@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #5d2cd8;
    --primary-hover: #481db8;
    --primary-light: #ece6ff;
    --secondary: #6366f1;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 20px -2px rgba(93, 44, 216, 0.06), 0 2px 10px -1px rgba(93, 44, 216, 0.03);
    --shadow-lg: 0 20px 40px -5px rgba(93, 44, 216, 0.1), 0 10px 20px -5px rgba(93, 44, 216, 0.05);
    
    /* Subject colors */
    --maths-color: #6366f1;
    --maths-bg: #e0e7ff;
    --physics-color: #0ea5e9;
    --physics-bg: #e0f2fe;
    --chemistry-color: #f97316;
    --chemistry-bg: #ffedd5;
    --biology-color: #10b981;
    --biology-bg: #d1fae5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, h3, h4, .brand-title {
    font-family: 'Outfit', sans-serif;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Offline/Fallback Banner */
.status-banner {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-bottom: 1px solid #fcd34d;
    color: #92400e;
    padding: 10px 20px;
    font-size: 0.875rem;
    text-align: center;
    font-weight: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 100;
}

.status-banner svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Header Area */
header {
    background: linear-gradient(135deg, #6225e6 0%, #3e12ab 100%);
    color: white;
    padding: 60px 20px 100px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 140%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
    transform: rotate(-15deg);
    pointer-events: none;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.logo-icon {
    margin-bottom: 15px;
    display: inline-flex;
    background: rgba(255, 255, 255, 0.15);
    padding: 12px;
    border-radius: 50%;
    backdrop-filter: blur(10px);
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.2);
}

.logo-icon svg {
    width: 32px;
    height: 32px;
    fill: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

header p {
    font-size: 1.125rem;
    opacity: 0.9;
    font-weight: 300;
    max-width: 600px;
    margin: 0 auto;
}

/* Dashboard Wrapper */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 80px 20px;
    position: relative;
}

/* Filters Card */
.filters-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    margin-top: -50px;
    margin-bottom: 40px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
    z-index: 10;
    transition: all 0.3s ease;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-select {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-main);
    background-color: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 14px;
    transition: all 0.2s ease;
}

.filter-select:hover {
    border-color: #cbd5e1;
    background-color: #f1f5f9;
}

.filter-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(93, 44, 216, 0.15);
    background-color: #ffffff;
}

.btn-show {
    background-color: var(--primary);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    padding: 14px 28px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(93, 44, 216, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    height: 48px;
}

.btn-show:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(93, 44, 216, 0.4);
}

.btn-show:active {
    transform: translateY(0);
}

/* Statistics Bar */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 0 5px;
}

.stats-count {
    font-size: 1rem;
    color: var(--text-muted);
}

.stats-count span {
    font-weight: 700;
    color: var(--primary);
}

.search-wrapper {
    position: relative;
    max-width: 300px;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    outline: none;
    background-color: white;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(93, 44, 216, 0.1);
}

.search-wrapper svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

/* Video Grid Area */
.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

/* Video Card */
.video-card {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(226, 232, 240, 0.6);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: relative;
}

.video-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(93, 44, 216, 0.2);
}

.video-thumbnail-container {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background-color: #0f172a;
    overflow: hidden;
}

.video-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.video-card:hover .video-thumbnail {
    transform: scale(1.08);
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    opacity: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.video-card:hover .video-overlay {
    opacity: 1;
}

.play-btn-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.play-btn-circle svg {
    width: 22px;
    height: 22px;
    fill: white;
    margin-left: 2px; /* Center the play icon visually */
}

.video-card:hover .play-btn-circle {
    transform: scale(1);
}

.duration-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(15, 23, 42, 0.75);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.video-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 12px;
}

.badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 30px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-grade {
    background-color: var(--primary-light);
    color: var(--primary);
}

.badge-subject {
    /* Set dynamically in JS/PHP */
}

.badge-math {
    background-color: var(--maths-bg);
    color: var(--maths-color);
}

.badge-physics {
    background-color: var(--physics-bg);
    color: var(--physics-color);
}

.badge-chemistry {
    background-color: var(--chemistry-bg);
    color: var(--chemistry-color);
}

.badge-biology {
    background-color: var(--biology-bg);
    color: var(--biology-color);
}

.video-chapter {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.video-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.4;
    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 2px dashed var(--border);
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: #cbd5e1;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--text-main);
    font-weight: 600;
}

/* Loader Animation */
.loader-container {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 80px 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    width: 100%;
    max-width: 900px;
    background: #0f172a;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px;
    background-color: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: white;
}

.modal-meta-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 80%;
}

.modal-breadcrumbs {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-light);
    opacity: 0.8;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.modal-close-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.video-player-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: black;
}

.video-player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Footer Section */
footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
    background-color: white;
    margin-top: 60px;
}

footer span {
    font-weight: 600;
    color: var(--primary);
}

/* Responsive Overrides */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.85rem;
    }
    
    header {
        padding: 40px 20px 80px 20px;
    }
    
    .filters-card {
        margin-top: -35px;
        padding: 18px;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stats-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .search-wrapper {
        max-width: 100%;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-title {
        font-size: 1rem;
    }
}
