/* ============================================
   JWT Token Forge — Design System
   ============================================ */
:root {
    --bg-primary: #0D0A19;
    --bg-secondary: #1A1530;
    --bg-card: rgba(26, 21, 48, 0.85);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #E8E4F0;
    --text-secondary: #A29BFE;
    --text-muted: #6C6490;
    --accent: #6C5CE7;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --gold: #FDCB6E;
    --success: #4ADE80;
    --error: #F87171;
    --jwt-header: #F87171;
    --jwt-payload: #A29BFE;
    --jwt-signature: #4ADE80;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, sans-serif;
}

[data-theme="light"] {
    --bg-primary: #FAF5FF;
    --bg-secondary: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.9);
    --border-glass: rgba(0, 0, 0, 0.08);
    --text-primary: #1A1530;
    --text-secondary: #6C5CE7;
    --text-muted: #9B93C0;
}

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

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

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 500px 400px at 30% 20%, rgba(108, 92, 231, 0.06), transparent 70%);
    pointer-events: none;
    z-index: -1;
}

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

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

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

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

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

.logo h1 {
    font-size: 1.1rem;
    font-weight: 700;
}

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

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-secondary);
    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 {
    color: var(--accent);
}

.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: 5px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

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

.btn-primary:hover {
    transform: translateY(-1px);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.76rem;
}

.btn-lg {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 1rem;
}

.section {
    margin-bottom: 16px;
}

/* Mode Tabs */
.mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 16px;
}

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

.mode-tab.active {
    background: var(--accent);
    color: #fff;
}

/* Editor */
.editor-group {
    margin-bottom: 12px;
}

.editor-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

.editor-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.editor-group textarea,
.editor-group input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.8rem;
    resize: vertical;
}

.editor-group textarea:focus,
.editor-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.editor-group select {
    padding: 4px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.72rem;
    cursor: pointer;
}

.exp-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.exp-row input {
    width: 70px;
    padding: 7px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.82rem;
}

.exp-row select {
    padding: 7px 8px;
}

/* Token Anatomy */
.anatomy {
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.72rem;
    word-break: break-all;
    line-height: 1.6;
    margin-bottom: 12px;
}

.anatomy .jwt-header {
    color: var(--jwt-header);
}

.anatomy .jwt-payload {
    color: var(--jwt-payload);
}

.anatomy .jwt-sig {
    color: var(--jwt-signature);
}

.anatomy .jwt-dot {
    color: var(--text-muted);
}

/* Decoded */
.decoded-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.decoded-card {
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
}

.decoded-card h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.decoded-code {
    font-family: monospace;
    font-size: 0.74rem;
    color: var(--accent);
    line-height: 1.5;
    white-space: pre-wrap;
    margin: 0;
}

/* Claims */
.claims-info {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.claim-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.76rem;
    border-bottom: 1px solid var(--border-glass);
}

.claim-row:last-child {
    border-bottom: none;
}

.claim-key {
    color: var(--gold);
    font-weight: 600;
}

.claim-val {
    color: var(--text-secondary);
}

.claim-expired {
    color: var(--error);
}

.claim-valid {
    color: var(--success);
}

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

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.82rem;
    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: 480px) {
    .decoded-grid {
        grid-template-columns: 1fr;
    }
}