/* ===== Project Builder Base Styles ===== */
/* Theme-specific colors are defined in css/themes/*.css */

html, body {
    background-color: var(--theme-bg) !important;
    color: var(--theme-text) !important;
    font-family: var(--font-body) !important;
    font-size: 15px;
    font-weight: 400;
}

/* ===== Typography ===== */

h1, h2, h3 {
    font-family: var(--font-display) !important;
    color: var(--theme-primary) !important;
    font-weight: 500 !important;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 1.3rem !important;
}

h4, h5, h6 {
    font-family: var(--font-display) !important;
    color: var(--theme-text-bright) !important;
    font-weight: 400 !important;
    letter-spacing: 0.06em;
    font-size: 1rem !important;
}

p, div, span, label, small, li, td, th {
    color: var(--theme-text);
}

a {
    color: var(--theme-primary) !important;
    text-decoration: none !important;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--theme-accent) !important;
}

code {
    color: var(--theme-primary) !important;
    background-color: var(--theme-code-bg) !important;
    border: 1px solid var(--theme-border);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-family: var(--font-mono) !important;
    font-size: 0.85em;
}

.text-muted {
    color: var(--theme-text-muted) !important;
}

.font-monospace {
    font-family: var(--font-mono) !important;
}

/* ===== Glass Panel Cards ===== */

.card {
    background: var(--theme-bg-card) !important;
    border: 1px solid var(--theme-border) !important;
    border-radius: 6px !important;
    box-shadow: var(--theme-card-shadow);
    position: relative;
    overflow: hidden;
}

.card-header {
    background: var(--theme-card-header-bg) !important;
    border-bottom: 1px solid var(--theme-border) !important;
    color: var(--theme-text-bright) !important;
    font-family: var(--font-display) !important;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.card-header h5 {
    font-size: 0.85rem !important;
}

.card-body {
    background: transparent !important;
    color: var(--theme-text) !important;
}

/* ===== Tables ===== */

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--theme-text);
    --bs-table-border-color: var(--theme-border);
    --bs-table-hover-bg: var(--theme-glass);
    --bs-table-hover-color: var(--theme-text-bright);
}

.table > thead > tr > th {
    color: var(--theme-text-bright);
    border-bottom-color: var(--theme-border);
}

.table > tbody > tr > td {
    border-bottom-color: var(--theme-border);
}

/* ===== Forms ===== */

.form-control, .form-select, .input-group-text {
    background-color: var(--theme-bg-input) !important;
    color: var(--theme-text-bright) !important;
    border: 1px solid var(--theme-border) !important;
    font-family: var(--font-body) !important;
    font-size: 0.95rem;
    border-radius: 4px !important;
    transition: all 0.25s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--theme-bg-input) !important;
    color: var(--theme-text-bright) !important;
    border-color: var(--theme-primary) !important;
}

.form-control::placeholder {
    color: var(--theme-placeholder) !important;
    opacity: 1;
}

.form-label {
    color: var(--theme-primary-dim) !important;
    font-family: var(--font-display) !important;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 0.35rem;
}

.form-text {
    color: var(--theme-form-text) !important;
    font-size: 0.8rem;
}

.form-check-input {
    background-color: var(--theme-bg-input) !important;
    border-color: var(--theme-border-strong) !important;
    border-radius: 2px !important;
}

.form-check-input:checked {
    background-color: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
}

.form-check-label {
    color: var(--theme-text) !important;
    font-size: 0.9rem;
}

/* ===== Buttons ===== */

.btn {
    font-family: var(--font-display) !important;
    font-size: 0.75rem !important;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: 3px !important;
    transition: all 0.25s ease;
    position: relative;
}

.btn-primary {
    background: var(--theme-btn-primary-bg) !important;
    border: 1px solid var(--theme-primary) !important;
    color: var(--theme-primary) !important;
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--theme-btn-primary-hover-bg) !important;
    border-color: var(--theme-primary) !important;
    color: var(--theme-btn-hover-color) !important;
}

.btn-lg {
    font-size: 0.85rem !important;
    padding: 0.6rem 1.8rem !important;
}

.btn-outline-secondary {
    border-color: var(--theme-btn-secondary-border) !important;
    color: var(--theme-text) !important;
}

.btn-outline-secondary:hover {
    background: var(--theme-btn-secondary-hover-bg) !important;
    border-color: var(--theme-btn-secondary-hover-border) !important;
    color: var(--theme-text-bright) !important;
}

.btn-outline-danger {
    border-color: var(--theme-danger) !important;
    color: var(--theme-danger) !important;
}

.btn-outline-danger:hover {
    background: var(--theme-btn-danger-hover-bg) !important;
    color: var(--theme-danger) !important;
}

.btn-outline-warning {
    border-color: var(--theme-tertiary) !important;
    color: var(--theme-tertiary) !important;
}

.btn-outline-warning:hover {
    background: var(--theme-btn-warning-hover-bg) !important;
    color: var(--theme-tertiary) !important;
}

.btn-outline-info {
    border-color: var(--theme-secondary) !important;
    color: var(--theme-secondary) !important;
}

.btn-outline-info:hover {
    background: var(--theme-btn-info-hover-bg) !important;
    color: var(--theme-secondary) !important;
}

.btn-success {
    background: var(--theme-btn-success-bg) !important;
    border: 1px solid var(--theme-success) !important;
    color: var(--theme-success) !important;
}

.btn-success:hover {
    background: var(--theme-btn-success-hover-bg) !important;
    color: var(--theme-btn-hover-color) !important;
}

.btn-outline-success {
    border-color: var(--theme-success) !important;
    color: var(--theme-success) !important;
}

.btn-outline-success:hover {
    background: var(--theme-btn-success-outline-hover-bg) !important;
    color: var(--theme-success) !important;
}

.btn:disabled, .btn.disabled {
    opacity: var(--theme-btn-disabled-opacity) !important;
    box-shadow: none !important;
}

/* ===== Badges ===== */

.badge {
    font-family: var(--font-display) !important;
    font-size: 0.65rem !important;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: 2px !important;
    padding: 0.3em 0.6em !important;
}

.badge.bg-primary {
    background: var(--theme-badge-primary-bg) !important;
    color: var(--theme-primary) !important;
    border: 1px solid var(--theme-badge-primary-border);
}

.badge.bg-success {
    background: var(--theme-badge-success-bg) !important;
    color: var(--theme-success) !important;
    border: 1px solid var(--theme-badge-success-border);
}

.badge.bg-danger {
    background: var(--theme-badge-danger-bg) !important;
    color: var(--theme-danger) !important;
    border: 1px solid var(--theme-badge-danger-border);
}

.badge.bg-warning {
    background: var(--theme-badge-warning-bg) !important;
    color: var(--theme-warning) !important;
    border: 1px solid var(--theme-badge-warning-border);
}

.badge.bg-secondary {
    background: var(--theme-badge-secondary-bg) !important;
    color: var(--theme-primary-muted) !important;
    border: 1px solid var(--theme-border);
}

/* ===== Alerts ===== */

.alert {
    border-radius: 4px !important;
    font-family: var(--font-body) !important;
}

.alert-info {
    background: var(--theme-alert-info-bg) !important;
    border: 1px solid var(--theme-border) !important;
    color: var(--theme-text) !important;
}

.alert-warning {
    background: var(--theme-alert-warning-bg) !important;
    border: 1px solid var(--theme-alert-warning-border) !important;
    color: var(--theme-warning) !important;
}

.alert-danger {
    background: var(--theme-alert-danger-bg) !important;
    border: 1px solid var(--theme-alert-danger-border) !important;
    color: var(--theme-danger) !important;
}

.alert-link {
    color: var(--theme-primary) !important;
    font-weight: 600;
}

/* ===== List Groups ===== */

.list-group-item {
    background: var(--theme-bg-card) !important;
    border: 1px solid var(--theme-border) !important;
    color: var(--theme-text) !important;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    border-radius: 4px !important;
}

.list-group-item:hover {
    border-color: var(--theme-border-strong) !important;
}

.list-group-item h5 {
    font-family: var(--font-display) !important;
    color: var(--theme-text-bright) !important;
    font-size: 0.9rem !important;
    letter-spacing: 0.08em;
}

/* ===== Validation ===== */

.validation-message, .field-validation-error {
    color: var(--theme-danger) !important;
    font-size: 0.8rem;
}

.validation-summary-errors {
    color: var(--theme-danger) !important;
}

.invalid, .input-validation-error {
    border-color: var(--theme-danger) !important;
}

/* ===== Spinner ===== */

.spinner-border {
    color: var(--theme-primary) !important;
}

/* ===== Scrollbar ===== */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--theme-scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--theme-scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--theme-scrollbar-thumb-hover);
}

/* ===== Selection ===== */

::selection {
    background-color: var(--theme-selection-bg);
    color: var(--theme-selection-color);
}

/* ===== Console panels (used across pages) ===== */

.console-output {
    background-color: var(--theme-console-bg) !important;
    color: var(--theme-primary) !important;
    font-family: var(--font-mono) !important;
    font-size: 0.8rem !important;
    border: 1px solid var(--theme-border) !important;
    border-radius: 4px !important;
}

/* ===== Error UI ===== */

#blazor-error-ui {
    background: var(--theme-error-ui-bg) !important;
    color: var(--theme-danger) !important;
    border-top: 1px solid var(--theme-error-ui-border);
    bottom: 0;
    box-shadow: var(--theme-error-ui-shadow);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

/* ===== Utility ===== */

.gap-2 {
    gap: 0.5rem !important;
}

/* ===== BusyOverlay ===== */

.busy-overlay {
    position: absolute;
    inset: 0;
    background: var(--theme-busy-overlay-bg);
    opacity:0.4;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

.busy-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.busy-spinner-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--theme-spinner-ring);
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    animation: busy-spin 0.8s linear infinite;
}

.busy-spinner-ring-sm {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--theme-spinner-ring);
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    animation: busy-spin 0.8s linear infinite;
    vertical-align: middle;
}

.busy-status-text {
    font-family: var(--font-display);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--theme-primary);
}

.busy-overlay-cancel {
    font-family: var(--font-display);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--theme-danger);
    background: var(--theme-cancel-bg);
    border: 1px solid var(--theme-danger);
    border-radius: 3px;
    padding: 0.3em 1.2em;
    cursor: pointer;
    transition: all 0.25s ease;
}

.busy-overlay-cancel:hover {
    background: var(--theme-cancel-hover-bg);
}

.busy-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-display);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--theme-primary);
}

@keyframes busy-spin {
    to { transform: rotate(360deg); }
}

/* ===== Dashboard ===== */

.dashboard-stat-card {
    border: 1px solid var(--theme-border-strong);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.dashboard-stat-card:hover {
    border-color: var(--theme-primary);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--theme-primary);
    line-height: 1.2;
}

.stat-value.stat-running {
    color: var(--theme-success);
}

.stat-value.stat-chat {
    color: var(--theme-secondary);
}

.stat-value.stat-templates {
    color: var(--theme-tertiary);
}

.stat-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--theme-text);
    margin-top: 0.25rem;
}

/* ===== Git Log Commits ===== */

.commit-entry:nth-child(odd) {
    background: var(--theme-git-odd-bg);
}

.commit-entry:nth-child(even) {
    background: var(--theme-git-even-bg);
}

.commit-entry.commit-head {
    background: var(--theme-git-head-bg);
    border-radius: 3px;
}

.commit-head-badge {
    color: var(--theme-git-head-badge);
    font-size: 0.6rem;
    font-weight: 600;
    border: 1px solid var(--theme-git-head-badge);
    border-radius: 3px;
    padding: 0 0.3em;
}

.commit-hash {
    color: var(--theme-git-hash);
    font-weight: 500;
}

.commit-date {
    color: var(--theme-git-date);
    white-space: nowrap;
    font-size: 0.75rem;
}

.commit-revert-btn {
    border-width: 1px !important;
}

.commit-message {
    color: var(--theme-git-message);
    word-break: break-word;
}

.commit-expand-btn {
    background: none;
    border: none;
    color: var(--theme-git-expand);
    cursor: pointer;
    padding: 0 0.3em;
    font-size: 0.75rem;
    font-family: inherit;
}

/* ===== Sidebar Collapse ===== */

@media (min-width: 641px) {
    /* Inner wrapper clips content when collapsed, expands on hover */
    .sidebar-inner {
        width: 250px;
        height: 100vh;
        overflow: hidden;
        transition: width 0.25s ease;
    }

    .sidebar-collapsed .sidebar-inner {
        width: 56px;
    }

    .sidebar-collapsed .sidebar:hover .sidebar-inner {
        width: 250px;
    }

    /* Hide text labels when collapsed */
    .sidebar-collapsed .nav-label,
    .sidebar-collapsed .navbar-brand {
        opacity: 0;
        transition: opacity 0.15s ease;
    }

    .sidebar-collapsed .sidebar:hover .nav-label,
    .sidebar-collapsed .sidebar:hover .navbar-brand {
        opacity: 1;
    }

    /* Collapse icon flips when collapsed */
    .sidebar-collapsed .bi-collapse-icon {
        transform: scaleX(-1);
    }

    /* Shrink nav items to icon-only when collapsed */
    .sidebar-collapsed .nav-item {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        transition: padding 0.25s ease;
    }

    .sidebar-collapsed .sidebar:hover .nav-item {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .sidebar-collapsed .nav-link {
        overflow: hidden;
    }

    .sidebar-collapsed .bi {
        margin-right: 0;
        transition: margin 0.25s ease;
    }

    .sidebar-collapsed .sidebar:hover .bi {
        margin-right: 0.75rem;
    }

    /* Hover overlay effect */
    .sidebar-collapsed .sidebar:hover {
        position: relative;
        z-index: 100;
        box-shadow: var(--theme-sidebar-hover-shadow);
    }
}

/* ===== Theme Selector ===== */

.theme-selector {
    margin-right: auto;
    display: flex;
    align-items: center;
}

.theme-dropdown {
    background: var(--theme-bg-input);
    color: var(--theme-text);
    border: 1px solid var(--theme-border);
    border-radius: 3px;
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.theme-dropdown:hover,
.theme-dropdown:focus {
    border-color: var(--theme-primary);
}

.theme-dropdown option {
    background: var(--theme-bg);
    color: var(--theme-text);
}
