/* ========================================
   SVG Sprite Sheet Builder — Premium Theme
   ======================================== */

:root {
    --primary: #8B5CF6;
    --primary-light: #A78BFA;
    --primary-dark: #7C3AED;
    --accent: #F472B6;
    --accent-light: #F9A8D4;
    --bg-base: #0C0A1A;
    --bg-surface: #1A1530;
    --bg-elevated: #2D2548;
    --bg-glass: rgba(26, 21, 48, 0.65);
    --text-primary: #F1F0F7;
    --text-secondary: #A5A0C0;
    --text-muted: #6B6590;
    --border: rgba(165, 160, 192, 0.1);
    --border-active: rgba(139, 92, 246, 0.4);
    --success: #34D399;
    --error: #F87171;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(139, 92, 246, 0.15);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 50% 40% at 25% 15%, rgba(139, 92, 246, 0.08), transparent),
        radial-gradient(ellipse 40% 30% at 75% 75%, rgba(244, 114, 182, 0.06), transparent);
    pointer-events: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Layout --- */
.app {
    position: relative;
    z-index: 1;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.header {
    padding: 24px 0 16px;
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-glow);
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- Main --- */
.main {
    flex: 1;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* --- Drop Zone --- */
.drop-zone {
    border: 2px dashed rgba(139, 92, 246, 0.25);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.06);
    box-shadow: var(--shadow-glow);
}

.drop-icon {
    color: var(--primary-light);
    margin-bottom: 12px;
}

.drop-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.drop-browse {
    color: var(--primary-light);
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.drop-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* --- Section Headers --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    font-size: 0.7rem;
    background: rgba(139, 92, 246, 0.15);
    color: var(--primary-light);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

/* --- Icons Grid --- */
.icons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.icon-card {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
    transition: all var(--transition);
    backdrop-filter: blur(8px);
}

.icon-card:hover {
    border-color: var(--border-active);
    background: rgba(139, 92, 246, 0.05);
}

.icon-card svg,
.icon-card img {
    color: var(--text-primary);
}

.icon-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.icon-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: rgba(248, 113, 113, 0.15);
    border: none;
    border-radius: 50%;
    color: var(--error);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    opacity: 0;
    transition: opacity var(--transition);
}

.icon-card:hover .icon-remove {
    opacity: 1;
}

.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.icons-section:has(.icon-card) .empty-state {
    display: none;
}

/* --- Output --- */
.output-section {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.output-section .section-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.output-actions {
    display: flex;
    gap: 6px;
}

.output-tabs {
    display: flex;
    gap: 0;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
}

.tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 10px 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
}

.tab:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.code-wrap {
    position: relative;
}

.code-block {
    padding: 16px 18px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent-light);
    line-height: 1.7;
    min-height: 200px;
    max-height: 400px;
    overflow: auto;
    white-space: pre;
    user-select: text;
}

.code-block:empty::before {
    content: '// Upload SVG files to generate a sprite sheet...';
    color: var(--text-muted);
    font-style: italic;
}

.copy-overlay-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    opacity: 0;
    transition: opacity var(--transition);
}

.code-wrap:hover .copy-overlay-btn {
    opacity: 1;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.72rem;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.btn-accent {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    box-shadow: 0 0 14px rgba(139, 92, 246, 0.2);
}

.btn-accent:hover {
    box-shadow: 0 0 22px rgba(139, 92, 246, 0.35);
    transform: translateY(-1px);
}

/* --- Range --- */
input[type="range"] {
    -webkit-appearance: none;
    width: 80px;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary-light);
    border-radius: 50%;
    cursor: pointer;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-elevated);
    color: var(--success);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid rgba(52, 211, 153, 0.2);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 300ms ease;
    pointer-events: none;
    z-index: 100;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --- Footer --- */
.footer {
    padding: 16px 0;
    border-top: 1px solid var(--border);
    text-align: center;
}

.footer p {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .app {
        padding: 0 12px;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .drop-zone {
        padding: 32px 16px;
    }

    .icons-grid {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    }

    .output-tabs {
        overflow-x: auto;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(165, 160, 192, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(165, 160, 192, 0.35);
}

::selection {
    background: rgba(139, 92, 246, 0.3);
    color: white;
}

*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}