*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Dark Theme (Default) */
:root {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --primary-color: #3b82f6;
    --secondary-color: #1e293b;
    --accent-color: #8b5cf6;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --card-bg: rgba(30, 41, 59, 0.6);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --header-height: 60px;
    --sidebar-width: 250px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --primary-color: #3b82f6;
    --secondary-color: #ffffff;
    --accent-color: #8b5cf6;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --card-bg: rgba(255, 255, 255, 0.9);
    --glass-border: 1px solid rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    width: 100%;
}

/* Layout Structure */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Mobile Header */
.mobile-header {
    height: var(--header-height);
    background-color: var(--secondary-color);
    backdrop-filter: blur(10px);
    border-bottom: var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    flex-shrink: 0;
}

#sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0.5rem;
}

#sidebar-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-color);
    border-radius: 2px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--secondary-color);
    border-right: var(--glass-border);
    z-index: 100;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: var(--glass-border);
}

#sidebar-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.sidebar-nav ul {
    list-style: none !important;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: 0.5rem;
    list-style: none !important;
}

.sidebar-nav li::marker {
    content: none !important;
    display: none;
}

.sidebar-nav .nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin: 1.5rem 0 0.5rem 0;
    font-weight: 700;
}

.sidebar-nav a,
.sidebar-nav .nav-logout {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
}

.sidebar-nav a:hover,
.sidebar-nav .nav-logout:hover,
.sidebar-nav a.active {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
}

.user-name {
    display: block;
    padding: 0.75rem 1rem;
    color: #94a3b8;
    font-size: 0.9rem;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem 1rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.auth-full-page {
    margin-left: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
}

/* Logo */
.logo a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Forms */
.auth-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 1rem;
    border: var(--glass-border);
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: var(--text-color);
    font-size: 1rem;
    margin-bottom: 0;
    transition: all 0.2s;
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background-color: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

button,
.button {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.2s, opacity 0.3s;
    display: inline-block;
}

button:hover,
.button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Cards */
.card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.alert.success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.alert.error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

/* Desktop Styles */
@media (min-width: 768px) {
    .mobile-header {
        display: none;
    }

    .sidebar {
        left: 0;
        position: fixed;
        border-right: var(--glass-border);
    }

    #sidebar-close {
        display: none;
    }

    .main-content {
        margin-left: var(--sidebar-width);
        padding: 3rem 2rem;
    }

    .overlay {
        display: none;
    }
}

/* Pagination Styles */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin: 2rem 0;
}

.pagination li {
    display: inline-block;
}

.pagination a,
.pagination span {
    display: block;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.pagination a:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination .active span {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination .disabled span {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Video Grid */
.videos-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 640px) {
    .videos-grid {
        grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    }
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

th {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

[data-theme="light"] th,
[data-theme="light"] td {
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] th {
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

/* Footer Styles */
.site-footer {
    background-color: var(--secondary-color);
    border-top: var(--glass-border);
    padding: 3rem 1.5rem 1.5rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

.footer-description {
    color: #94a3b8;
    font-size: 0.9rem;
    line-height: 1.6;
}

.footer-links {
    list-style: none !important;
    list-style-type: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.footer-links li {
    list-style: none !important;
    list-style-type: none !important;
    margin: 0;
    padding: 0;
}

.footer-links li::marker {
    content: none !important;
    display: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
    display: inline-block;
    padding: 0.25rem 0;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

[data-theme="light"] .footer-bottom {
    border-top-color: rgba(0, 0, 0, 0.1);
}

.footer-bottom p {
    color: #64748b;
    font-size: 0.85rem;
    margin: 0;
}

/* Mobile Optimizations */
@media (max-width: 767px) {
    .sidebar {
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.3s ease, visibility 0.3s ease;
        transform: translateX(-100%);
        left: 0;
    }

    .sidebar.open {
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0);
    }

    /* Improve touch targets - minimum 44x44px */
    .sidebar-nav a,
    .sidebar-nav .nav-logout {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Better footer on mobile */
    .site-footer {
        padding: 3rem 1rem 2rem;
        text-align: center;
    }

    .footer-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2.5rem;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        padding: 0;
        grid-template-columns: none;
        /* Explicitly clear grid */
    }

    .footer-section {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        margin: 0;
    }

    .footer-logo {
        justify-content: center;
        margin-bottom: 1rem;
        width: 100%;
    }

    .footer-description {
        max-width: 320px;
        margin: 0 auto;
        text-wrap: balance;
    }

    .footer-links {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        gap: 0.5rem;
    }

    .footer-links li {
        width: 100%;
        text-align: center;
    }

    .footer-links a {
        padding: 0.75rem 0;
        width: 100%;
        display: block;
        text-align: center;
    }
}

/* Improve focus states for accessibility */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Desktop Footer adjustment */
@media (min-width: 768px) {
    .site-footer {
        margin-left: var(--sidebar-width);
    }
}