@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Theme Colors */
    --primary: #4f46e5;
    /* Indigo */
    --primary-hover: #4338ca;

    /* Light Theme (Dashboard) */
    --bg-main: #f3f4f6;
    /* Very light gray/blue tint */
    --bg-card: #ffffff;
    --text-main: #111827;
    /* Almost black */
    --text-muted: #6b7280;
    /* Gray 500 */
    --border: #e5e7eb;

    /* Dark Theme (Public & Legacy) */
    --bg-dark: #0f172a;
    --bg-dark-card: #1e293b;
    --text-light: #f8fafc;

    /* Premium Sidebar */
    --sidebar-bg: #111827;
    /* Deep gray/black */
    --sidebar-text: #9ca3af;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: rgba(255, 255, 255, 0.1);

    /* Status & Accents */
    --danger: #ef4444;
    --success: #10b981;
    /* Emerald */
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

html,
body {
    overflow-x: hidden;
    /* Crucial for mobile no-scroll */
    max-width: 100vw;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

/* Utilities */
.container {
    max-width: 1600px;
    /* Wider for dashboard */
    margin: 0 auto;
    padding: 0 1.5rem;
    width: 100%;
}

.text-center {
    text-align: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-outline {
    border-color: var(--border);
    color: var(--text-main);
    background: white;
}

.btn-outline:hover {
    background: #f9fafb;
    border-color: var(--text-muted);
}

/* Sidebar (Premium) */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 2rem 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-menu {
    flex: 1;
    padding: 1.5rem 1rem;
    list-style: none;
}

.menu-item {
    margin-bottom: 0.5rem;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.menu-link::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background-color: var(--primary);
    transform: scaleY(0);
    transition: transform 0.2s;
}

.menu-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

.menu-link:hover::after {
    transform: scaleY(1);
}

.menu-link.active {
    color: white;
    background-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.menu-link.active::after {
    display: none;
}

.menu-link i {
    width: 24px;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

/* Submenu */
.submenu {
    padding-left: 2.5rem;
    list-style: none;
    display: none;
    margin-top: 0.25rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    margin-left: 1.2rem;
}

.menu-item.open .submenu {
    display: block;
    animation: slideDown 0.3s ease-out;
}

.submenu-link {
    display: block;
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s, transform 0.2s;
}

.submenu-link:hover {
    color: white;
    transform: translateX(5px);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2.5rem;
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: calc(100% - 280px);
    max-width: 100vw;
    /* Prevent overflow */
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    animation: fadeInDown 0.6s ease-out;
}

.page-title {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
}

/* Widgets (Premium) */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.widget {
    background: var(--bg-card);
    padding: 1.75rem;
    border-radius: 1rem;
    border: none;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
    /* Start hidden for stagger */
}

.widget:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-premium);
}

.widget:nth-child(1) {
    animation-delay: 0.1s;
}

.widget:nth-child(2) {
    animation-delay: 0.2s;
}

.widget:nth-child(3) {
    animation-delay: 0.3s;
}

.widget:nth-child(4) {
    animation-delay: 0.4s;
}

.widget-icon-wrapper {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-main);
    font-size: 1.25rem;
    transition: transform 0.3s;
}

.widget:hover .widget-icon-wrapper {
    transform: rotate(10deg) scale(1.1);
}

.widget-title {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.widget-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

/* Charts Section */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    animation: fadeInUp 0.6s ease-out 0.5s forwards;
    /* Delay after widgets */
    opacity: 0;
}

.chart-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    transition: transform 0.3s;
}

.chart-card:hover {
    transform: translateY(-3px);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Animation Keyframes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Public & Legacy Fixes */
.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 800;
    font-size: 1.5rem;
    color: #f8fafc;
    text-decoration: none;
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: var(--bg-dark);
}

.auth-card {
    background-color: var(--bg-dark-card);
    padding: 2.5rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    color: var(--text-light);
}

.auth-card .form-control {
    background-color: #0f172a;
    border-color: #334155;
    color: white;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    ring: 2px solid rgba(79, 70, 229, 0.2);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.auth-card .form-label {
    color: #cbd5e1;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    .main-content {
        margin-left: 0;
        padding: 1.5rem;
        width: 100%;
        max-width: 100vw;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    .menu-toggle {
        display: block;
        margin-right: 1rem;
        font-size: 1.5rem;
        background: transparent;
        border: none;
        color: var(--text-main);
        cursor: pointer;
    }

    /* Overlay effect when sidebar opens */
    .sidebar.open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
        width: 100vw;
        height: 100vh;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .widgets-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}