/* ============================================
   Figma Token Converter — Design System
   ============================================ */
:root {
    --bg-primary: #0F0A1A;
    --bg-secondary: #1A1230;
    --bg-card: rgba(26, 18, 48, 0.85);
    --bg-glass: rgba(26, 18, 48, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #F1F5F9;
    --text-secondary: #A78BFA;
    --text-muted: #6D5C8F;
    --accent: #8B5CF6;
    --accent-glow: rgba(139, 92, 246, 0.3);
    --accent-2: #F472B6;
    --success: #4ADE80;
    --error: #F87171;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="light"] {
    --bg-primary: #F5F3FF;
    --bg-secondary: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.08);
    --text-primary: #1A1230;
    --text-secondary: #6D28D9;
    --text-muted: #9B8CB8;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
}

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

html {
    font-size: 16px;
}

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

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 600px 400px at 25% 25%, rgba(139, 92, 246, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 500px 300px at 75% 75%, rgba(244, 114, 182, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.app {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.header {
    padding: 20px 0 16px;
}

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

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

.logo-icon {
    font-size: 1.6rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: var(--radius);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border: none;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--bg-card);
    color: var(--accent);
    transform: translateY(-1px);
}

.icon {
    width: 18px;
    height: 18px;
}

.moon-icon {
    display: none;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon {
    display: block;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #A78BFA);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.78rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color var(--transition);
}

.btn-text:hover {
    color: var(--accent);
}

/* Input */
.input-section {
    margin-bottom: 20px;
}

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

.input-header label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

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

textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    resize: vertical;
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder {
    color: var(--text-muted);
}

.error-msg {
    margin-top: 6px;
    padding: 8px 12px;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.82rem;
}

/* Format Tabs */
.format-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    margin-bottom: 0;
}

.format-tab {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.format-tab:hover {
    color: var(--text-secondary);
    background: rgba(139, 92, 246, 0.05);
}

.format-tab.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

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

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-glass);
}

.token-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

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

.output-code {
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    color: var(--accent);
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 400px;
    overflow-y: auto;
    margin: 0;
    background: transparent;
}

/* Preview */
.preview-section {
    margin-top: 24px;
}

.preview-section h2 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.token-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.token-card {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition);
}

.token-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.token-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.token-info {
    overflow: hidden;
}

.token-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.token-value {
    font-size: 0.66rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: all 0.35s ease;
    z-index: 100;
    pointer-events: none;
}

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

.hidden {
    display: none !important;
}

@media (max-width: 640px) {
    .format-tabs {
        flex-wrap: wrap;
    }

    .format-tab {
        min-width: 45%;
    }

    .token-grid {
        grid-template-columns: 1fr;
    }

    .input-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}