/* ============================================================
   PolyCop — Dashboard Layout CSS
   ============================================================ */

/* ---------- Sidebar + Main Layout ---------- */
.dashboard-body {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.25s ease;
}

.dashboard-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    height: 100vh;
}

/* ---------- Sidebar Header ---------- */
.sidebar-header {
    padding: 20px 18px 12px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.3px;
    text-decoration: none;
}

.logo-dot {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #000;
    box-shadow: 0 0 12px var(--primary-glow);
}

/* ---------- Sidebar Nav ---------- */
.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(59, 107, 250, 0.12);
    color: var(--text-primary);
}

.sidebar-link.active {
    color: #ffffff;
}

.sidebar-link svg {
    flex-shrink: 0;
    opacity: 0.75;
}

.sidebar-link.active svg,
.sidebar-link:hover svg {
    opacity: 1;
}

/* ---------- Sidebar Footer ---------- */
.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    transition: background 0.15s;
    text-align: left;
}

.profile-trigger:hover {
    background: var(--bg-input);
}

.profile-avatar-small {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

/* Dropdown menu */
.profile-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    z-index: 200;
    display: none;
}

.dropdown-menu.open {
    display: block;
    animation: slideUp 0.18s ease;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.13s, color 0.13s;
}

.dropdown-item:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.dropdown-item.logout {
    color: var(--danger);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* ---------- Content Header ---------- */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.content-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.content-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 3px;
}

.content-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ---------- Tab Sections ---------- */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
}

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
}

.stat-label {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---------- API Keys ---------- */
.key-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    transition: border-color 0.15s;
}

.key-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.key-info {
    flex: 1;
    min-width: 0;
}

.key-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13.5px;
    margin-bottom: 4px;
}

.key-prefix {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.key-meta {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

.key-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Created key banner */
.key-result-banner {
    background: rgba(45, 219, 129, 0.08);
    border: 1px solid rgba(45, 219, 129, 0.3);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.key-result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    color: var(--success);
}

.key-result-header h3 {
    color: var(--text-primary);
}

.key-result-header p {
    color: var(--text-secondary);
    font-size: 12.5px;
}

.key-result-body {
    display: flex;
    gap: 10px;
    align-items: center;
}

.key-result-body code {
    flex: 1;
    padding: 10px 14px;
    font-size: 13px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Wallet ---------- */
.wallet-balance-card {
    background: linear-gradient(135deg, #222222 0%, #000000 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 22px;
    position: relative;
    overflow: hidden;
}

.wallet-balance-card::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.wallet-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
}

.wallet-amount {
    font-size: 2.6rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -1px;
}

.wallet-sub {
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 6px;
}

.topup-presets {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.topup-preset-btn {
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card-2);
    color: var(--text-primary);
    transition: all 0.15s;
    font-family: inherit;
}

.topup-preset-btn:hover,
.topup-preset-btn.selected {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    color: #ffffff;
}

/* ---------- Usage Charts ---------- */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 22px;
    min-height: 220px;
    position: relative;
}

.chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

/* Simple bar chart bars */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 160px;
    padding-bottom: 24px;
    overflow-x: auto;
}

.bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 24px;
}

.bar-fill {
    width: 20px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    transition: height 0.4s ease;
    min-height: 2px;
    opacity: 0.85;
}

.bar-fill:hover {
    opacity: 1;
}

.bar-label {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    transform: rotate(-45deg);
    transform-origin: top left;
    margin-top: 8px;
    margin-left: 10px;
}

/* ---------- Mobile Header ---------- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 18px;
    align-items: center;
    justify-content: space-between;
    z-index: 300;
    height: 56px;
}

.mobile-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .dashboard-main {
        margin-left: 0;
        padding: 20px 16px;
        margin-top: 56px;
        height: calc(100vh - 56px);
    }
}

/* ---------- Auth Pages (Login) ---------- */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 60%),
        var(--bg-base);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    justify-content: center;
}

.auth-logo span {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.auth-title {
    text-align: center;
    margin-bottom: 8px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13.5px;
    margin-bottom: 28px;
}

.auth-error {
    background: rgba(232, 76, 106, 0.1);
    border: 1px solid rgba(232, 76, 106, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 18px;
    display: none;
}

/* ---------- Account Tab ---------- */
.account-info-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.account-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.account-info-row:last-child {
    border-bottom: none;
}

.account-info-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.account-info-value {
    font-size: 13.5px;
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}