:root {
    /* Sves Dark Theme Palette - "Premium Glass" */

    /* Core Backgrounds */
    --bg-dark: #0f172a;
    /* Main dark background */
    --bg-card: rgba(30, 41, 59, 0.65);
    /* Card background */
    --bg-sidebar: rgba(15, 23, 42, 0.95);
    /* Sidebar background */
    --bg-input: rgba(15, 23, 42, 0.6);
    /* Input background */

    /* Typography */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;

    /* Accents - Vibrant & Neon-ish */
    --accent-primary: #8b5cf6;
    /* Violet */
    --accent-secondary: #3b82f6;
    /* Blue */
    --accent-gradient: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
    --accent-glow: rgba(168, 85, 247, 0.4);

    --success-color: #10b981;
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);

    --danger-color: #ef4444;
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);

    --warning-color: #f59e0b;
    --warning-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);

    /* Glass Effect Tokens */
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.12);
    --backdrop-blur: blur(20px);

    /* Dimensions */
    --radius-sm: 0.5rem;
    --radius-md: 0.875rem;
    /* Slightly larger for modern feel */
    --radius-lg: 1.25rem;
    --radius-xl: 1.75rem;

    /* Shadows */
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);
}

/* Base Reset & Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    /* Richer Mesh Gradient */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(76, 29, 149, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(59, 130, 246, 0.15), transparent 25%);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(139, 92, 246, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    }
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    z-index: 1000;
    backdrop-filter: blur(20px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: white;
    letter-spacing: -0.02em;
}

.logo i {
    color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid var(--glass-border);
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: white;
    padding-left: 1.5rem;
    /* Subtle slide */
    border-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 8px 20px -4px var(--accent-glow);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--danger-color);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.7;
    transition: opacity 0.2s;
    font-weight: 500;
}

.logout-btn:hover {
    opacity: 1;
}

/* Main Content Layout */
.main-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding: 0;
    background: transparent;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 1.5rem 2.5rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.85);
    /* Slightly more opaque */
    backdrop-filter: blur(16px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.3s;
}

.page-title {
    margin: 0;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.page-subtitle {
    margin: 4px 0 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* User Badge in Header */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Content Container */
.view-container {
    padding: 2.5rem 3rem 5rem 3rem;
    /* Extra bottom padding */
    max-width: 1800px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

/* Premium Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: var(--backdrop-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    /* For inner glow effects */
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--glass-highlight);
    background: rgba(30, 41, 59, 0.75);
}

/* Subtle top shine on card */
.card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0.5;
}

/* Interactive Elements: Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    letter-spacing: 0.01em;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
    box-shadow: 0 8px 20px var(--accent-glow);
    filter: brightness(1.1);
}

.btn-success {
    background: var(--success-gradient);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: var(--danger-gradient);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Forms */
.form-control {
    width: 100%;
    padding: 0.85rem 1.1rem;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-secondary);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25), inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Custom Select Chevron */
select.form-control {
    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='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
    padding-right: 3rem;
}

select.form-control option {
    background-color: #1e293b;
    color: white;
    padding: 10px;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    text-align: left;
    padding: 1.2rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
}

.table td {
    padding: 1.2rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.2s;
}

.table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.table tr:last-child td {
    border-bottom: none;
}

/* Dashboard Grids */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform-origin: center;
    animation: scaleUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleUp {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Extra Utilities */
.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.font-bold {
    font-weight: 700;
}

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

/* Switch Toggle (iOS style) */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked+.slider {
    background-color: var(--success-color);
}

.switch input:checked+.slider:before {
    transform: translateX(20px);
}

/* Scrollbar specific */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Layout Editor */
.screen-layout-editor {
    width: 100%;
    height: 600px;
    /* Fixed height for canvas */
    background-color: rgba(15, 23, 42, 0.5);
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    margin-top: 1rem;
    /* Grid Pattern */
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

.screen-node {
    position: absolute;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    cursor: grab;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
    user-select: none;
    min-width: 100px;
    min-height: 60px;
}

.screen-node:active {
    cursor: grabbing;
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
    z-index: 100 !important;
}

.screen-node.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.screen-node .screen-header {
    width: 100%;
    padding: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.screen-node .screen-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
    margin-right: 5px;
}

.screen-node .screen-status-dot.online {
    background: var(--success-color);
    box-shadow: 0 0 5px var(--success-color);
}

.screen-node .screen-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 4px;
    text-align: center;
}

/* Resize Handle */
.resize-handle {
    width: 12px;
    height: 12px;
    background: var(--text-secondary);
    position: absolute;
    bottom: 0;
    right: 0;
    cursor: se-resize;
    border-top-left-radius: 4px;
    border-bottom-right-radius: 6px;
    /* Match container */
    opacity: 0.5;
    transition: opacity 0.2s;
}

.screen-node:hover .resize-handle {
    opacity: 1;
    background: var(--accent-secondary);
}

/* Drag & Drop Visual Improvements */
.playlist-item {
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}

.playlist-item.drop-target-active {
    border: 1px dashed #22c55e !important;
    background-color: rgba(34, 197, 94, 0.1) !important;
    transform: scale(1.02);
}

.playlist-item.dragging-item {
    border: 1px dashed #666 !important;
    background-color: #222 !important;
}

.playlist-drop-zone.drag-over-zone {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px dashed #555;
}