:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #06b6d4;
    --accent-color: #8b5cf6;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --success: #10b981;
    --danger: #ef4444;
    --gradient-main: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    --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);
    --radius-md: 0.5rem;
    --radius-lg: 1rem;

    /* Admin Specific */
    --admin-dark: #0f172a;
    --admin-card: rgba(255, 255, 255, 0.8);
    --admin-bg: #f1f5f9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    margin-bottom: 1rem;
    color: #111827;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Auth Pages (Login/Register) */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--gradient-main);
    padding: 20px;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 2rem;
    color: var(--primary-dark);
}

.auth-header p {
    color: var(--text-light);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--gradient-main);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: white;
    box-shadow: var(--shadow-md);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 100vh;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    flex: 1 1 auto;
    padding: 1.5rem 1rem;
    list-style: none;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 180px);
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-light);
    border-radius: var(--radius-md);
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    background-color: #eef2ff;
    color: var(--primary-color);
}

.nav-icon {
    margin-right: 0.75rem;
}

.user-profile {
    padding: 1rem;
    border-top: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    text-align: center;
    min-height: 120px;
}

.avatar-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), #667eea);
    color: white;
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.text-sm {
    font-size: 0.75rem;
}

.text-danger {
    color: #dc2626;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
    display: inline-block;
    margin-top: 0.5rem;
}

.text-danger:hover {
    color: #991b1b;
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
}

.page-header {
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid #f3f4f6;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0.5rem 0;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
}

th {
    font-weight: 600;
    color: var(--text-light);
    background-color: #f9fafb;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* Admin Portal Refinement */
.admin-body {
    background-color: var(--admin-bg);
}

.admin-sidebar {
    background-color: var(--admin-dark);
    color: white;
}

.admin-sidebar .logo {
    background: white;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.admin-sidebar .nav-link {
    color: #94a3b8;
}

.admin-sidebar .nav-link:hover, .admin-sidebar .nav-active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.admin-stat-card {
    background: white;
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    border: 1px solid rgba(226, 232, 240, 0.8);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.admin-stat-card:hover {
    transform: translateY(-5px);
}

.admin-stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--admin-primary);
}

.admin-stat-icon {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 2.5rem;
    opacity: 0.1;
    color: var(--admin-dark);
}

.admin-tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.admin-tool-card {
    background: white;
    padding: 1.5rem;
    border-radius: 1.25rem;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.2s ease;
}

.admin-tool-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    background: #f8fafc;
}

.admin-tool-icon {
    width: 56px;
    height: 56px;
    background: #f1f5f9;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--admin-dark);
    font-size: 1.25rem;
}

.admin-tool-card:hover .admin-tool-icon {
    background: var(--primary-color);
    color: white;
}

/* --- Mobile Responsiveness --- */
.mobile-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: white;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 90;
}

.menu-toggle {
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

@media screen and (max-width: 640px) {
    .dashboard-layout {
        flex-direction: column;
    }
    
    .mobile-header {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        width: 280px;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .container {
        padding: 0 1rem;
    }

    .main-content {
        padding: 1rem;
    }

    .card, .admin-stat-card, .admin-tool-card {
        margin-bottom: 1rem;
    }

    .btn-block, .btn-full {
        width: 100%;
    }

    .form-control,
    .form-group input,
    .form-group select,
    .form-group textarea,
    .card-header,
    .card-footer {
        width: 100%;
    }

    .page-header {
        margin-bottom: 1.5rem;
    }

    .table-responsive {
        overflow-x: auto;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
        overflow-x: hidden;
    }

    .stats-grid, .admin-stat-grid, .admin-tool-grid {
        grid-template-columns: 1fr;
    }

    .card, .admin-stat-card, .admin-tool-card {
        padding: 1rem;
    }
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .row {
        flex-direction: column;
    }
    
    .form-group input, .form-group select, .form-group textarea {
        width: 100%;
    }
    
    /* Wizard Overrides for all generator files */
    .break-row, .topic-row, .lesson-row {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    .wizard-footer {
        flex-direction: column !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }
    
    .btn-wizard {
        width: 100% !important;
        justify-content: center !important;
    }
    
    .progress-bar {
        padding: 1rem !important;
        overflow-x: auto !important;
        gap: 0.5rem !important;
    }
    
    .step-label, .step-name {
        display: none !important;
    }
    
    .progress-step {
        flex: 0 0 auto !important;
        width: 50px !important;
    }
    
    .preview-grid {
        grid-template-columns: 1fr !important;
        margin-bottom: 1rem !important;
    }
    
    /* Fix inline grids that force multi-column on mobile */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr 1fr"],
    div[style*="grid-template-columns: 280px 1fr"],
    div[style*="grid-template-columns: repeat(3, 1fr)"],
    .options-grid {
        grid-template-columns: 1fr !important;
    }
}

