/* ============================================================
   Neon Pixel Art Converter PRO — Style Sheet
   Design System: Neon Dark (matches Audio Trimmer PRO & Image Converter PRO)
   ============================================================ */

/* --- CSS Variables (identical to sibling tools) --- */
:root {
    --bg-color: #0a0a0a;
    --surface-color: #141414;
    --surface-light: #222;
    --primary-color: #a3ff00;
    --primary-glow: rgba(163, 255, 0, 0.4);
    --danger-color: #ff4444;
    --text-color: #ffffff;
    --text-muted: #888899;
    --border-color: #333;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2rem;
    min-height: 100vh;
    background-image: radial-gradient(
        circle at 50% 0%,
        rgba(163, 255, 0, 0.08) 0%,
        transparent 70%
    );
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- App Container --- */
.app-container {
    width: 100%;
    max-width: 1500px;
    padding: 2.5rem;
    background: rgba(20, 20, 20, 0.7);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 32px;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.8),
        inset 0 0 0 1px rgba(163, 255, 0, 0.1);
    margin: 2rem;
}

/* --- Header --- */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.badge {
    font-size: 1rem;
    background: var(--primary-color);
    color: var(--bg-color);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 800;
    box-shadow: 0 0 15px var(--primary-glow);
    line-height: 1.4;
}

.highlight {
    color: var(--primary-color);
    text-shadow: 0 0 20px var(--primary-glow);
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
    margin-top: 0.4rem;
}

/* --- Drop Zone --- */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 20px;
    padding: 5rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(163, 255, 0, 0.05);
    box-shadow: 0 0 40px rgba(163, 255, 0, 0.1) inset;
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    pointer-events: none;
}

.drop-content p {
    font-size: 1.2rem;
    font-weight: 600;
}

.drop-content svg {
    color: var(--primary-color);
    filter: drop-shadow(0 0 15px var(--primary-glow));
    transition: var(--transition);
}

.drop-zone:hover .drop-content svg {
    transform: translateY(-10px) scale(1.1);
}

.drop-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* --- Utility: Hidden --- */
.hidden {
    display: none !important;
}

/* --- Editor Layout (3-column) --- */
.editor {
    display: grid;
    grid-template-columns: 260px 1fr 200px;
    gap: 1.5rem;
    align-items: flex-start;
    animation: fadeIn 0.4s ease;
}

/* --- Sidebars --- */
.sidebar {
    background: var(--surface-color);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow: hidden;
}

.sidebar-right {
    min-width: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.8rem;
    flex-shrink: 0;
}

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

/* --- Count Badge --- */
.count-badge {
    font-size: 0.75rem;
    background: var(--primary-color);
    color: var(--bg-color);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-weight: 800;
    min-width: 24px;
    text-align: center;
    display: inline-block;
    line-height: 1.4;
}

/* --- Settings Scroll --- */
.settings-scroll {
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding-right: 0.3rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.settings-scroll::-webkit-scrollbar {
    width: 4px;
}

.settings-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* --- Setting Group --- */
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.4rem 0;
}

/* --- Slider Header --- */
.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.slider-header span {
    color: var(--primary-color);
}

/* --- Slider Ticks --- */
.slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* --- Color Presets --- */
.color-presets {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.color-preset-btn {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    transition: var(--transition);
}

.color-preset-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.color-preset-btn.active {
    background: rgba(163, 255, 0, 0.15);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* --- Pro Slider (identical to sibling tools) --- */
.pro-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: transparent;
    height: 4px;
    width: 100%;
    cursor: pointer;
}

.pro-slider:focus {
    outline: none;
}

.pro-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
}

.pro-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 10px var(--primary-glow);
    border: none;
    transition: box-shadow 0.2s ease;
}

.pro-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 18px var(--primary-glow);
}

.pro-slider::-moz-range-track {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    border: none;
}

.pro-slider::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-glow);
    border: none;
}

/* zoom slider narrower */
.zoom-slider {
    width: 120px;
    flex-grow: 0;
}

/* --- Pro Select (identical to sibling tools) --- */
.pro-select {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888899' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2.2rem;
    width: 100%;
}

.pro-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(163, 255, 0, 0.15);
}

.pro-select option,
.pro-select optgroup {
    background: var(--surface-color);
    color: var(--text-color);
}

.pro-select-sm {
    font-size: 0.78rem;
    padding: 0.45rem 0.7rem;
    padding-right: 2rem;
    border-radius: 8px;
}

/* --- Pro Checkbox --- */
.pro-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
}

.pro-checkbox:hover {
    color: var(--text-color);
}

.pro-checkbox input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
    background: transparent;
}

.pro-checkbox input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-glow);
}

.pro-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 0px;
    left: 4px;
    width: 4px;
    height: 8px;
    border: solid var(--bg-color);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* --- Buttons (identical to sibling tools) --- */
.btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-color);
    outline: none;
    font-family: 'Outfit', sans-serif;
}

.btn-small {
    padding: 0.4rem;
    border-radius: 8px;
    background: var(--surface-light);
    color: var(--primary-color);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-family: 'Outfit', sans-serif;
}

.btn-small:hover {
    background: var(--primary-color);
    color: var(--bg-color);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-color);
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    gap: 0.5rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', sans-serif;
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 15px rgba(163, 255, 0, 0.1);
}

.btn-primary {
    background: var(--primary-color);
    color: var(--bg-color);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.9rem;
    gap: 0.5rem;
    box-shadow: 0 0 20px var(--primary-glow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-family: 'Outfit', sans-serif;
}

.btn-primary:hover {
    box-shadow: 0 0 35px var(--primary-glow);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 0 20px var(--primary-glow);
}

/* --- Main Editor --- */
.main-editor {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

/* --- Canvas Container --- */
.canvas-container {
    background: var(--surface-light);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.5);
}

/* --- Canvas Toolbar --- */
.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
    gap: 1rem;
    flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* --- View Toggle (Before/After) --- */
.view-toggle {
    display: flex;
    background: var(--surface-light);
    border-radius: 10px;
    overflow: hidden;
    padding: 3px;
    border: 1px solid var(--border-color);
}

.view-toggle input {
    display: none;
}

.view-toggle label {
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    border-radius: 7px;
    transition: var(--transition);
    color: var(--text-muted);
    white-space: nowrap;
}

.view-toggle input:checked + label {
    background: var(--primary-color);
    color: var(--bg-color);
    box-shadow: 0 0 12px var(--primary-glow);
}

/* --- Zoom Panel --- */
.zoom-panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.zoom-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 38px;
    text-align: right;
}

/* --- Canvas Wrapper --- */
.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 440px;
    overflow: hidden;
    background:
        repeating-conic-gradient(
            rgba(255, 255, 255, 0.025) 0% 25%,
            transparent 0% 50%
        ) 50% / 16px 16px;
    cursor: crosshair;
}

.canvas-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: center;
    display: flex;
    gap: 4px;
    transform: translate(-50%, -50%);
}

#canvas-original,
#canvas-result {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.canvas-grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    opacity: 0.3;
}

/* --- Split View --- */
.split-pane {
    position: relative;
}

.split-label {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.7);
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* --- Canvas Status Bar --- */
.canvas-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1.2rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    gap: 0.8rem;
    flex-wrap: wrap;
}

.status-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.info-chip {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.info-chip svg {
    opacity: 0.6;
}

.info-chip.muted {
    opacity: 0.6;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Bottom Panel --- */
.bottom-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.5rem;
    align-items: start;
}

/* --- Panel Section --- */
.panel-section {
    background: var(--surface-color);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.8rem;
}

.panel-section-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.panel-section-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* --- Palette Swatches --- */
.palette-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 32px;
}

.swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

.swatch:hover {
    transform: scale(1.3);
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.swatch::after {
    content: attr(data-hex);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-color);
    color: var(--text-color);
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    border: 1px solid var(--border-color);
    transition: opacity 0.15s ease;
    font-weight: 600;
    font-family: monospace;
}

.swatch:hover::after {
    opacity: 1;
}

/* --- Export Section --- */
.export-section {
    min-width: 340px;
}

.export-grid {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.pro-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filename-col {
    /* full width filename row */
}

/* --- Filename Input --- */
.filename-input {
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.filename-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(163, 255, 0, 0.15);
}

.filename-input::placeholder {
    color: var(--text-muted);
}

/* --- Export Actions --- */
.export-actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* --- Color List (Right Sidebar) --- */
.color-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex-grow: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.color-list::-webkit-scrollbar {
    width: 4px;
}

.color-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.color-list-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--surface-light);
    border: 1px solid transparent;
}

.color-list-item:hover {
    border-color: rgba(163, 255, 0, 0.2);
}

.color-dot {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
}

.color-hex {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    flex-grow: 1;
}

.color-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* --- Loading Overlay (identical to sibling tools) --- */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 20px;
    z-index: 10;
    gap: 1rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    box-shadow: 0 0 20px var(--primary-glow);
}

#processing-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-glow);
}

/* --- Keyframe Animations --- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

/* --- Responsive: Tablet --- */
@media (max-width: 1200px) {
    .editor {
        grid-template-columns: 240px 1fr;
    }

    .sidebar-right {
        display: none;
    }

    .bottom-panel {
        grid-template-columns: 1fr;
    }

    .export-section {
        min-width: 0;
    }
}

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

    .sidebar {
        position: static;
        max-height: 320px;
    }

    .canvas-wrapper {
        height: 300px;
    }

    .canvas-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    h1 {
        font-size: 1.8rem;
    }
}

/* --- Mobile --- */
@media (max-width: 600px) {
    .app-container {
        padding: 1.2rem;
        border-radius: 20px;
        margin: 1rem;
    }

    .drop-zone {
        padding: 3rem 1.2rem;
    }

    .export-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}
