/* ==========================================================================
   Base CSS - Shared variables, reset, and common styles
   ========================================================================== */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    --primary: hsl(0 0% 9%);
    --primary-hover: hsl(0 0% 9% / 0.9);
    --primary-light: hsl(0 0% 9% / 0.1);
    --accent: hsl(0 0% 96.1%);

    --background: hsl(0 0% 100%);
    --background-secondary: hsl(0 0% 98%);
    --card-bg: hsl(0 0% 100%);
    --border-color: hsl(0 0% 89.8%);

    --text-primary: hsl(0 0% 3.9%);
    --text-secondary: hsl(0 0% 45.1%);
    --text-muted: hsl(0 0% 63.9%);

    --error: hsl(0, 84%, 60%);
    --error-light: hsla(0, 84%, 60%, 0.1);
    --success: hsl(142, 76%, 36%);
    --success-light: hsla(142, 76%, 36%, 0.1);
    --warning: hsl(38, 92%, 50%);
    --warning-light: hsla(38, 92%, 50%, 0.1);

    --gradient-primary: linear-gradient(180deg, hsl(0, 0%, 9%) 0%, hsl(0, 0%, 25%) 100%);
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --code-bg: hsl(0 0% 9%);
    --code-text: hsl(0 0% 98%);
    --radius: 0.5rem;
}

/* ==========================================================================
   Reset
   ========================================================================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
    color: var(--primary-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ==========================================================================
   Common Animations
   ========================================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Spinner
   ========================================================================== */
.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px -10px hsla(222, 47%, 11%, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: var(--success);
}

.toast.error {
    border-color: var(--error);
}

.toast-icon {
    width: 20px;
    height: 20px;
}

.toast-icon.success {
    color: var(--success);
}

.toast-icon.error {
    color: var(--error);
}

.toast-message {
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* ==========================================================================
   Dashboard Layout (shared by dashboard, logs, billing, admin)
   ========================================================================== */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.logo-icon {
    width: 2rem;
    height: 2rem;
    border-radius: calc(var(--radius) - 2px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-icon svg {
    width: 1rem;
    height: 1rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    min-height: 2rem;
}

.nav-item:hover {
    background: var(--background-secondary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--background-secondary);
    color: var(--text-primary);
}

.nav-item svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: var(--radius);
    background: var(--background);
    border: 1px solid transparent;
}

.user-profile:hover {
    border-color: var(--border-color);
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    font-size: 0.75rem;
}

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

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-plan {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
}

.top-bar {
    height: 3.5rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.page-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.content-area {
    padding: 1.5rem;
}

/* Icon Button */
.icon-btn {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
    padding: 0;
}

.icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--background-secondary);
}

.icon-btn svg {
    width: 1rem;
    height: 1rem;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    color: transparent;
    overflow: hidden;
}

/* ==========================================================================
   Common Responsive - Sidebar mobile
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-overlay {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .menu-toggle {
        display: flex;
    }
}