/* LED24H Editor - Combined Styles */
/* ======================================== */
/* SECTION 1: CSS Variables & Base Styles   */
/* ======================================== */
:root {
    --bg: #0b1020;
    --panel: rgba(255,255,255,0.06);
    --border: rgba(255,255,255,0.14);
    --accent: #7c5cff;
    --accent2: #20c997;
    --text: rgba(255,255,255,0.92);
    --muted: rgba(255,255,255,0.65);
    --radius: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

.wrap { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* ======================================== */
/* SECTION 2: Header & Navigation         */
/* ======================================== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

h1 { font-size: 20px; margin: 0; }
.sub { color: var(--muted); font-size: 13px; }

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.03);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Disabled tab - khi không có quyền */
.tab-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.tab-btn.disabled:hover {
    color: var(--muted);
    background: none;
}

.tab-content {
    display: none;
}

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

/* ======================================== */
/* SECTION 3: Layout Grid & Cards           */
/* ======================================== */
.grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.card .hd {
    padding: 12px 14px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.05), transparent);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card .bd { padding: 14px; }

/* ======================================== */
/* SECTION 4: Buttons & Pills             */
/* ======================================== */
.btn {
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.btn:hover { background: rgba(255,255,255,0.12); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.good { background: var(--accent2); border-color: var(--accent2); color: #000; font-weight: 500; }
.btn.small { padding: 4px 12px; font-size: 11px; }

.pill {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 20px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
}

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ======================================== */
/* SECTION 5: Form Elements               */
/* ======================================== */
.field {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.label { font-size: 12px; color: var(--muted); }
.form-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 12px; }

.form-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
}

.form-input:focus { outline: none; border-color: var(--accent); }
select.form-input { cursor: pointer; }

select {
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text);
    font-size: 13px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 30px;
}

/* Prevent white flash when opening dropdown */
select,
select:focus,
select:active {
    background-color: rgba(0,0,0,0.3) !important;
    color: var(--text) !important;
}

/* Dropdown options - force dark background */
select option {
    background: #1a1a2e !important;
    color: var(--text) !important;
    padding: 8px;
}

select option:hover,
select option:focus,
select option:checked {
    background: var(--accent) !important;
    color: white !important;
}

/* Force dark theme for select elements to prevent white flash */
select {
    color-scheme: dark;
}

/* Firefox specific fix */
select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 var(--text);
}

/* Webkit browsers - prevent white background flash */
select::-webkit-select {
    background: rgba(0,0,0,0.3) !important;
}

/* IE/Edge fix */
select::-ms-expand {
    background: rgba(0,0,0,0.3);
    color: var(--text);
}

input[type="file"] { width: 100%; font-size: 13px; display: none; }
input[type="file"]::-webkit-file-upload-button {
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-right: 8px;
}

/* ======================================== */
/* SECTION 6: Upload Areas                  */
/* ======================================== */
.upload-area {
    border: 2px dashed var(--border);
    padding: 20px;
    text-align: center;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255,255,255,0.02);
}

.upload-area:hover {
    border-color: #FFD700;
    background: rgba(255,215,0,0.05);
}

.upload-area.has-file {
    border-color: var(--accent2);
    background: rgba(32,201,151,0.1);
}

.upload-text { font-size: 12px; color: var(--muted); }

/* ======================================== */
/* SECTION 7: Canvas & Preview            */
/* ======================================== */
#container {
    width: 100%;
    height: 600px;
    border-radius: 12px;
    background: repeating-conic-gradient(#1a1a1a 0% 25%, #222 0% 50%) 50% / 20px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#container > div {
    max-width: 100%;
    max-height: 100%;
}

#png-container {
    width: 100%;
    height: 600px;
    border-radius: 12px;
    background: repeating-conic-gradient(#1a1a1a 0% 25%, #222 0% 50%) 50% / 20px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#png-container > div {
    max-width: 100%;
    max-height: 100%;
}

#canvas-container,
#canvas-container-music,
#canvas-container-color {
    width: 100%;
    max-width: 100%;
    min-height: 300px;
    aspect-ratio: 16/9;
    border-radius: 12px;
    background: repeating-conic-gradient(#1a1a1a 0% 25%, #222 0% 50%) 50% / 20px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

#canvas-container canvas {
    pointer-events: auto !important;
    cursor: pointer;
}

.canvas-info {
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(11,16,32,0.9);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 12px;
    border: 1px solid var(--border);
    z-index: 10;
    pointer-events: none;
}

/* ======================================== */
/* SECTION 8: Sliders                     */
/* ======================================== */
.slider-group { margin-bottom: 15px; }
.slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}
.slider-value { color: #FFD700; font-weight: 600; }
.slider-value.thickness { color: #FFD700; }

.slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    outline: none;
    margin-top: 8px;
    margin-bottom: 8px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #FFD700;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -6px;
}

.slider::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #FFD700;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ======================================== */
/* SECTION 9: PNG Mapping - Layer Items   */
/* ======================================== */
.layer-item {
    padding: 12px;
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
    cursor: pointer;
    transition: all 0.2s;
    width: 300px;
    flex-shrink: 0;
}

.layer-item.highlighted {
    border-color: #FFD700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5) !important;
    background: rgba(255, 215, 0, 0.1) !important;
}

.layer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.layer-color {
    width: 24px; height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.3);
}

.layer-name { font-weight: 500; flex: 1; }

.layer-type {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
}

.layer-type.black { background: #000; color: #fff; }
.layer-type.white { background: rgba(255,255,255,0.2); }

.layer-modes {
    display: flex;
    gap: 5px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.mode-btn[data-mode="transparent"] {
    background: repeating-conic-gradient(#333 0% 25%, #444 0% 50%) 50% / 10px 10px;
    border: 2px solid rgba(255,255,255,0.3);
}

.mode-btn[data-mode="transparent"].active {
    border-color: #FFD700;
    box-shadow: 0 0 8px rgba(255,215,0,0.5);
}

.mode-btn[data-mode="black"] {
    background: #000;
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
}

.mode-btn[data-mode="black"].active {
    border-color: #FFD700;
    box-shadow: 0 0 8px rgba(255,215,0,0.5);
}

.mode-btn[data-mode="video"] {
    border: 2px solid rgba(255,255,255,0.3);
}

.mode-btn[data-mode="video"].active {
    border-color: #FFD700;
    box-shadow: 0 0 8px rgba(255,215,0,0.5);
}

.mode-btn {
    padding: 10px 16px;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    min-width: 50px;
}

.layer-video-input { display: none; margin-top: 8px; }
.layer-video-input.show { display: block; }

.preview { border-radius: 10px; overflow: hidden; max-height: 120px; margin-top: 8px; }
.preview video { width: 100%; max-height: 120px; display: block; }

/* ======================================== */
/* SECTION 10: Video Mapping - Screen Items */
/* ======================================== */
.screen-item {
    background: rgba(255,255,255,0.03);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    width: 280px;
    flex-shrink: 0;
}

.screen-item:hover { border-color: rgba(255,255,255,0.2); }
.screen-item.selected {
    border-color: var(--accent);
    background: rgba(124,92,255,0.1);
    box-shadow: 0 0 0 2px rgba(124,92,255,0.3);
}

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

.screen-title { font-weight: 500; font-size: 13px; }

.screen-remove {
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 18px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1;
}

.screen-remove:hover { background: rgba(255,107,107,0.1); }

.screen-eye {
    background: none;
    border: none;
    color: var(--accent2);
    cursor: pointer;
    font-size: 14px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen-eye:hover { background: rgba(32,201,151,0.1); }
.screen-eye.hidden { color: #ff6b6b; }
.screen-eye.hidden:hover { background: rgba(255,107,107,0.1); }

.no-screens {
    text-align: center;
    color: var(--muted);
    padding: 20px;
    font-size: 13px;
    width: 100%;
}

/* ======================================== */
/* SECTION 11: Progress & Status          */
/* ======================================== */
.progress-container { margin-top: 10px; display: none; }
.progress-container.active { display: block; }

.progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    width: 0;
    transition: width 0.2s;
}

.progress-text { font-size: 11px; color: var(--muted); margin-top: 5px; text-align: center; }

.small { font-size: 12px; color: var(--muted); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.hint { font-size: 11px; color: var(--muted); margin-top: 8px; text-align: center; }

/* ======================================== */
/* SECTION 12: Library Sidebar            */
/* ======================================== */
.library-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.library-sidebar.active { right: 0; }

.library-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
}

.library-overlay.active { display: block; }

.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.library-search {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.library-search input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(0,0,0,0.3);
    color: var(--text);
    font-size: 14px;
}

.library-search input:focus { outline: none; border-color: var(--accent); }

.library-categories {
    display: flex;
    gap: 8px;
    padding: 15px 20px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
}

.library-category {
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
    transition: all 0.2s;
}

.library-category:hover,
.library-category.active {
    background: var(--accent);
    border-color: var(--accent);
}

.library-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
}

.library-video-item {
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.library-video-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.library-video-item video,
.library-video-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.library-video-info {
    padding: 10px;
    font-size: 12px;
    color: var(--muted);
}

.library-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.library-upload {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(124,92,255,0.05);
}

/* ======================================== */
/* SECTION 13: Download Overlay           */
/* ======================================== */
.download-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1000;
}

.download-overlay.active { display: flex; }

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--accent2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin-bottom: 20px;
    color: #000;
}

.download-btn {
    background: var(--accent2);
    color: #000;
    padding: 15px 40px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s;
}

.download-btn:hover { transform: scale(1.05); }

/* ======================================== */
/* SECTION 14: Utilities & Misc           */
/* ======================================== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.hidden-video { display: none; }
.hidden-image { display: none; }
.time-display { display: flex; justify-content: center; font-size: 11px; color: var(--muted); }

/* ======================================== */
/* SECTION 15: Scrollbar Styling          */
/* ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}
