/* 
=============================================================
style.css — Desain Antarmuka Premium untuk Simulasi S-AES
=============================================================
Desain mengadopsi Modern Dark Theme, Glassmorphism, Micro-interactions,
dan tipografi modern (Outfit + Space Grotesk).
=============================================================
*/

/* ─────────────────────────────────────────────
   1. VARIABLES & DESIGN TOKENS
   ───────────────────────────────────────────── */
:root {
    --bg-app: #0b0f19;
    --bg-card: rgba(22, 30, 49, 0.7);
    --bg-card-border: rgba(255, 255, 255, 0.08);
    --bg-input: #121824;
    --bg-input-focus: #182235;
    
    --primary: #4f46e5;
    --primary-hover: #6366f1;
    --primary-light: rgba(99, 102, 241, 0.15);
    
    --secondary: #3b82f6;
    --secondary-hover: #60a5fa;
    --secondary-light: rgba(96, 165, 250, 0.1);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-primary: #a5b4fc;
    
    --success: #10b981;
    --danger: #ef4444;
    
    --font-heading: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --border-radius-lg: 16px;
    --border-radius-md: 10px;
    --border-radius-sm: 6px;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    
    --shadow-main: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.2);
}

/* ─────────────────────────────────────────────
   2. RESET & BASE STYLES
   ───────────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-app);
    background-image: 
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ─────────────────────────────────────────────
   3. APP HEADER
   ───────────────────────────────────────────── */
.app-header {
    text-align: center;
    margin-bottom: 1rem;
    animation: fadeInDown 0.8s ease;
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    display: inline-block;
    filter: drop-shadow(0 0 10px rgba(79, 70, 229, 0.4));
    animation: pulseGlow 3s infinite alternate;
}

.app-header h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 2.5rem;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #fff 40%, var(--text-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 1rem;
}

/* ─────────────────────────────────────────────
   4. CARDS & GENERAL LAYOUT
   ───────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-main);
    transition: transform var(--transition-normal), border-color var(--transition-normal);
}

.card:hover {
    border-color: rgba(99, 102, 241, 0.2);
}

.card h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
}

/* ─────────────────────────────────────────────
   5. FORM INPUTS & SELECTORS
   ───────────────────────────────────────────── */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.input-group input[type="text"] {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--border-radius-md);
    padding: 0.85rem 1rem;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    transition: all var(--transition-fast);
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--bg-input-focus);
    box-shadow: var(--shadow-glow);
}

.input-helper {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.error-message {
    font-size: 0.85rem;
    color: var(--danger);
    margin-top: 0.5rem;
    display: none;
    font-weight: 500;
}

/* Mode Radio Buttons */
.mode-selector {
    display: flex;
    gap: 2rem;
    margin: 1.5rem 0 2rem 0;
}

.radio-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.radio-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-button {
    height: 20px;
    width: 20px;
    background-color: var(--bg-input);
    border: 2px solid var(--bg-card-border);
    border-radius: 50%;
    margin-right: 0.75rem;
    display: inline-block;
    position: relative;
    transition: all var(--transition-fast);
}

.radio-container:hover input ~ .radio-button {
    border-color: var(--primary-hover);
}

.radio-container input:checked ~ .radio-button {
    background-color: var(--primary);
    border-color: var(--primary);
}

.radio-button::after {
    content: "";
    position: absolute;
    display: none;
    top: 50%;
    left: 50%;
    transform: translate(-translate(-50%, -50%)); /* Fallback below */
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.radio-container input:checked ~ .radio-button::after {
    display: block;
    top: 4px;
    left: 4px;
}

.radio-label {
    font-family: var(--font-heading);
    font-weight: 500;
    color: var(--text-main);
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
}

.btn {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    padding: 0.85rem 2rem;
    border-radius: var(--border-radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    flex-grow: 1;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), #818cf8);
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--bg-card-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ─────────────────────────────────────────────
   6. OUTPUT RESULTS PANEL
   ───────────────────────────────────────────── */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .result-grid {
        grid-template-columns: 1fr;
    }
}

.result-box {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.result-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--secondary);
}

.result-label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.binary-font {
    font-family: var(--font-mono);
    color: #38bdf8;
    letter-spacing: 0.05em;
}

.hex-font {
    font-family: var(--font-mono);
    color: #a78bfa;
}

.hidden {
    display: none !important;
}

/* ─────────────────────────────────────────────
   7. ACCORDION (STEP-BY-STEP)
   ───────────────────────────────────────────── */
.accordion {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.accordion-item {
    border: 1px solid var(--bg-card-border);
    background-color: rgba(255, 255, 255, 0.02);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    transition: all var(--transition-fast);
}

.accordion-item:hover {
    border-color: rgba(99, 102, 241, 0.2);
}

.accordion-header {
    width: 100%;
    background: none;
    border: none;
    color: #fff;
    padding: 1.25rem 1.5rem;
    text-align: left;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
}

.acc-num {
    color: var(--primary-hover);
    margin-right: 1rem;
    font-family: var(--font-mono);
}

.acc-title {
    flex-grow: 1;
}

.acc-chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.accordion-item.active .acc-chevron {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1);
    background-color: rgba(0, 0, 0, 0.15);
}

.accordion-item.active .accordion-content {
    max-height: 2000px; /* Nilai arbitrer besar */
    transition: max-height 0.3s cubic-bezier(1, 0, 1, 0);
}

.step-detail-container {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ─────────────────────────────────────────────
   8. VISUALIZATION COMPONENTS (MATRIX, BOX, LOGS)
   ───────────────────────────────────────────── */
/* Container state */
.state-step {
    margin-bottom: 2rem;
    background-color: rgba(255, 255, 255, 0.01);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    border: 1px dashed rgba(255, 255, 255, 0.05);
}

.state-step:last-child {
    margin-bottom: 0;
}

.state-step-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Flexbox untuk visualisasi kalkulasi */
.state-viz-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

/* Visualisasi Matrix 2x2 */
.matrix-wrapper {
    text-align: center;
}

.matrix-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
}

.matrix-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 2px solid #818cf8;
    border-radius: var(--border-radius-sm);
    padding: 8px;
    min-width: 140px;
    position: relative;
}

/* Bracket Matrix Samping */
.matrix-grid-2x2::before, .matrix-grid-2x2::after {
    content: '';
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 6px;
    border: 2px solid #818cf8;
}
.matrix-grid-2x2::before { left: -2px; border-right: none; }
.matrix-grid-2x2::after { right: -2px; border-left: none; }

.matrix-cell {
    background-color: var(--bg-input);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 8px 6px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-align: center;
    color: #38bdf8;
    font-weight: 500;
}

/* Operasi Matematika Beralur */
.math-operator {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-muted);
    font-family: var(--font-mono);
    user-select: none;
}

/* Detail Perkalian GF */
.calculation-log {
    width: 100%;
    margin-top: 1rem;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: #e2e8f0;
    white-space: pre-wrap;
    line-height: 1.5;
    border-left: 3px solid #818cf8;
}

/* ─────────────────────────────────────────────
   9. TABS & REFERENCE TABLES
   ───────────────────────────────────────────── */
.tabs-container {
    width: 100%;
}

.tabs-header {
    display: flex;
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 1.5rem;
    gap: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}

.tab-btn:hover {
    color: #fff;
}

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

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-hover);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.tab-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.table-scroll {
    overflow-x: auto;
}

/* Tabel S-Box */
.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    text-align: center;
}

.ref-table th, .ref-table td {
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.75rem 0.5rem;
    min-width: 50px;
}

.ref-table th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-heading);
}

.ref-table td.header-cell {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-heading);
}

.ref-table td:not(.header-cell):hover {
    background-color: var(--primary-light);
    color: #fff;
    cursor: default;
}

/* Matriks Visual Tab */
.matrices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 600px) {
    .matrices-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.matrix-box {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    text-align: center;
}

.matrix-box h4 {
    font-family: var(--font-heading);
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.matrix-viz {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    display: inline-flex;
    flex-direction: column;
    border-left: 2px solid var(--text-muted);
    border-right: 2px solid var(--text-muted);
    padding: 0 10px;
    color: #38bdf8;
    line-height: 1.4;
}

/* ─────────────────────────────────────────────
   10. APP FOOTER & ANIMATIONS
   ───────────────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {
    from {
        transform: scale(1);
        filter: drop-shadow(0 0 5px rgba(79, 70, 229, 0.3));
    }
    to {
        transform: scale(1.05);
        filter: drop-shadow(0 0 15px rgba(79, 70, 229, 0.6));
    }
}
