/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: #0b0e14;
    color: #e5e7eb;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1.5rem;
}

#app {
    max-width: 1400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== HEADER ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    background: rgba(20, 26, 36, 0.8);
    backdrop-filter: blur(12px);
    padding: 0.75rem 1.5rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-area i {
    font-size: 1.8rem;
    color: #60a5fa;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #f0f4ff, #93bbfc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-area .badge {
    font-size: 0.6rem;
    font-weight: 600;
    background: #2563eb;
    color: white;
    padding: 0.15rem 0.6rem;
    border-radius: 1rem;
    -webkit-text-fill-color: white;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lang-selector {
    display: flex;
    gap: 0.25rem;
    background: #1e293b;
    padding: 0.2rem;
    border-radius: 2rem;
}

.lang-btn {
    background: transparent;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 1.5rem;
    font-weight: 600;
    font-size: 0.75rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn.active {
    background: #3b82f6;
    color: white;
}

.lang-btn:hover:not(.active) {
    color: #e2e8f0;
}

.icon-btn {
    background: #1e293b;
    border: none;
    color: #94a3b8;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #2d3a4f;
    color: white;
}

/* ===== DROP ZONE ===== */
.drop-zone {
    position: relative;
    background: rgba(20, 26, 36, 0.6);
    backdrop-filter: blur(6px);
    border: 2px dashed #334155;
    border-radius: 1.5rem;
    padding: 3rem 1.5rem;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.drop-zone.dragover {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-content {
    pointer-events: none;
}

.drop-content i {
    color: #4b5563;
    margin-bottom: 0.5rem;
}

.drop-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: #e2e8f0;
}

.drop-hint {
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.preview-area {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
}

.preview-area img {
    max-height: 100px;
    max-width: 100px;
    object-fit: contain;
    border-radius: 0.5rem;
    border: 1px solid #2d3a4f;
    background: #0b0e14;
}

.file-list {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #94a3b8;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.file-list .file-tag {
    background: #1e293b;
    padding: 0.2rem 0.7rem;
    border-radius: 1rem;
    border: 1px solid #2d3a4f;
}

.hidden {
    display: none !important;
}

/* ===== STATUS BAR ===== */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 1rem;
    border: 1px solid #1e293b;
    font-size: 0.85rem;
    color: #94a3b8;
}

.progress-info {
    font-weight: 500;
    color: #60a5fa;
}

/* ===== SETTINGS MODAL ===== */
.settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.settings-modal.hidden {
    display: none;
}

.settings-panel {
    background: #1a2332;
    border: 1px solid #2d3a4f;
    border-radius: 1.5rem;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem 2rem 2rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.settings-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #f1f5f9;
}

.close-btn {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    transition: 0.2s;
}

.close-btn:hover {
    color: #f1f5f9;
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.setting-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #e2e8f0;
}

.setting-group small {
    font-size: 0.75rem;
    color: #6b7280;
}

.range-with-value {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.range-with-value input[type="range"] {
    flex: 1;
    height: 4px;
    background: #2d3a4f;
    border-radius: 2px;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.range-with-value input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
}

.range-with-value span {
    min-width: 2.5rem;
    text-align: right;
    font-weight: 500;
    color: #60a5fa;
}

select, .manual-bg-area input[type="color"] {
    background: #0f172a;
    border: 1px solid #2d3a4f;
    color: #e2e8f0;
    padding: 0.4rem 0.75rem;
    border-radius: 0.6rem;
    font-size: 0.85rem;
    outline: none;
}

select:focus, input[type="color"]:focus {
    border-color: #3b82f6;
}

.manual-bg-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}

.manual-bg-area .btn-secondary {
    padding: 0.3rem 0.8rem;
    font-size: 0.75rem;
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    font-size: 0.85rem;
    color: #d1d5db;
}

.radio-group input[type="radio"] {
    accent-color: #3b82f6;
    width: 1rem;
    height: 1rem;
}

.settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #2d3a4f;
}

.btn-primary, .btn-secondary {
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: 0.6rem;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #1e293b;
    color: #cbd5e1;
}

.btn-secondary:hover {
    background: #2d3a4f;
}

/* ===== COLOR PICKER MODAL ===== */
.color-picker-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    padding: 1rem;
}

.color-picker-modal.hidden {
    display: none;
}

.color-picker-content {
    background: #1a2332;
    border: 1px solid #2d3a4f;
    border-radius: 1.5rem;
    padding: 1.5rem;
    max-width: 700px;
    width: 100%;
}

.color-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.color-picker-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
    color: #f1f5f9;
}

.color-picker-canvas {
    width: 100%;
    height: auto;
    max-height: 400px;
    border-radius: 0.75rem;
    border: 1px solid #2d3a4f;
    cursor: crosshair;
    background: #0b0e14;
}

.color-picker-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.selected-color-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.color-preview-box {
    width: 2rem;
    height: 2rem;
    border-radius: 0.4rem;
    border: 1px solid #4b5563;
}

#selectedColorHex {
    font-weight: 600;
    color: #60a5fa;
}

.color-picker-footer .btn-secondary,
.color-picker-footer .btn-primary {
    font-size: 0.8rem;
    padding: 0.4rem 1rem;
}

/* ===== RESULTS SECTION ===== */
.results-section {
    background: rgba(20, 26, 36, 0.6);
    backdrop-filter: blur(6px);
    border-radius: 1.5rem;
    padding: 1.5rem;
    border: 1px solid #1e293b;
}

.results-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1.5rem;
}

.results-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #f1f5f9;
}

.count-badge {
    background: #2563eb;
    color: white;
    padding: 0.1rem 0.8rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.results-actions .btn-primary,
.results-actions .btn-secondary {
    font-size: 0.75rem;
    padding: 0.4rem 0.9rem;
}

.sprite-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
}

.sprite-item {
    position: relative;
    background: #111b28;
    border-radius: 0.75rem;
    border: 1px solid #253141;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
}

.sprite-item:hover {
    transform: scale(1.04);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    z-index: 5;
}

.sprite-item canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
    image-rendering: pixelated;
}

.sprite-item .download-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    padding: 4px 6px;
    color: #cbd5e1;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    border: none;
}

.sprite-item:hover .download-icon {
    opacity: 1;
}

.sprite-item .download-icon:hover {
    color: white;
    background: rgba(37, 99, 235, 0.8);
}

.no-sprites {
    text-align: center;
    padding: 3rem 0;
    color: #6b7280;
    font-size: 0.95rem;
}

/* ===== FOOTER ===== */
.app-footer {
    text-align: center;
    font-size: 0.7rem;
    color: #4b5563;
    padding: 0.5rem 0;
    border-top: 1px solid #1e293b;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    body {
        padding: 0.75rem;
    }
    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }
    .header-controls {
        justify-content: flex-end;
    }
    .logo-area h1 {
        font-size: 1.2rem;
    }
    .settings-panel {
        padding: 1rem;
    }
    .sprite-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 0.75rem;
    }
    .results-header {
        flex-direction: column;
        align-items: stretch;
    }
    .results-actions {
        margin-left: 0;
        justify-content: flex-start;
    }
    .color-picker-content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .drop-zone {
        padding: 1.5rem 0.75rem;
        min-height: 150px;
    }
    .settings-panel {
        padding: 0.75rem;
    }
    .sprite-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 0.5rem;
    }
    .range-with-value {
        gap: 0.5rem;
    }
    .range-with-value span {
        min-width: 2rem;
        font-size: 0.8rem;
    }
}