/* ========================================
   Top Bar
   ======================================== */

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.menu-toggle:hover {
    background-color: var(--hover-bg);
}

.hamburger {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-primary);
    margin: 4px 0;
    border-radius: 1px;
    transition: var(--transition);
}

.app-title {
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.app-brand {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.top-bar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 24px;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 0 0 auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
}

.user-email {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* User Icon in Info Table or Top Bar */
.user-with-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.logout-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.logout-btn:hover {
    background-color: var(--hover-bg);
    color: var(--danger);
}


/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 64px;
    bottom: 0;
    width: 256px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-light);
    padding: 20px 0;
    overflow-y: auto;
    z-index: 90;
    transition: transform 0.3s ease;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: none;
    border: none;
    border-radius: 0 28px 28px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    margin-right: 8px;
}

.nav-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

.nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background-color: var(--border-light);
    margin: 12px 24px 12px 0;
}

.sidebar-storage {
    padding: 20px 24px;
    border-top: 1px solid var(--border-light);
    margin-top: 20px;
}

.storage-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.storage-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary);
}

.cost-breakdown {
    margin-top: 12px;
    padding: 12px;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    font-size: 12px;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    color: var(--text-secondary);
}

.cost-label {
    color: var(--text-secondary);
}

.cost-amount {
    font-weight: 600;
    color: var(--text-primary);
}

.metrics-info {
    margin-top: 8px;
}

.cache-metrics {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    font-size: 11px;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    color: var(--text-secondary);
}

.metric-label {
    color: var(--text-secondary);
    font-size: 11px;
}

.metric-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 11px;
}

.btn-clear-cache {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    margin-top: 8px;
    padding: 6px 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-clear-cache:hover {
    background-color: var(--hover-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-clear-cache:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-clear-cache svg {
    width: 14px;
    height: 14px;
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    margin-left: 256px;
    margin-top: 64px;
    padding: 32px;
    min-height: calc(100vh - 64px);
    background-color: var(--bg-secondary);
}

/* ========================================
   Login Page
   ======================================== */

body.login-page {
    background: linear-gradient(135deg, var(--login-bg-start) 0%, var(--login-bg-end) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    width: 100%;
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-header {
    margin-bottom: 2rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    stroke: #667eea;
    stroke-width: 1.5;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.75rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #666;
    font-size: 0.95rem;
}

.login-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.google-btn {
    background: white;
    border: 1px solid #dadce0;
    color: #3c4043;
}

.google-btn:hover {
    background: #f1f3f4;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.login-notice {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #888;
}

/* ========================================
   Responsive Layout
   ======================================== */

@media (max-width: 1200px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1001; /* Above overlay */
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: transparent;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 1000;
    }

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        height: auto;
        padding: 12px;
        gap: 12px;
    }

    .top-bar-left,
    .top-bar-center,
    .top-bar-right {
        width: 100%;
    }

    .top-bar-center {
        padding: 0;
    }

    .main-content {
        margin-top: 0;
        padding: 16px;
    }

    .app-title {
        font-size: 18px;
    }

    .user-email {
        display: none;
    }
}
