* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at 85% 0%, rgba(0, 217, 255, 0.10), transparent 28%),
        radial-gradient(circle at 0% 100%, rgba(90, 0, 255, 0.10), transparent 32%),
        linear-gradient(135deg, #06090e, #0a0f17 55%, #070b11);
    color: #fff;
}

button {
    border: 0;
    border-radius: 9px;
    padding: 10px 15px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
    font-size: 12px;
    letter-spacing: 0.25px;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.12);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

/* =========================
   HEADER
========================= */

.header {
    min-height: 82px;
    padding: 14px 22px;
    background: rgba(8, 13, 21, 0.96);
    border-bottom: 1px solid rgba(0, 220, 255, 0.10);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 45px;
    height: 45px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #00d9ff, #006eff);
    box-shadow:
        0 0 22px rgba(0, 217, 255, 0.22),
        inset 0 0 10px rgba(255, 255, 255, 0.12);
    font-size: 22px;
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.7px;
}

.brand-title span {
    color: #00d9ff;
}

.brand-subtitle {
    margin-top: 3px;
    color: #778499;
    font-size: 11px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.control-group:first-child {
    padding-left: 0;
    border-left: 0;
}

.control-group-title {
    color: #68768a;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-right: 2px;
}

.btn-start {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 0 14px rgba(22, 163, 74, 0.16);
}

.btn-stop {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 0 14px rgba(220, 38, 38, 0.14);
}

.btn-skip {
    background: linear-gradient(135deg, #00cfff, #006eff);
    box-shadow: 0 0 18px rgba(0, 207, 255, 0.18);
}

.btn-reload {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    box-shadow: 0 0 14px rgba(124, 58, 237, 0.16);
}

/* =========================
   LAYOUT
========================= */

.container {
    display: grid;
    grid-template-columns: minmax(360px, 43%) 1fr;
    gap: 16px;
    padding: 16px;
    min-height: calc(100vh - 82px);
}

.left,
.right {
    min-width: 0;
}

/* =========================
   CARDS
========================= */

.card {
    background: rgba(14, 20, 29, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.065);
    border-radius: 15px;
    box-shadow:
        0 12px 38px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.025);
    overflow: hidden;
}

.card-header {
    padding: 15px 17px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.055);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.card-title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.25px;
}

.card-subtitle {
    color: #68768a;
    font-size: 11px;
}

.card-body {
    padding: 15px;
}

/* =========================
   ENGINE STATUS
========================= */

.engine-status {
    margin-bottom: 14px;
    padding: 13px;
    border-radius: 11px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.engine-status-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.engine-status-name {
    color: #778499;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.engine-state {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
}

.state-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #64748b;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.state-dot.online {
    background: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.75);
}

.state-dot.stopped {
    background: #f59e0b;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.55);
}

.state-dot.offline {
    background: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.55);
}

.engine-current {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.045);
}

.engine-current-label {
    color: #68768a;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.engine-current-file {
    margin-top: 5px;
    color: #dce7f5;
    font-size: 12px;
    line-height: 1.45;
    word-break: break-word;
}

/* =========================
   SEARCH
========================= */

.media-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.media-search-box {
    position: relative;
    flex: 1;
}

.media-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 13px;
    pointer-events: none;
}

#mediaSearch {
    width: 100%;
    height: 38px;
    padding: 0 36px 0 33px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 9px;
    outline: none;
    background: rgba(0, 0, 0, 0.24);
    color: #dce7f5;
    font-size: 12px;
    transition: 0.18s ease;
}

#mediaSearch::placeholder {
    color: #64748b;
}

#mediaSearch:focus {
    border-color: rgba(0, 207, 255, 0.45);
    box-shadow: 0 0 0 2px rgba(0, 207, 255, 0.08);
}

.search-clear {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    width: 25px;
    height: 25px;
    padding: 0;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font-size: 15px;
    line-height: 25px;
}

.search-clear:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
    transform: translateY(-50%);
    filter: none;
}

.search-result-info {
    margin-bottom: 8px;
    color: #657287;
    font-size: 10px;
    line-height: 1.4;
}

/* =========================
   FILE LIST
========================= */

.file-list {
    max-height: 51vh;
    overflow-y: auto;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.file-item {
    position: relative;
    padding: 9px 11px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.035);
    cursor: pointer;
    color: #c8d0dc;
    font-size: 12px;
    transition: 0.15s;
    word-break: break-word;
    padding-right: 90px;
}

.file-item:last-child {
    border-bottom: 0;
}

.file-item:hover {
    background: rgba(0, 210, 255, 0.055);
    color: #fff;
}

.file-item.selected {
    background: rgba(0, 174, 255, 0.13);
    color: #fff;
    box-shadow: inset 3px 0 0 #00cfff;
}

/* =========================
   PLAYING FILE
========================= */

.file-item.playing {
    background: linear-gradient(
        90deg,
        rgba(0, 207, 255, 0.17),
        rgba(0, 110, 255, 0.08)
    );
    color: #ffffff;
    box-shadow:
        inset 4px 0 0 #00d9ff,
        0 0 18px rgba(0, 217, 255, 0.06);
}

.file-item.playing::after {
    content: "▶ PLAYING";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #00d9ff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.7px;
}

.file-item.playing.pending {
    animation: playPulse 1.1s ease-in-out infinite;
}

@keyframes playPulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.55;
    }
}

.no-results {
    padding: 20px 12px;
    color: #657287;
    text-align: center;
    font-size: 12px;
}

/* =========================
   SETTINGS
========================= */

.settings {
    margin-top: 14px;
    padding: 13px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.022);
    border: 1px solid rgba(255, 255, 255, 0.045);
}

.setting {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #b9c4d3;
    font-size: 12px;
}

.setting:last-child {
    margin-bottom: 0;
}

.setting input {
    accent-color: #00cfff;
}

/* =========================
   STATUS GRID
========================= */

.status-panel {
    margin-top: 14px;
    padding: 13px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.045);
}

.status-title {
    margin-bottom: 9px;
    color: #dce4ee;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.35px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.035);
    font-size: 11px;
}

.status-row:last-child {
    border-bottom: 0;
}

.status-label {
    color: #657287;
}

.status-value {
    color: #dbe5f0;
    text-align: right;
    max-width: 72%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-online {
    color: #22c55e !important;
    font-weight: 800;
}

.status-offline {
    color: #ef4444 !important;
    font-weight: 800;
}

.status-stopped {
    color: #f59e0b !important;
    font-weight: 800;
}

.status-command {
    color: #38bdf8;
    font-weight: 700;
}

.status-media {
    color: #c4b5fd;
}

.playlist-meta {
    margin-top: 9px;
    color: #657287;
    font-size: 11px;
}

/* =========================
   SAVE BUTTON
========================= */

.save-button {
    margin-top: 13px;
    width: 100%;
    background: linear-gradient(135deg, #0891b2, #2563eb);
    box-shadow: 0 0 18px rgba(8, 145, 178, 0.14);
}

/* =========================
   PREVIEW
========================= */

.preview {
    position: relative;
    background: #000;
    border-radius: 11px;
    overflow: hidden;
    box-shadow:
        0 0 35px rgba(0, 0, 0, 0.45),
        0 0 1px rgba(0, 217, 255, 0.3);
}

.preview-live {
    position: absolute;
    z-index: 2;
    top: 12px;
    left: 12px;
    padding: 5px 8px;
    border-radius: 6px;
    background: rgba(220, 38, 38, 0.88);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.8px;
    box-shadow: 0 0 14px rgba(220, 38, 38, 0.3);
}

video {
    display: block;
    width: 100%;
    min-height: 440px;
    background: #000;
}

/* =========================
   PREVIEW INFO
========================= */

.preview-info {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
}

.info-box {
    padding: 11px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.022);
    border: 1px solid rgba(255, 255, 255, 0.045);
}

.info-label {
    color: #697689;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.info-value {
    margin-top: 4px;
    color: #dce4ee;
    font-size: 13px;
    font-weight: 700;
}

/* =========================
   TOAST
========================= */

.control-message {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    padding: 11px 15px;
    border-radius: 9px;
    background: rgba(9, 15, 24, 0.96);
    border: 1px solid rgba(0, 210, 255, 0.25);
    color: #dbeafe;
    font-size: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: 0.2s;
}

.control-message.show {
    opacity: 1;
    transform: translateY(0);
}

/* =========================
   SCROLLBAR
========================= */

::-webkit-scrollbar {
    width: 7px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 207, 255, 0.22);
    border-radius: 10px;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1000px) {
    .container {
        grid-template-columns: 1fr;
    }

    video {
        min-height: 320px;
    }
}

@media (max-width: 700px) {
    .header {
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
    }

    .header-controls button {
        flex: 1;
    }
    
    .control-group {
        flex: 1 1 100%;
        width: 100%;
        padding-left: 0;
        border-left: 0;
    }
    
    .control-group-title {
        width: 100%;
    }

    .preview-info {
        grid-template-columns: 1fr;
    }
}