/* ==========================================================================
   CSS Variables & Theming
   ========================================================================== */
:root {
    /* Colors */
    --primary: #233F8D;
    --dark-blue: #162A63;
    --accent: #D4AF37;
    --bg-main: #F5F7FB;
    --bg-card: #FFFFFF;
    --text-main: #1A1A1A;
    --text-muted: #666666;
    --border-color: #E2E8F0;
    --hover-bg: #F8FAFC;
    
    /* Layout */
    --max-width: 1400px;
    --header-height: 72px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.025);
    
    /* Transitions */
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --primary: #3B5BBD;
    --dark-blue: #1C2D5C;
    --accent: #E8C14B;
    --bg-main: #0F172A;
    --bg-card: #1E293B;
    --text-main: #F1F5F9;
    --text-muted: #94A3B8;
    --border-color: #334155;
    --hover-bg: #283548;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--primary);
    text-decoration: none;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-main);
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ==========================================================================
   Components
   ========================================================================== */
/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: var(--dark-blue);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--hover-bg);
    border-color: var(--text-muted);
}

.btn-media {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background-color: var(--hover-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-media.active {
    background-color: rgba(35, 63, 141, 0.1);
    color: var(--primary);
    border-color: rgba(35, 63, 141, 0.3);
}

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

.btn-media.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: transparent;
    border: none;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-muted);
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: var(--hover-bg);
    color: var(--text-main);
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--bg-card);
    box-shadow: var(--shadow-sm);
    height: var(--header-height);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    height: 48px;         /* Sets a fixed height to fit the header */
    width: auto;          /* Allows the width to scale naturally */
    object-fit: contain;  /* Ensures the entire logo is perfectly visible without being stretched or cut off */
    display: block;
}

.titles h1 {
    font-size: 1.1rem;
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.search-wrapper input {
    width: 280px;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(35, 63, 141, 0.1);
    width: 320px;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--dark-blue), var(--primary));
    background-size: 200% 200%;
    animation: gradientShift 10s ease infinite;
    color: white;
    padding: 5rem 2rem;
    text-align: center;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    margin-bottom: 3rem;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: white;
}

.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    font-weight: 300;
}

/* Dashboard Stats */
.dashboard-stats {
    max-width: var(--max-width);
    margin: 0 auto 3rem;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 28px;
    height: 28px;
}

.stat-details h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}

/* Data Table */
.data-section {
    max-width: var(--max-width);
    margin: 0 auto 3rem;
    padding: 0 2rem;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.table-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    position: relative;
    min-height: 400px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

th, td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-card);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 var(--border-color);
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

th.sortable:hover {
    color: var(--primary);
}

.sort-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 4px;
    position: relative;
    opacity: 0.3;
}

.sort-icon::before, .sort-icon::after {
    content: '';
    position: absolute;
    left: 4px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

.sort-icon::before {
    top: 0;
    border-bottom: 4px solid currentColor;
}

.sort-icon::after {
    bottom: 0;
    border-top: 4px solid currentColor;
}

th.asc .sort-icon { opacity: 1; }
th.asc .sort-icon::after { display: none; }
th.desc .sort-icon { opacity: 1; }
th.desc .sort-icon::before { display: none; }

tbody tr {
    transition: background-color 0.2s;
    cursor: pointer;
}

tbody tr:nth-child(even) {
    background-color: var(--bg-main);
}

tbody tr:hover {
    background-color: var(--hover-bg);
}

tbody td {
    font-size: 0.9rem;
    color: var(--text-main);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

td:first-child {
    font-weight: 500;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    width: 100%;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-main);
}

.empty-sub {
    font-size: 0.9rem;
}

/* Pagination */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding: 0 0.5rem;
}

#page-info {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    gap: 0.25rem;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-main);
    font-size: 0.9rem;
    transition: var(--transition);
}

.page-btn:not(:disabled):hover {
    background-color: var(--hover-bg);
    border-color: var(--text-muted);
}

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

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-main);
}

/* Modal */
.modal {
    border: none;
    background: transparent;
    padding: 0;
    margin: auto;
    width: 100%;
    max-width: 600px;
}

.modal::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    color: var(--text-main);
    transform: scale(0.95);
    opacity: 0;
    animation: zoomIn 0.3s ease forwards;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-field {
    display: flex;
    flex-direction: column;
}

.modal-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.modal-value {
    font-size: 0.95rem;
    word-break: break-word;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Loader & Error */
.loader-overlay {
    position: fixed;
    inset: 0;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

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

.error-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 400px;
}

.error-icon {
    width: 64px;
    height: 64px;
    color: #e74c3c;
    margin-bottom: 1rem;
}

/* Scroll to top */
.scroll-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    z-index: 90;
    transition: var(--transition);
    opacity: 0;
    pointer-events: none;
}

.scroll-top:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.scroll-top:hover {
    background-color: var(--dark-blue);
    transform: translateY(-3px);
}

.scroll-top svg {
    width: 24px;
    height: 24px;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    margin-top: 2rem;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; visibility: visible; }
    to { opacity: 0; visibility: hidden; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 1024px) {
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .header-content { flex-direction: column; gap: 1rem; padding: 1rem; }
    .app-header { height: auto; }
    .search-wrapper input { width: 100%; }
    .search-wrapper input:focus { width: 100%; }
    .hero { padding: 3rem 1rem; border-radius: 0; }
    .dashboard-stats { grid-template-columns: 1fr; padding: 0 1rem; }
    .data-section { padding: 0 1rem; }
    .table-toolbar { flex-direction: column; gap: 1rem; align-items: flex-start; }
    .pagination-wrapper { flex-direction: column; gap: 1rem; }
}

/* ==========================================================================
   Video Player Modal
   ========================================================================== */
.video-modal {
    max-width: 900px; /* Wider for video */
}

.video-content {
    background-color: var(--bg-card);
}

.video-body {
    padding: 0; /* Remove padding for edge-to-edge video */
}

/* 16:9 Aspect Ratio Container */
.iframe-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    height: 0;
    overflow: hidden;
    background-color: #000;
}

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