:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg: #0f172a;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-white: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

:root.light {
    --bg: #f8fafc;
    --bg-dark: #f1f5f9;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-white: #0f172a;
    --text-muted: #475569;
    --glass: rgba(0, 0, 0, 0.03);
    --glass-border: rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
}

/* Glassmorphism Classes */
.glass {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

/* Header */
header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav a {
    color: var(--text-white);
    text-decoration: none;
    margin-left: 2rem;
    font-weight: 500;
    transition: color 0.3s;
}

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

/* Hero Section */
.hero {
    padding: 8rem 2rem;
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    line-height: 1.1;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.25rem;
    margin-bottom: 2rem;
}

/* Grid Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.masonry-grid {
    column-count: 4;
    column-gap: 1.5rem;
    width: 100%;
}

.masonry-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 1.5rem;
    break-inside: avoid;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease-out;
}

.masonry-item.loaded {
    opacity: 1;
    transform: translateY(0);
}

#prevMedia,
#nextMedia {
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
}

#prevMedia:hover,
#nextMedia:hover {
    background: var(--primary-color);
    transform: scale(1.1) translateY(-50%) !important;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--glass);
    border-bottom-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@media (max-width: 1200px) {
    .masonry-grid {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .masonry-grid {
        column-count: 2;
    }
}

@media (max-width: 480px) {
    .masonry-grid {
        column-count: 1;
    }
}

.card {
    overflow: hidden;
    transition: transform 0.3s, border-color 0.3s;
}

.card:hover {
    transform: translateY(-8px);
    border-color: var(--primary-color);
}

.card-media {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: cover;
    display: block;
    transition: filter 0.3s;
}

.card-info {
    padding: 1.5rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

/* Admin Panel */
.admin-header {
    font-size: 2rem;
    margin-bottom: 2rem;
}

.admin-form {
    max-width: 500px;
    margin-bottom: 3rem;
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        height: auto;
    }

    nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.8rem;
    }

    nav a {
        margin: 0;
        font-size: 0.9rem;
    }

    .hero {
        padding: 4rem 1rem;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .container {
        padding: 1rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    /* Study Page Mobile */
    .study-grid {
        grid-template-columns: 1fr !important;
    }

    .video-container {
        position: static !important;
    }

    .transcript-container {
        height: 400px !important;
    }

    /* Admin Dashboard Mobile */
    .admin-form {
        max-width: 100%;
        padding: 1rem;
    }

    .gallery-grid[style*="grid-template-columns: 1fr 1fr 1fr"],
    .gallery-grid[style*="grid-template-columns: repeat(4, 1fr)"],
    .gallery-grid[style*="grid-template-columns: 1fr 2fr"],
    .gallery-grid[style*="grid-template-columns: 1fr 1.5fr"] {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.2rem;
    }

    .hero h1 {
        font-size: 1.8rem;
    }

    #homePlayerContainer {
        padding: 0.8rem !important;
        width: 100% !important;
    }

    #homePlayerContainer #player {
        border-radius: 0.5rem !important;
    }

    #subtitles {
        font-size: 1.1rem !important;
        padding: 0.6rem 1.2rem !important;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#slideshowContent img,
#slideshowContent video {
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

/* CMS Explorer Styles */
#cmsBreadcrumbs span {
    transition: color 0.2s;
}

#cmsBreadcrumbs span:hover {
    color: var(--primary-color) !important;
}

#cmsPageList .glass {
    transition: all 0.2s ease;
}

#cmsPageList .glass:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

/* Security Stats Cards */
.security-stats-grid .glass {
    transition: transform 0.3s;
}

.security-stats-grid .glass:hover {
    transform: translateY(-4px);
}

.draggable-section {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.draggable-section.moving {
    opacity: 0.5;
    transform: scale(0.98);
}