/* ================================================================
   style.css — Stylesheet Utama
   Implementasi DFA untuk Validasi Format NPWP Indonesia Berbasis Web
   Tema: Bersih, ringan, putih & biru langit
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
    --bg:            #ffffff;
    --bg-soft:       #f0f7ff;
    --bg-section:    #f8fbff;

    --blue-50:       #eff8ff;
    --blue-100:      #dbeefe;
    --blue-200:      #bfdbfe;
    --blue-300:      #7ec8f2;
    --blue-400:      #38bdf8;
    --blue-500:      #0ea5e9;
    --blue-600:      #0284c7;
    --blue-700:      #0369a1;

    --border:        #e2e8f0;
    --border-blue:   #bfdbfe;

    --text:          #1e293b;
    --text-secondary:#64748b;
    --text-muted:    #94a3b8;

    --success:       #16a34a;
    --success-bg:    #f0fdf4;
    --success-border:#bbf7d0;
    --error:         #dc2626;
    --error-bg:      #fef2f2;
    --error-border:  #fecaca;

    --radius:        8px;
    --radius-lg:     12px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.06);
    --shadow:        0 2px 8px rgba(0,0,0,0.06);
    --transition:    all 0.2s ease;
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────── */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ── Header / Hero ────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 48px 0 36px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
}

.hero__badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    background: var(--blue-100);
    color: var(--blue-700);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.hero__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--blue-700);
    line-height: 1.3;
    margin-bottom: 10px;
}

.hero__subtitle {
    font-size: 0.92rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

.hero__subtitle strong {
    color: var(--blue-600);
}

/* ── Card ─────────────────────────────────────────────────────── */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.card__icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--blue-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.card__title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.card__description {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ── Definisi Formal ──────────────────────────────────────────── */
.formal-def {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.formal-def__item {
    background: var(--bg-soft);
    border: 1px solid var(--border-blue);
    border-radius: var(--radius);
    padding: 14px;
}

.formal-def__label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--blue-600);
    font-weight: 600;
    margin-bottom: 4px;
}

.formal-def__value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text);
    word-break: break-word;
    line-height: 1.6;
}

/* ── Input Section ────────────────────────────────────────────── */
.input-section {
    text-align: center;
    background: var(--bg-soft);
    border-color: var(--border-blue);
}

.input-group {
    display: flex;
    gap: 10px;
    max-width: 500px;
    margin: 0 auto 12px;
}

.input-group__field {
    flex: 1;
    padding: 12px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    letter-spacing: 1.5px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    outline: none;
    transition: var(--transition);
    text-align: center;
}

.input-group__field::placeholder {
    color: var(--text-muted);
    font-size: 0.82rem;
    letter-spacing: 1px;
}

.input-group__field:focus {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.btn {
    padding: 12px 24px;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn--primary {
    background: var(--blue-500);
    color: #fff;
}

.btn--primary:hover {
    background: var(--blue-600);
}

.btn--primary:active {
    background: var(--blue-700);
}

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

.btn--secondary:hover {
    border-color: var(--blue-300);
    color: var(--blue-600);
    background: var(--blue-50);
}

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

.input-hint code {
    background: var(--blue-50);
    border: 1px solid var(--border-blue);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--blue-600);
}

.btn-group {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

/* ── Result ───────────────────────────────────────────────────── */
.result-box {
    display: none;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 18px;
    text-align: left;
    animation: fadeIn 0.3s ease;
}

.result-box--valid {
    display: block;
    background: var(--success-bg);
    border: 1px solid var(--success-border);
}

.result-box--invalid {
    display: block;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
}

.result-box__message {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.result-box--valid .result-box__message  { color: var(--success); }
.result-box--invalid .result-box__message { color: var(--error); }

.result-box__detail {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ── Segments ─────────────────────────────────────────────────── */
.segments {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.segment-item {
    background: var(--bg);
    border: 1px solid var(--success-border);
    border-radius: 6px;
    padding: 10px;
    text-align: center;
}

.segment-item__label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

.segment-item__value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--success);
}

/* ── Diagram ──────────────────────────────────────────────────── */
.diagram-wrapper {
    overflow-x: auto;
    padding: 8px 0;
}

.diagram-wrapper svg {
    display: block;
    margin: 0 auto;
}

/* ── Format Explainer ─────────────────────────────────────────── */
.format-explain {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    margin: 14px 0;
    font-family: 'JetBrains Mono', monospace;
}

.format-char {
    width: 32px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

.format-char--digit {
    background: var(--blue-50);
    border: 1px solid var(--blue-200);
    color: var(--blue-600);
}

.format-char--dot {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: var(--success);
}

.format-char--dash {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #d97706;
}

.format-legend {
    display: flex;
    gap: 18px;
    justify-content: center;
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.format-legend__item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.format-legend__dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* ── Steps Table ──────────────────────────────────────────────── */
.steps-table-wrapper {
    overflow-x: auto;
    margin-top: 6px;
}

.steps-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.steps-table th {
    background: var(--bg-soft);
    color: var(--blue-700);
    font-weight: 600;
    padding: 10px 12px;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border-blue);
}

.steps-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
}

.steps-table tbody tr:hover {
    background: var(--blue-50);
}

.steps-table .step-accepted { color: var(--success); font-weight: 600; }
.steps-table .step-rejected { color: var(--error); font-weight: 600; }
.steps-table .step-active   { color: var(--blue-600); font-weight: 600; }

.steps-table .char-highlight {
    background: var(--blue-100);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
}

/* ── Transition Table ─────────────────────────────────────────── */
.transition-table-wrapper {
    overflow-x: auto;
}

.transition-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

.transition-table th {
    background: var(--bg-soft);
    color: var(--blue-700);
    padding: 9px 10px;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid var(--border-blue);
}

.transition-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.transition-table tbody tr:hover {
    background: var(--blue-50);
}

.transition-table td:first-child {
    font-weight: 600;
    color: var(--blue-600);
    text-align: left;
}

.transition-table .cell-dead   { color: var(--text-muted); }
.transition-table .cell-accept { color: var(--success); font-weight: 600; }

.transition-table .cell-start::before {
    content: '→ ';
    color: #d97706;
}

/* ── Footer ───────────────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 32px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 32px;
    background: var(--bg-soft);
}

.footer strong {
    color: var(--text-secondary);
}

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ──────────────────────────────────────────────────── */
.spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn--loading .spinner  { display: inline-block; }
.btn--loading .btn__text { display: none; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .hero__title    { font-size: 1.35rem; }
    .hero__subtitle { font-size: 0.85rem; }
    .input-group    { flex-direction: column; }
    .formal-def     { grid-template-columns: 1fr; }
    .segments       { grid-template-columns: 1fr 1fr; }
    .card           { padding: 18px; }
    .format-legend  { flex-direction: column; align-items: center; gap: 8px; }
}

@media (max-width: 480px) {
    .hero            { padding: 32px 0 24px; }
    .hero__title     { font-size: 1.15rem; }
    .btn-group       { flex-direction: column; }
    .segments        { grid-template-columns: 1fr; }
}
