/* ============================================================
   INNOVATIVE NECTAR — Portal Dark Theme
   ============================================================
   Extends design-tokens.css with a dark dashboard theme.
   Used by: site/pages/portal.html
   ============================================================ */

/* ── Dark Theme Overrides ─────────────────────────────── */
:root {
    --portal-bg: #051a10;
    --portal-panel: #0d2618;
    --portal-border: #1e3a29;
    --portal-text: #E2E8F0;
    --portal-muted: #94A3B8;
    --portal-success: #22c55e;
    --portal-error: #ef4444;
    --portal-warning: #f59e0b;
    --portal-amber: var(--color-amber, #FFBF00);
    --portal-forest: var(--color-forest, #014421);
    --portal-radius: 8px;
    --portal-sidebar-w: 260px;
}

/* ── Reset ───────────────────────────────────────────── */
.portal-app {
    background: var(--portal-bg);
    color: var(--portal-text);
    font-family: var(--font-head, 'Inter', sans-serif);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

/* ── Auth Overlay ────────────────────────────────────── */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--portal-bg);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.auth-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-box {
    width: 420px;
    max-width: 90vw;
    padding: 3rem;
    background: var(--portal-panel);
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    text-align: center;
}

.login-box h2 {
    color: white;
    margin-bottom: 0.5rem;
    font-size: 1.4rem;
}

.login-box .login-subtitle {
    color: var(--portal-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.login-box .login-logo {
    width: 80px;
    height: auto;
    margin-bottom: 1rem;
}

.login-box .portal-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--portal-border);
    color: white;
    padding: 0.85rem 1rem;
    border-radius: var(--portal-radius);
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.login-box .portal-input:focus {
    border-color: var(--portal-amber);
}

.login-box .portal-input::placeholder {
    color: var(--portal-muted);
}

.login-error {
    color: var(--portal-error);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: none;
}

.login-error.visible {
    display: block;
}

.login-box .btn-login {
    background: var(--portal-amber);
    color: var(--portal-bg);
    border: none;
    padding: 0.85rem;
    width: 100%;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: var(--portal-radius);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: opacity 0.2s;
}

.login-box .btn-login:hover {
    opacity: 0.9;
}

.login-box .dev-skip {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--portal-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.login-box .dev-skip:hover {
    color: var(--portal-amber);
}

.forgot-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--portal-muted);
    cursor: pointer;
    transition: color 0.2s;
    border: none;
    background: none;
    font-family: inherit;
}

.forgot-link:hover {
    color: var(--portal-amber);
}

/* ── Sidebar ─────────────────────────────────────────── */
.portal-sidebar {
    width: var(--portal-sidebar-w);
    min-height: 100vh;
    background: rgba(0, 0, 0, 0.2);
    border-right: 1px solid var(--portal-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2.5rem;
    color: white;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: -0.02em;
    text-decoration: none;
}

.sidebar-logo svg {
    width: 32px;
    height: auto;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    color: var(--portal-muted);
    text-decoration: none;
    border-radius: var(--portal-radius);
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.nav-item:hover {
    background: rgba(255, 191, 0, 0.1);
    color: var(--portal-amber);
}

.nav-item.active {
    background: var(--portal-amber);
    color: var(--portal-bg);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-profile {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--portal-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    background: var(--portal-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--portal-amber);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.profile-info {
    font-size: 0.85rem;
}

.profile-info .name {
    font-weight: 600;
    color: white;
}

.profile-info .plan {
    color: var(--portal-muted);
    font-size: 0.75rem;
}

.btn-logout {
    background: none;
    border: 1px solid var(--portal-border);
    color: var(--portal-muted);
    padding: 0.4rem 0.8rem;
    border-radius: var(--portal-radius);
    font-size: 0.75rem;
    cursor: pointer;
    margin-left: auto;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: var(--portal-error);
    color: var(--portal-error);
}

/* ── Main Content ────────────────────────────────────── */
.portal-main {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    max-height: 100vh;
}

.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.portal-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.portal-header p {
    color: var(--portal-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    color: var(--portal-success);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-pulse {
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
    animation: portalPulse 2s infinite;
}

@keyframes portalPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ── Views ───────────────────────────────────────────── */
.portal-view {
    display: none;
}

.portal-view.active {
    display: block;
}

/* ── Dashboard Grid ──────────────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--portal-panel);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 1.5rem;
    text-align: center;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--portal-amber);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--portal-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-change {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.kpi-change.up {
    color: var(--portal-success);
}

.kpi-change.down {
    color: var(--portal-error);
}

/* ── Panel Card ──────────────────────────────────────── */
.panel {
    background: var(--portal-panel);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--portal-border);
}

.panel-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--portal-amber);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.panel-meta {
    font-size: 0.8rem;
    color: var(--portal-muted);
}

/* ── Health Graph ────────────────────────────────────── */
.health-graph {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    padding-top: 20px;
}

.health-bar {
    flex: 1;
    background: rgba(255, 191, 0, 0.15);
    transition: height 0.5s ease, background 0.2s;
    border-top: 2px solid var(--portal-amber);
    border-radius: 2px 2px 0 0;
    min-height: 10px;
}

.health-bar:hover {
    background: rgba(255, 191, 0, 0.4);
}

/* ── Health Gauge ────────────────────────────────────── */
.gauge-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3rem;
    padding: 2rem 0;
}

.gauge-svg {
    width: 180px;
    height: 180px;
}

.gauge-bg {
    fill: none;
    stroke: var(--portal-border);
    stroke-width: 12;
}

.gauge-fill {
    fill: none;
    stroke: var(--portal-amber);
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease;
}

.gauge-text {
    fill: white;
    font-size: 2rem;
    font-weight: 800;
    text-anchor: middle;
    dominant-baseline: central;
}

.gauge-label-text {
    fill: var(--portal-muted);
    font-size: 0.7rem;
    text-anchor: middle;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.gauge-stats {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.gauge-stat-item {
    text-align: center;
}

.gauge-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
}

.gauge-stat-label {
    font-size: 0.75rem;
    color: var(--portal-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.25rem;
}

/* ── Activity Log ────────────────────────────────────── */
.activity-list {
    list-style: none;
}

.activity-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--portal-border);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.8rem;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-time {
    color: var(--portal-muted);
    min-width: 80px;
}

.activity-action {
    color: var(--portal-text);
    flex: 1;
    padding: 0 1rem;
}

.activity-status {
    font-weight: 600;
    min-width: 80px;
    text-align: right;
}

.activity-status.success {
    color: var(--portal-success);
}

.activity-status.warning {
    color: var(--portal-warning);
}

.activity-status.error {
    color: var(--portal-error);
}

.activity-status.pending {
    color: var(--portal-amber);
}

/* ── Milestone Tracker ───────────────────────────────── */
.milestone-current {
    text-align: center;
    margin-bottom: 2rem;
}

.milestone-current h3 {
    color: white;
    font-size: 1.5rem;
}

.milestone-current p {
    font-size: 0.8rem;
    color: var(--portal-muted);
    margin-top: 4px;
}

.milestone-track {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-top: 1.5rem;
    padding: 0 1rem;
}

.track-line {
    position: absolute;
    top: 12px;
    left: 2rem;
    right: 2rem;
    height: 2px;
    background: var(--portal-border);
    z-index: 0;
}

.milestone-step {
    position: relative;
    z-index: 1;
    text-align: center;
    flex: 1;
}

.step-dot {
    width: 24px;
    height: 24px;
    background: var(--portal-panel);
    border: 2px solid var(--portal-muted);
    border-radius: 50%;
    margin: 0 auto 8px;
    transition: all 0.3s;
}

.milestone-step.completed .step-dot {
    background: var(--portal-amber);
    border-color: var(--portal-amber);
    box-shadow: 0 0 12px rgba(255, 191, 0, 0.4);
}

.milestone-step.current .step-dot {
    border-color: var(--portal-amber);
    box-shadow: 0 0 8px rgba(255, 191, 0, 0.2);
}

.step-label {
    font-size: 0.75rem;
    color: var(--portal-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.milestone-step.completed .step-label {
    color: white;
    font-weight: 600;
}

.milestone-step.current .step-label {
    color: var(--portal-amber);
    font-weight: 600;
}

/* ── Error Log Table ─────────────────────────────────── */
.error-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.error-table th {
    text-align: left;
    padding: 0.8rem;
    color: var(--portal-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--portal-border);
}

.error-table td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--portal-border);
    color: var(--portal-text);
}

.error-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge--resolved {
    background: rgba(34, 197, 94, 0.15);
    color: var(--portal-success);
}

.badge--pending {
    background: rgba(255, 191, 0, 0.15);
    color: var(--portal-amber);
}

.badge--manual {
    background: rgba(239, 68, 68, 0.15);
    color: var(--portal-error);
}

.badge--paid {
    background: rgba(34, 197, 94, 0.15);
    color: var(--portal-success);
}

.badge--overdue {
    background: rgba(239, 68, 68, 0.15);
    color: var(--portal-error);
}

/* ── Ticket Form ─────────────────────────────────────── */
.portal-form .form-group {
    margin-bottom: 1rem;
}

.portal-form .form-label {
    display: block;
    font-size: 0.8rem;
    color: var(--portal-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.portal-form .portal-input,
.portal-form .portal-select,
.portal-form .portal-textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--portal-border);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: var(--portal-radius);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.portal-form .portal-input:focus,
.portal-form .portal-select:focus,
.portal-form .portal-textarea:focus {
    border-color: var(--portal-amber);
}

.portal-form .portal-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.portal-form .portal-select option {
    background: var(--portal-panel);
    color: white;
}

.portal-form .portal-textarea {
    resize: vertical;
    min-height: 100px;
}

.btn-portal {
    background: var(--portal-amber);
    color: var(--portal-bg);
    border: none;
    padding: 0.85rem 1.5rem;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: var(--portal-radius);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: opacity 0.2s;
    font-family: inherit;
}

.btn-portal:hover {
    opacity: 0.9;
}

.btn-portal:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-portal--full {
    width: 100%;
}

.ticket-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: var(--portal-success);
    padding: 1rem;
    border-radius: var(--portal-radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    display: none;
}

.ticket-success.visible {
    display: block;
}

/* ── Invoice Table ───────────────────────────────────── */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.invoice-table th {
    text-align: left;
    padding: 0.8rem 1rem;
    color: var(--portal-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--portal-border);
}

.invoice-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--portal-border);
}

.invoice-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.invoice-amount {
    font-weight: 700;
    color: white;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
}

.btn-download {
    background: none;
    border: 1px solid var(--portal-border);
    color: var(--portal-amber);
    padding: 0.3rem 0.8rem;
    border-radius: var(--portal-radius);
    font-size: 0.75rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-download:hover {
    background: rgba(255, 191, 0, 0.1);
    border-color: var(--portal-amber);
}

/* ── Two-Column Layout ───────────────────────────────── */
.portal-grid-2 {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
}

.portal-grid-2-equal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {
    .portal-sidebar {
        width: 200px;
        padding: 1rem;
    }

    .dash-grid {
        grid-template-columns: 1fr 1fr;
    }

    .portal-grid-2,
    .portal-grid-2-equal {
        grid-template-columns: 1fr;
    }

    .gauge-container {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .portal-app {
        flex-direction: column;
    }

    .portal-sidebar {
        width: 100%;
        min-height: auto;
        flex-direction: row;
        overflow-x: auto;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
        border-right: none;
        border-bottom: 1px solid var(--portal-border);
    }

    .sidebar-logo {
        margin-bottom: 0;
        margin-right: 1rem;
        white-space: nowrap;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 0.25rem;
    }

    .nav-item {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
        font-size: 0.8rem;
    }

    .sidebar-profile {
        display: none;
    }

    .portal-main {
        max-height: none;
        padding: 1rem;
    }

    .dash-grid {
        grid-template-columns: 1fr;
    }

    .portal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .milestone-track {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}