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

:root {
    --bg-base: #07090e;
    --bg-surface-1: #0d111a;
    --bg-surface-2: #141a26;
    --bg-surface-3: #1c2436;
    --bg-card: rgba(20, 26, 38, 0.7);
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-highlight: rgba(255, 255, 255, 0.14);
    --primary: #38bdf8;
    --primary-glow: rgba(56, 189, 248, 0.25);
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    --accent-purple: #818cf8;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
    --header-height: 72px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-soft: 0 10px 30px -10px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.2);
    --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* App Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface-1);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
    transition: width var(--transition-normal);
    position: relative;
    z-index: 40;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    overflow: hidden;
}

.brand-logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.brand-name {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #fff;
    white-space: nowrap;
}

.brand-name span {
    color: var(--primary);
}

.sidebar-collapse-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    padding: 12px 12px 6px;
    white-space: nowrap;
}

.sidebar.collapsed .nav-section-title {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition-fast);
    position: relative;
    user-select: none;
    white-space: nowrap;
}

.nav-item i {
    font-size: 20px;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.nav-item.active {
    background: rgba(56, 189, 248, 0.12);
    color: var(--primary);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

.nav-item.active i {
    color: var(--primary);
}

.nav-badge {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.nav-item.active .nav-badge {
    background: var(--primary);
    color: #07090e;
    font-weight: 700;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-badge {
    display: none;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.status-dot-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* Main Area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
    background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.04), transparent 40%),
                radial-gradient(circle at bottom left, rgba(129, 140, 248, 0.03), transparent 50%);
}

/* Header */
.top-header {
    height: var(--header-height);
    background: rgba(13, 17, 26, 0.7);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    flex-shrink: 0;
    z-index: 30;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-heading {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #fff;
}

.header-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    width: 320px;
    transition: var(--transition-fast);
}

.header-search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.header-search-bar input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 13.5px;
    width: 100%;
}

.header-search-bar input::placeholder {
    color: var(--text-dim);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #07090e;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

.btn-secondary {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: var(--bg-surface-3);
    border-color: var(--border-highlight);
}

.btn-danger {
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: var(--accent-rose);
}

.btn-danger:hover {
    background: var(--accent-rose);
    color: #fff;
}

.content-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px 40px;
}

/* Tab Panels */
.tab-panel {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

.tab-panel.active {
    display: block;
}

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

/* Stat Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-highlight);
    box-shadow: var(--shadow-soft);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-icon.cyan { background: rgba(56, 189, 248, 0.15); color: var(--primary); }
.stat-icon.purple { background: rgba(129, 140, 248, 0.15); color: var(--accent-purple); }
.stat-icon.emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
    margin-bottom: 6px;
}

.stat-subtext {
    font-size: 12px;
    color: var(--text-dim);
}

/* Glass Data Containers */
.data-card {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 22px;
    margin-bottom: 24px;
}

.card-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}

.card-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.search-input-inline {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 7px 12px;
    color: #fff;
    font-size: 13px;
    outline: none;
    width: 220px;
    transition: var(--transition-fast);
}

.search-input-inline:focus {
    border-color: var(--primary);
}

.select-inline {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 7px 12px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

/* Modern Data Table */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13.5px;
}

.data-table th {
    background: var(--bg-surface-2);
    color: var(--text-muted);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.poster-thumb {
    width: 44px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--bg-surface-3);
    border: 1px solid var(--border-subtle);
}

.item-meta-title {
    font-weight: 700;
    color: #fff;
    font-size: 14px;
}

.item-meta-sub {
    font-size: 12px;
    color: var(--text-dim);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-vip {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.08));
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

.badge-free {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-muted);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-emerald);
}

.badge-info {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: var(--primary);
}

.action-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface-2);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition-fast);
}

.action-icon-btn:hover {
    background: var(--bg-surface-3);
    color: var(--text-main);
    border-color: var(--border-highlight);
}

.action-icon-btn.delete:hover {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
    border-color: var(--accent-rose);
}

/* Modal Dialogs */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
    animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-box {
    background: var(--bg-surface-1);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 860px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

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

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, 0.02);
}

/* Forms and Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-grid.single {
    grid-template-columns: 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 9px 14px;
    color: #fff;
    font-size: 13.5px;
    outline: none;
    transition: var(--transition-fast);
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* TMDb Search Box */
.tmdb-search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: rgba(56, 189, 248, 0.05);
    padding: 14px;
    border-radius: var(--radius-lg);
    border: 1px dashed rgba(56, 189, 248, 0.3);
}

.tmdb-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    max-height: 280px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: var(--shadow-soft);
    margin-top: 4px;
    display: none;
}

.tmdb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: var(--transition-fast);
}

.tmdb-item:hover {
    background: rgba(56, 189, 248, 0.1);
}

/* Toast Notifications */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-surface-2);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-soft);
    animation: toastSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }
.toast.info { border-left: 4px solid var(--primary); }

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