/* --- Modern SaaS Design System v1.1 --- */

/* 
    IMPORTANT: 
    The following CSS variables are expected to be defined dynamically 
    in a <style> tag in your main PHP layout file (e.g., header.php or index.php)
    based on the admin's settings:
    --primary: (e.g., #ff0000 - the main brand color)
    --primary-dark: (e.g., #cc0000 - a darker shade for hover states)
    --primary-text: (e.g., #ffffff - text color for primary buttons, typically white)
*/

:root {
    /* Default Fallback Colors (Bootstrap's default primary) */
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --primary-text: #ffffff; 

    --secondary: #a1a1aa;
    --light: #2a2a2a;
    --dark: #ffffff;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #ef4444;
    --info: #38bdf8;

    --background: #050505; 
    
    /* Sidebar Specific Colors */
    --sidebar-bg: rgba(20, 20, 20, 0.8);
    --sidebar-text: #a1a1aa; 
    --sidebar-icon-bg: rgba(255,255,255,0.05); 
    --sidebar-icon-color: var(--primary);
    --sidebar-active-bg: rgba(255,255,255,0.1); 
    --sidebar-active-text: #ffffff;
    --sidebar-active-icon-color: #ffffff;

    /* General Component Styling */
    --card-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5); 
    --bs-border-radius: .75rem;
    --bs-border-radius-lg: 1.5rem;
}

body {
    background-color: var(--background);
    color: var(--dark);
    font-family: 'Inter', "Helvetica Neue", Arial, sans-serif; 
}

/* --- Login & Installer Page --- */
.auth-page {
    background-color: var(--background);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.auth-box {
    background: rgba(25, 25, 25, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2.5rem;
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--card-shadow); 
    width: 100%;
    max-width: 450px;
    color: #fff;
}
.auth-box h2, .auth-box h3, .auth-box label { color: #fff; }

/* --- Main App Layout (Sidebar & Content) --- */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
}

#sidebar {
    min-width: 260px;
    max-width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    color: var(--sidebar-text);
    transition: margin-left 0.3s ease-in-out;
    min-height: 100vh;
    box-shadow: var(--card-shadow);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.05);
}

#sidebar.active {
    margin-left: -260px;
}

#sidebar .sidebar-header {
    padding: 24px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#sidebar .sidebar-header h3 {
    font-size: 1.4rem; /* Slightly smaller for better fit */
    font-weight: 600;
    color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
}
#sidebar .sidebar-header h3 img {
    max-height: 30px; /* Adjust logo size in sidebar */
    margin-right: 10px;
}


#sidebar ul.components {
    padding: 1rem;
    flex-grow: 1; /* Allows menu to fill space */
}

#sidebar ul li a {
    padding: 0.75rem 1rem; /* Slightly adjusted padding */
    font-size: 0.9rem;    /* Slightly adjusted font size */
    font-weight: 500;
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    border-radius: var(--bs-border-radius);
    margin-bottom: 0.25rem;
}

#sidebar ul li a i {
    color: var(--sidebar-icon-color);
    margin-right: 1rem;
    font-size: 1.1rem; /* Slightly adjusted icon size */
    width: 30px;       /* Adjusted icon wrapper size */
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--sidebar-icon-bg);
    border-radius: var(--bs-border-radius);
    transition: all 0.2s;
}

#sidebar ul li a:hover {
    background: rgba(255,255,255,0.05); 
    color: #fff; 
}
#sidebar ul li a:hover i {
    background: var(--primary);
    color: var(--primary-text); /* Typically white */
}


#sidebar ul li.active > a, 
#sidebar ul li a[aria-expanded="true"] { /* For dropdowns if any */
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    box-shadow: 0 4px 12px -2px rgba(0,0,0,0.15), 0 3px 8px -3px rgba(0,0,0,0.1);
}

#sidebar ul li.active > a i {
    background: transparent;
    color: var(--sidebar-active-icon-color);
}

#sidebar .CTAs { 
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}


#content {
    width: 100%;
    padding: 24px;
    min-height: 100vh;
    transition: all 0.3s;
}

/* --- Component Styles --- */
.card {
    background: rgba(25, 25, 25, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--bs-border-radius-lg); 
    box-shadow: var(--card-shadow);
    color: #fff;
    margin-bottom: 1.5rem; 
}
.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08); 
    padding: 1.25rem 1.5rem;
    font-size: 1.05rem; 
    font-weight: 600;
}
.table { color: #fff; }
.table-hover tbody tr:hover { color: #fff; background-color: rgba(255,255,255,0.05); }
.text-muted { color: #a1a1aa !important; }
.text-dark { color: #fff !important; }
.bg-white { background: rgba(25, 25, 25, 0.8) !important; backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.08); }

.stat-card { /* Used in dashboards */
    border-radius: var(--bs-border-radius-lg);
    color: white;
    padding: 24px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}
.stat-card:hover {
    transform: translateY(-5px);
}
.stat-card .stat-icon {
    font-size: 4rem; /* Slightly smaller */
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.15; /* Less intrusive */
    transition: all 0.3s;
}
.stat-card:hover .stat-icon {
    opacity: 0.25;
    transform: translateY(-50%) scale(1.05);
}
.stat-card .stat-number {
    font-size: 2.25rem;
    font-weight: 700;
}
.stat-card .stat-text {
    font-size: 1rem;
    font-weight: 500;
}

.btn {
    font-weight: 500; /* Slightly less bold */
    padding: 0.6rem 1.2rem;
    border-radius: var(--bs-border-radius);
    transition: all 0.2s ease-in-out;
}

.btn-primary { /* This will now use the :root --bs-primary if defined */
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: var(--primary-text);
}

/* Custom Primary Button for specific overrides if needed */
.btn-custom-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--primary-text) !important;
}
.btn-custom-primary:hover,
.btn-custom-primary:focus,
.btn-custom-primary:active {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    color: var(--primary-text) !important;
}


.form-control, .form-select {
    padding: 0.6rem 1rem;
    border-radius: var(--bs-border-radius);
    background-color: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
}
.form-control:focus, .form-select:focus {
    background-color: rgba(255,255,255,0.1);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25); 
}
.form-label { color: #fff; }

/* --- Playlist Editor (Dark Mode) --- */
.media-library, .playlist-timeline {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: .75rem;
    padding: 1rem;
    min-height: 400px;
    max-height: 70vh;
    overflow-y: auto;
    background: rgba(15,15,15,0.6);
    backdrop-filter: blur(10px);
}
.media-item, .timeline-item {
    display: flex;
    align-items: center;
    background: rgba(35,35,35,0.8);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: .75rem;
    padding: .6rem;
    margin-bottom: .5rem;
    cursor: grab;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    position: relative;
    color: #fff;
}
.media-item:hover, .timeline-item:hover {
    background: rgba(55,55,55,0.9);
    border-color: var(--primary);
    transform: translateX(3px);
}
.media-thumbnail-wrapper {
    width: 80px; height: 60px; min-width: 80px;
    margin-right: 12px;
    background: rgba(0,0,0,0.4);
    border-radius: .5rem;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.media-thumbnail { width: 100%; height: 100%; object-fit: cover; }
.media-name {
    flex-grow: 1; font-weight: 500; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; color: #e4e4e7;
}
.duration-display, .duration-input { width: 80px; }
.drop-placeholder {
    height: 70px;
    background: rgba(var(--bs-primary-rgb), 0.1);
    border: 2px dashed var(--primary);
    margin-bottom: .5rem;
    border-radius: .75rem;
    transition: background 0.2s;
}
.dragging { opacity: 0.4; transform: scale(0.98); }
.hover-preview {
    display: none; position: absolute; top: 50%; left: 105%;
    transform: translateY(-50%);
    width: 280px; height: 160px;
    background: #000; border: 1px solid rgba(255,255,255,0.15);
    border-radius: .75rem; box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    z-index: 1050; pointer-events: none; overflow: hidden;
}
.media-item:hover .hover-preview { display: block; }
.hover-preview video, .hover-preview img { width:100%; height:100%; object-fit:contain; }
.timeline-item .delete-timeline-item {
    position: absolute; top: 6px; right: 6px;
    background: rgba(239,68,68,0.0); color: #ef4444;
    border-radius: 50%; width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; border: 1px solid rgba(239,68,68,0);
    cursor: pointer; z-index: 10; opacity: 0;
    transition: opacity 0.2s, background 0.2s, border-color 0.2s;
}
.timeline-item:hover .delete-timeline-item {
    opacity: 1; background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4);
}

/* --- Analytics Page --- */
.analytics-chart-card {
    background: rgba(20,20,20,0.7);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 1.25rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.top-media-item {
    display: flex; align-items: center; gap: 1rem;
    padding: .75rem 1rem;
    background: rgba(30,30,30,0.6);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: .75rem;
    margin-bottom: .5rem;
    transition: background 0.2s;
}
.top-media-item:hover { background: rgba(50,50,50,0.8); }
.top-media-rank {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: var(--primary-text);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.play-count-bar {
    height: 6px; border-radius: 3px;
    background: linear-gradient(90deg, var(--primary), rgba(var(--bs-primary-rgb),0.3));
    margin-top: 4px; transition: width 0.6s ease;
}

/* --- Toast Notifications --- */
.toast-container-custom {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    z-index: 9999; display: flex; flex-direction: column; gap: .5rem;
}
.toast-custom {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1.25rem; border-radius: .85rem;
    background: rgba(25,25,25,0.95); backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    color: #fff; font-size: .9rem; font-weight: 500;
    min-width: 280px; max-width: 380px;
    animation: toast-in 0.3s cubic-bezier(0.16,1,0.3,1);
    cursor: pointer;
}
.toast-custom.toast-success { border-left: 3px solid var(--success); }
.toast-custom.toast-danger  { border-left: 3px solid var(--danger); }
.toast-custom.toast-info    { border-left: 3px solid var(--info); }
.toast-custom.toast-warning { border-left: 3px solid var(--warning); }
.toast-custom i { font-size: 1.2rem; }
.toast-custom.toast-success i { color: var(--success); }
.toast-custom.toast-danger i  { color: var(--danger); }
.toast-custom.toast-info i    { color: var(--info); }
.toast-custom.toast-warning i { color: var(--warning); }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(30px) scale(0.95); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
.toast-custom.toast-out {
    animation: toast-out 0.25s ease forwards;
}
@keyframes toast-out {
    to { opacity: 0; transform: translateX(30px) scale(0.95); }
}

/* --- Online Status Badge --- */
.status-dot {
    width: 10px; height: 10px; border-radius: 50%;
    display: inline-block; margin-right: 6px; flex-shrink: 0;
}
.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: #71717a; }
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 4px var(--success); }
    50% { box-shadow: 0 0 10px var(--success); }
}

/* --- Widget Settings Card --- */
.widget-toggle {
    display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem;
    background: rgba(30,30,30,0.5);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: .75rem; margin-bottom: .5rem;
}

/* --- List Group Dark --- */
.list-group-item {
    background: rgba(25,25,25,0.5);
    border-color: rgba(255,255,255,0.07);
    color: #e4e4e7;
}
.list-group-item + .list-group-item { border-top-color: rgba(255,255,255,0.07); }

/* --- Navbar Dark --- */
nav.navbar { background: rgba(20,20,20,0.7) !important; backdrop-filter: blur(20px); border-bottom: 1px solid rgba(255,255,255,0.07); }
.navbar .text-dark { color: #e4e4e7 !important; }
.dropdown-menu { background: rgba(25,25,25,0.95); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); }
.dropdown-item { color: #e4e4e7; }
.dropdown-item:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* --- Form Controls Dark --- */
.form-check-input { background-color: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.2); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-switch .form-check-input { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(255,255,255,0.5)'/%3e%3c/svg%3e"); }
.form-switch .form-check-input:checked { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='white'/%3e%3c/svg%3e"); }
.input-group-text { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: #a1a1aa; }
.alert { border-radius: .85rem; border: 1px solid rgba(255,255,255,0.1); background: rgba(30,30,30,0.8); color: #fff; }
.alert-success { border-left: 3px solid var(--success); }
.alert-danger  { border-left: 3px solid var(--danger); }
.alert-warning { border-left: 3px solid var(--warning); }
.alert-info    { border-left: 3px solid var(--info); }
.modal-content { background: rgba(20,20,20,0.95); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); color: #fff; }
.modal-header { border-bottom-color: rgba(255,255,255,0.08); }
.modal-footer { border-top-color: rgba(255,255,255,0.08); }
.btn-close { filter: invert(1); }

/* --- Responsive Design --- */
@media (max-width: 768px) {
    #sidebar { margin-left: -260px; position: fixed; height: 100%; z-index: 1050; }
    #sidebar.active { margin-left: 0; }
    #sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1040; backdrop-filter: blur(4px); }
    #sidebar.active ~ #sidebar-overlay, body.sidebar-open #sidebar-overlay { display: block; }
    #content { padding: 15px; }
    #sidebarCollapse { display: inline-block; }
    .hover-preview { display: none !important; }
}
@media (min-width: 769px) {
    #sidebarCollapse { display: none; }
}