/* ============================================================
   AES-128 Simulator - Style Sheet
   ============================================================
   Modern dark theme dengan glassmorphism, gradient,
   dan micro-animations untuk UI premium.
   ============================================================ */

/* ============================================================
   CSS VARIABLES & DESIGN TOKENS
   ============================================================ */
:root {
    /* Color Palette - Dark Theme dengan aksen cyan/blue */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --bg-glass: rgba(15, 23, 42, 0.6);
    --bg-input: rgba(15, 23, 42, 0.8);

    --border-primary: rgba(56, 189, 248, 0.2);
    --border-hover: rgba(56, 189, 248, 0.4);
    --border-subtle: rgba(148, 163, 184, 0.1);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #38bdf8;

    --accent-primary: #38bdf8;
    --accent-secondary: #818cf8;
    --accent-success: #34d399;
    --accent-warning: #fbbf24;
    --accent-danger: #f87171;

    --gradient-primary: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    --gradient-dark: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --gradient-card: linear-gradient(145deg, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.8) 100%);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.15);
    --shadow-glow-strong: 0 0 30px rgba(56, 189, 248, 0.25);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}


/* ============================================================
   RESET & BASE STYLES
   ============================================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

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

/* Animated background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(56, 189, 248, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(129, 140, 248, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(52, 211, 153, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}


/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
}


/* ============================================================
   LAYOUT - CONTAINER
   ============================================================ */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}


/* ============================================================
   HEADER
   ============================================================ */
.app-header {
    text-align: center;
    padding: 48px 0 32px;
}

.app-header__icon {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.app-header__title {
    font-size: 2.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.app-header__subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.app-header__badge {
    display: inline-block;
    margin-top: 12px;
    padding: 4px 16px;
    border-radius: 20px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    color: var(--accent-primary);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}


/* ============================================================
   CARDS - Glassmorphism
   ============================================================ */
.card {
    background: var(--gradient-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.card__title {
    font-size: 1.25rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.card__title-icon {
    font-size: 1.4rem;
}


/* ============================================================
   FORM INPUTS
   ============================================================ */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group--full {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.form-label__hint {
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: normal;
    margin-left: 4px;
}

.form-input {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    width: 100%;
}

.form-input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 0.85rem;
}

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

.form-input.error {
    border-color: var(--accent-danger);
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.15);
}

.form-error {
    color: var(--accent-danger);
    font-size: 0.78rem;
    min-height: 1.2em;
}


/* ============================================================
   MODE SELECTOR (Radio Buttons)
   ============================================================ */
.mode-selector {
    display: flex;
    gap: 12px;
}

.mode-option {
    position: relative;
    flex: 1;
}

.mode-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.mode-option__label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.mode-option input[type="radio"]:checked + .mode-option__label {
    border-color: var(--accent-primary);
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary);
}

.mode-option__label:hover {
    border-color: var(--border-hover);
    background: rgba(56, 189, 248, 0.05);
}


/* ============================================================
   BUTTONS
   ============================================================ */
.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn--primary {
    background: var(--gradient-primary);
    color: #0f172a;
    box-shadow: var(--shadow-sm), 0 0 15px rgba(56, 189, 248, 0.2);
}

.btn--primary:hover {
    box-shadow: var(--shadow-md), 0 0 25px rgba(56, 189, 248, 0.3);
    transform: translateY(-1px);
}

.btn--secondary {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn--secondary:hover {
    background: rgba(100, 116, 139, 0.3);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn--danger {
    background: rgba(248, 113, 113, 0.15);
    color: var(--accent-danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.btn--danger:hover {
    background: rgba(248, 113, 113, 0.25);
}

.btn--copy {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(52, 211, 153, 0.3);
    padding: 8px 16px;
    font-size: 0.82rem;
}

.btn--copy:hover {
    background: rgba(52, 211, 153, 0.25);
}

.btn--copy.copied {
    background: rgba(52, 211, 153, 0.3);
}


/* ============================================================
   RESULT / OUTPUT SECTION
   ============================================================ */
.result-section {
    display: none;
    animation: fadeSlideIn 0.5s ease forwards;
}

.result-section.visible {
    display: block;
}

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

.result-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 16px;
}

.result-box__label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.result-box__value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    color: var(--accent-primary);
    word-break: break-all;
    letter-spacing: 0.05em;
}

.result-box__actions {
    flex-shrink: 0;
    margin-left: 16px;
}


/* ============================================================
   NIST TEST VECTOR BADGE
   ============================================================ */
.nist-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 8px;
}

.nist-badge--pass {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-success);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.nist-badge--fail {
    background: rgba(248, 113, 113, 0.15);
    color: var(--accent-danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}


/* ============================================================
   KEY EXPANSION SECTION
   ============================================================ */
.key-expansion {
    display: none;
    animation: fadeSlideIn 0.5s ease forwards;
}

.key-expansion.visible {
    display: block;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.word-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    transition: border-color var(--transition-fast);
}

.word-item:hover {
    border-color: var(--border-hover);
}

.word-item__label {
    color: var(--text-muted);
    font-weight: 600;
    min-width: 36px;
}

.word-item__value {
    color: var(--accent-primary);
    letter-spacing: 0.04em;
}

.word-item--highlight {
    border-color: rgba(129, 140, 248, 0.3);
    background: rgba(129, 140, 248, 0.05);
}

.word-item--highlight .word-item__label {
    color: var(--accent-secondary);
}


/* ============================================================
   g() FUNCTION DETAILS
   ============================================================ */
.g-function-detail {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.g-function-detail__title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-secondary);
    margin-bottom: 12px;
    letter-spacing: 0.02em;
}

.g-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.g-step__label {
    color: var(--text-muted);
    min-width: 100px;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
}

.g-step__value {
    color: var(--text-primary);
    letter-spacing: 0.04em;
}

.g-step__arrow {
    color: var(--accent-primary);
    font-size: 1rem;
}


/* ============================================================
   ROUND DETAILS - ACCORDION
   ============================================================ */
.rounds-section {
    display: none;
    animation: fadeSlideIn 0.5s ease forwards;
}

.rounds-section.visible {
    display: block;
}

.round-accordion {
    margin-bottom: 8px;
}

.round-accordion summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--gradient-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    list-style: none;
    transition: all var(--transition-fast);
    user-select: none;
}

.round-accordion summary::-webkit-details-marker {
    display: none;
}

.round-accordion summary::before {
    content: '▶';
    font-size: 0.65rem;
    color: var(--accent-primary);
    transition: transform var(--transition-normal);
    display: inline-block;
    flex-shrink: 0;
}

.round-accordion[open] summary::before {
    transform: rotate(90deg);
}

.round-accordion summary:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.round-accordion[open] summary {
    border-color: var(--accent-primary);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background: rgba(56, 189, 248, 0.08);
}

.round-accordion__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #0f172a;
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
}

.round-accordion__content {
    padding: 20px;
    border: 1px solid var(--border-subtle);
    border-top: none;
    border-bottom-left-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.4);
}


/* ============================================================
   STATE MATRIX TABLE (4x4)
   ============================================================ */
.step-group {
    margin-bottom: 20px;
}

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

.step-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-label__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-primary);
    flex-shrink: 0;
}

.state-matrix {
    border-collapse: separate;
    border-spacing: 3px;
}

.state-matrix td {
    width: 48px;
    height: 40px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    letter-spacing: 0.06em;
    transition: all var(--transition-fast);
}

.state-matrix td:hover {
    border-color: var(--accent-primary);
    background: rgba(56, 189, 248, 0.1);
    transform: scale(1.05);
}

/* Variasi warna untuk round key */
.state-matrix--key td {
    color: var(--accent-secondary);
    border-color: rgba(129, 140, 248, 0.2);
}

.state-matrix--key td:hover {
    border-color: var(--accent-secondary);
    background: rgba(129, 140, 248, 0.1);
}

/* Variasi warna untuk hasil */
.state-matrix--result td {
    color: var(--accent-success);
    border-color: rgba(52, 211, 153, 0.2);
}

.state-matrix--result td:hover {
    border-color: var(--accent-success);
    background: rgba(52, 211, 153, 0.1);
}

/* Matrix flow (multiple matrix in a row with arrows) */
.matrix-flow {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.matrix-flow__arrow {
    color: var(--text-muted);
    font-size: 1.2rem;
    flex-shrink: 0;
}


/* ============================================================
   TOAST / NOTIFICATION
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    background: var(--bg-card);
    border: 1px solid var(--accent-success);
    border-radius: var(--radius-sm);
    color: var(--accent-success);
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2s forwards;
    backdrop-filter: blur(10px);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}


/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
    text-align: center;
    padding: 40px 0 30px;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border-subtle);
    margin-top: 40px;
}

.app-footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}


/* ============================================================
   SCROLLBAR CUSTOM
   ============================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}


/* ============================================================
   SELECTION STYLE
   ============================================================ */
::selection {
    background: rgba(56, 189, 248, 0.3);
    color: var(--text-primary);
}


/* ============================================================
   INFO PANEL / SPECS
   ============================================================ */
.specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.spec-item {
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    text-align: center;
    transition: border-color var(--transition-fast);
}

.spec-item:hover {
    border-color: var(--border-hover);
}

.spec-item__value {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.spec-item__label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}


/* ============================================================
   LOADING / PROCESSING ANIMATION
   ============================================================ */
.processing {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: var(--text-secondary);
}

.processing.visible {
    display: flex;
}

.processing__spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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


/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */
@media (max-width: 768px) {
    .app-header__title {
        font-size: 1.8rem;
    }

    .app-header__subtitle {
        font-size: 0.9rem;
    }

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

    .btn-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .card {
        padding: 20px;
    }

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

    .specs-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .matrix-flow {
        flex-direction: column;
        align-items: flex-start;
    }

    .state-matrix td {
        width: 40px;
        height: 34px;
        font-size: 0.78rem;
    }

    .result-box {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .result-box__actions {
        margin-left: 0;
    }

    .mode-selector {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .app-header {
        padding: 32px 0 24px;
    }

    .app-header__title {
        font-size: 1.5rem;
    }

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


/* ============================================================
   SECTION DIVIDERS
   ============================================================ */
.section-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 32px 0 24px;
}

.section-divider__line {
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.section-divider__text {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    white-space: nowrap;
}


/* ============================================================
   EXPAND/COLLAPSE ALL BUTTON
   ============================================================ */
.expand-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

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