:root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;

    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;

    /* JWT Colors */
    --jwt-header: #fb7185;
    /* red */
    --jwt-payload: #a78bfa;
    /* purple */
    --jwt-signature: #38bdf8;
    /* blue */

    --success-color: #10b981;
    --danger-color: #ef4444;

    --radius: 8px;
    --font: 'Inter', system-ui, sans-serif;
    --font-mono: 'Fira Code', monospace;
    --transition: all 0.2s ease;
}

.light-theme {
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --surface-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --primary-color: #7c3aed;
    --primary-hover: #6d28d9;

    --jwt-header: #e11d48;
    --jwt-payload: #7c3aed;
    --jwt-signature: #0284c7;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.font-mono {
    font-family: var(--font-mono);
}

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

.text-sm {
    font-size: 0.85rem;
}

.font-normal {
    font-weight: 400;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-header {
    height: 60px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.badge {
    background-color: rgba(139, 92, 246, 0.15);
    color: var(--primary-color);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 99px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Panels */
.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.encoded-section {
    border-right: 1px solid var(--border-color);
}

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

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.decoded-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* UI Elements */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: var(--font);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-secondary {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--surface-hover);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: var(--transition);
    padding: 0.5rem;
}

.icon-btn:hover {
    color: var(--text-primary);
    background-color: var(--surface-hover);
}

/* Left Side - Encoded JWT */
.jwt-input-wrapper {
    flex: 1;
    position: relative;
    padding: 1.5rem;
    overflow: hidden;
    background-color: var(--surface-color);
}

.jwt-textarea,
.jwt-highlights {
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    font-size: 1.15rem;
    line-height: 1.6;
    word-break: break-all;
    white-space: pre-wrap;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    position: absolute;
    top: 0;
    left: 0;
}

.jwt-textarea {
    color: transparent;
    /* Text is transparent so highlights show through, but caret is still visible */
    caret-color: var(--text-primary);
    resize: none;
    z-index: 2;
    outline: none;
}

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

.jwt-highlights {
    z-index: 1;
    color: var(--text-muted);
    /* Fallback */
    pointer-events: none;
}

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

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

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

.jwt-color-dot {
    color: var(--text-primary);
    font-weight: bold;
}

/* Right Side - Decoded Blocks */
.editor-block {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background-color: var(--surface-color);
}

.block-header {
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.block-header h3 {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.part-type {
    font-weight: 400;
    color: var(--text-muted);
}

.header-block .block-header {
    border-top: 3px solid var(--jwt-header);
}

.payload-block .block-header {
    border-top: 3px solid var(--jwt-payload);
}

.signature-block .block-header {
    border-top: 3px solid var(--jwt-signature);
}

.json-editor {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 150px;
    outline: none;
}

.signature-editor {
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.1);
}

.sig-formula {
    color: var(--jwt-signature);
    font-size: 0.9rem;
    line-height: 1.6;
}

.secret-input {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    width: 250px;
    outline: none;
    transition: var(--transition);
}

.secret-input:focus {
    border-color: var(--jwt-signature);
}

/* Verification Status */
.verification-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    background-color: var(--surface-hover);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-valid .status-indicator {
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

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

.status-invalid .status-indicator {
    background-color: var(--danger-color);
    box-shadow: 0 0 8px var(--danger-color);
}

.status-invalid .status-text {
    color: var(--danger-color);
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}