/* ================================================================
   Aurora Glass Cryptography Lab — Premium UI
   Tugas 1 Kriptografi · Semester 6 · 2025/2026 Genap
   ================================================================ */

/* ---- CSS Custom Properties ---- */
:root {
    /* Accent palette */
    --c-cyan:    #22d3ee;
    --c-violet:  #8b5cf6;
    --c-indigo:  #6366f1;
    --c-emerald: #10b981;
    --c-rose:    #f43f5e;

    /* Dark-mode glass surface */
    --glass-bg:      rgba(15, 15, 22, 0.68);
    --glass-border:  rgba(255, 255, 255, 0.09);
    --glass-shadow:  0 8px 32px rgba(0, 0, 0, 0.45);
    --glass-blur:    18px;

    /* Layout */
    --nav-height: 64px;
    --radius-lg:  1rem;
    --radius-md:  0.625rem;

    /* Transitions */
    --t-fast:   0.15s ease;
    --t-normal: 0.25s ease;
    --t-slow:   0.4s ease;
}

/* Light-mode overrides */
[data-bs-theme="light"] {
    --glass-bg:     rgba(255, 255, 255, 0.72);
    --glass-border: rgba(99, 102, 241, 0.12);
    --glass-shadow: 0 8px 32px rgba(99, 102, 241, 0.10);
    --glass-blur:   16px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #080810;
    color: #e2e8f0;
    overflow-x: hidden;
    transition: background-color var(--t-slow), color var(--t-slow);
    -webkit-font-smoothing: antialiased;
}

[data-bs-theme="light"] body {
    background-color: #f0f2ff;
    color: #1e293b;
}

/* ================================================================
   ANIMATED BACKGROUND
   ================================================================ */

/* Aurora blobs — dark mode */
.aurora-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    overflow: hidden;
}

.aurora-bg::before,
.aurora-bg::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0;
    animation: aurora-appear 1.2s ease forwards;
}

/* Blob 1 — cyan/teal */
.aurora-bg::before {
    width: 70vw;
    height: 70vw;
    max-width: 700px;
    max-height: 700px;
    top: -15%;
    left: -10%;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.35) 0%, transparent 70%);
    animation: aurora-appear 1.2s ease forwards, aurora-drift-a 20s ease-in-out 1.2s infinite alternate;
}

/* Blob 2 — violet */
.aurora-bg::after {
    width: 60vw;
    height: 60vw;
    max-width: 600px;
    max-height: 600px;
    bottom: -10%;
    right: -10%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.35) 0%, transparent 70%);
    animation: aurora-appear 1.4s ease forwards, aurora-drift-b 22s ease-in-out 1.4s infinite alternate;
}

@keyframes aurora-appear {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes aurora-drift-a {
    0%   { transform: translate(0, 0)    scale(1); }
    50%  { transform: translate(4%, -4%) scale(1.08); }
    100% { transform: translate(-2%, 3%) scale(1.03); }
}
@keyframes aurora-drift-b {
    0%   { transform: translate(0, 0)    scale(1); }
    50%  { transform: translate(-3%, 4%) scale(1.06); }
    100% { transform: translate(3%, -2%) scale(1.04); }
}

/* Extra middle blob via a JS-free div */
.aurora-mid {
    position: fixed;
    z-index: -2;
    pointer-events: none;
    width: 55vw;
    height: 55vw;
    max-width: 550px;
    max-height: 550px;
    bottom: 20%;
    left: 30%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.22) 0%, transparent 70%);
    filter: blur(90px);
    opacity: 0;
    animation: aurora-appear 1.6s ease forwards, aurora-drift-c 18s ease-in-out 1.6s infinite alternate;
}
@keyframes aurora-drift-c {
    0%   { transform: translate(0, 0)    scale(1); }
    50%  { transform: translate(-4%, -3%) scale(1.1); }
    100% { transform: translate(2%, 4%)   scale(1.05); }
}

/* Light mode: softer, pastel aurora */
[data-bs-theme="light"] .aurora-bg::before {
    background: radial-gradient(circle, rgba(99, 102, 241, 0.18) 0%, transparent 70%);
}
[data-bs-theme="light"] .aurora-bg::after {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.16) 0%, transparent 70%);
}
[data-bs-theme="light"] .aurora-mid {
    background: radial-gradient(circle, rgba(34, 211, 238, 0.12) 0%, transparent 70%);
}

/* Twinkling stars — dark only */
.stars {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.8), transparent),
        radial-gradient(2px 2px at 35% 42%, rgba(255,255,255,.6), transparent),
        radial-gradient(1px 1px at 58% 12%, rgba(255,255,255,.9), transparent),
        radial-gradient(2px 2px at 72% 28%, rgba(255,255,255,.65), transparent),
        radial-gradient(1px 1px at 88% 55%, rgba(255,255,255,.75), transparent),
        radial-gradient(2px 2px at 22% 65%, rgba(255,255,255,.55), transparent),
        radial-gradient(1px 1px at 45% 82%, rgba(255,255,255,.70), transparent),
        radial-gradient(2px 2px at 62% 72%, rgba(255,255,255,.50), transparent),
        radial-gradient(1px 1px at 80% 90%, rgba(255,255,255,.75), transparent),
        radial-gradient(1px 1px at  5% 45%, rgba(255,255,255,.65), transparent),
        radial-gradient(2px 2px at 90% 15%, rgba(255,255,255,.60), transparent),
        radial-gradient(1px 1px at 25% 30%, rgba(255,255,255,.80), transparent);
    animation: twinkle 8s ease-in-out infinite alternate;
}
@keyframes twinkle {
    from { opacity: .35; }
    to   { opacity: .70; }
}
[data-bs-theme="light"] .stars { display: none; }

/* ================================================================
   GLASSMORPHISM
   ================================================================ */
.glass-nav {
    height: var(--nav-height);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    box-shadow: 0 1px 24px rgba(0,0,0,.30);
    transition: background var(--t-slow), border-color var(--t-slow);
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-lg);
    transition: transform var(--t-normal), box-shadow var(--t-normal), background var(--t-slow);
}
.glass-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 48px rgba(0,0,0,.50);
}
[data-bs-theme="light"] .glass-card:hover {
    box-shadow: 0 16px 40px rgba(99,102,241,.14);
}

.glass-alert {
    backdrop-filter: blur(12px);
    border-left-width: 3px;
}

/* ================================================================
   NAVIGATION
   ================================================================ */
.navbar-brand { letter-spacing: -0.01em; }

.nav-link {
    font-size: .92rem;
    font-weight: 500;
    color: inherit;
    border-radius: var(--radius-md);
    transition: color var(--t-fast), background var(--t-fast), opacity var(--t-fast);
    opacity: .75;
}
.nav-link:hover, .nav-link.active { opacity: 1; }
.nav-link.active { color: var(--c-cyan) !important; }

[data-bs-theme="light"] .nav-link.active { color: var(--c-indigo) !important; }

/* Theme toggle pill */
#themeToggle {
    font-size: .82rem;
    font-weight: 600;
    border-color: var(--glass-border);
    transition: all var(--t-normal);
}
#themeToggle:hover {
    transform: scale(1.06);
    box-shadow: 0 0 14px rgba(99,102,241,.35);
}

/* ================================================================
   TYPOGRAPHY
   ================================================================ */
.font-monospace { font-family: 'JetBrains Mono', monospace !important; }

.text-gradient {
    background: linear-gradient(135deg, var(--c-cyan), var(--c-violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-title {
    font-size: clamp(1.6rem, 5.5vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.15;
    background: linear-gradient(140deg, #fff 30%, #c4b5fd 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-bs-theme="light"] .hero-title {
    background: linear-gradient(140deg, #1e1b4b 20%, #6366f1 80%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(.85rem, 2vw, 1rem);
    font-weight: 300;
    color: #94a3b8;
    letter-spacing: .01em;
}
[data-bs-theme="light"] .hero-subtitle { color: #475569; }

/* ================================================================
   FORM CONTROLS
   ================================================================ */
.form-control,
.form-select {
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    font-size: .93rem;
}
.form-control:focus,
.form-select:focus {
    border-color: var(--c-indigo);
    box-shadow: 0 0 0 3px rgba(99,102,241,.20);
}

.key-inputs-box {
    background: rgba(255,255,255,.04);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
}
[data-bs-theme="light"] .key-inputs-box {
    background: rgba(99,102,241,.04);
    border-color: rgba(99,102,241,.12);
}

.form-text { font-size: .78rem; opacity: .7; }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
    font-weight: 500;
    letter-spacing: .01em;
    transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast) !important;
    position: relative;
    overflow: hidden;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active               { transform: translateY(0) !important; }

.btn-primary:hover  { box-shadow: 0 6px 20px rgba(99,102,241,.50); }
.btn-success:hover  { box-shadow: 0 6px 20px rgba(16,185,129,.50); }
.btn-outline-danger:hover { box-shadow: 0 6px 16px rgba(244,63,94,.35); }
.btn-outline-success:hover { box-shadow: 0 6px 16px rgba(16,185,129,.35); }

/* ================================================================
   TABS
   ================================================================ */
.glass-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    font-weight: 500;
    font-size: .88rem;
    color: inherit;
    opacity: .6;
    padding: .6rem 1rem;
    transition: opacity var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.glass-tabs .nav-link:hover  { opacity: 1; }
.glass-tabs .nav-link.active {
    opacity: 1;
    color: var(--c-cyan);
    border-bottom-color: var(--c-cyan);
    background: transparent;
}
[data-bs-theme="light"] .glass-tabs .nav-link.active {
    color: var(--c-indigo);
    border-bottom-color: var(--c-indigo);
}

.glass-tab-content {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-top: none;
    transition: background var(--t-slow);
}

/* ================================================================
   RESULT BOX
   ================================================================ */
.result-box {
    background: rgba(16,185,129,.08);
    border: 1px solid rgba(16,185,129,.22);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.formula-box {
    background: rgba(0,0,0,.35);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--c-cyan);
    font-size: .82rem;
    padding: .6rem 1rem;
    word-break: break-all;
}
[data-bs-theme="light"] .formula-box {
    background: rgba(99,102,241,.06);
    color: #4338ca;
}

/* ================================================================
   HILL MATRIX INPUTS
   ================================================================ */
.matrix-input-grid {
    display: grid;
    gap: 8px;
}

.matrix-input-cell {
    width: 56px;
    height: 56px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: .95rem;
    background: rgba(255,255,255,.06);
    border: 1px solid var(--glass-border);
    color: inherit;
    border-radius: var(--radius-md);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    -moz-appearance: textfield;
}
.matrix-input-cell::-webkit-inner-spin-button,
.matrix-input-cell::-webkit-outer-spin-button { -webkit-appearance: none; }

[data-bs-theme="light"] .matrix-input-cell {
    background: rgba(99,102,241,.06);
    border-color: rgba(99,102,241,.18);
}
.matrix-input-cell:focus {
    outline: none;
    border-color: var(--c-indigo);
    box-shadow: 0 0 0 3px rgba(99,102,241,.22);
}

/* ================================================================
   VISUALIZATION — HILL MATRIX DISPLAY
   ================================================================ */
.matrix-bracket {
    display: inline-flex;
    flex-direction: column;
    border-left: 2.5px solid #64748b;
    border-right: 2.5px solid #64748b;
    padding: 4px 8px;
    gap: 2px;
}
.matrix-row { display: flex; }
.matrix-val {
    display: inline-block;
    min-width: 2.4rem;
    text-align: right;
    padding: 1px 3px;
    font-size: .82rem;
}
.hill-block {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.matrix-display {
    display: inline-flex;
    flex-direction: column;
    border-left: 3px solid var(--c-indigo);
    border-right: 3px solid var(--c-indigo);
    padding: 8px 14px;
    border-radius: 2px;
    font-family: 'JetBrains Mono', monospace;
    gap: 4px;
}
.matrix-display.border-warning {
    border-color: #f59e0b;
}
.matrix-row-display { display: flex; gap: 4px; }
.matrix-cell {
    display: inline-block;
    min-width: 2.8rem;
    text-align: right;
    padding: 2px 4px;
    font-size: 1rem;
    font-weight: 700;
}

/* ================================================================
   VISUALIZATION — PLAYFAIR GRID
   ================================================================ */
.playfair-grid {
    display: inline-block;
}
.playfair-row { display: flex; }
.playfair-cell {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--c-cyan);
    border: 1px solid rgba(34,211,238,.20);
    border-radius: 6px;
    margin: 2px;
    background: rgba(34,211,238,.05);
    transition: background var(--t-fast), transform var(--t-fast);
    cursor: default;
}
.playfair-cell:hover {
    background: rgba(34,211,238,.18);
    transform: scale(1.1);
}
[data-bs-theme="light"] .playfair-cell {
    color: var(--c-indigo);
    border-color: rgba(99,102,241,.18);
    background: rgba(99,102,241,.05);
}
[data-bs-theme="light"] .playfair-cell:hover {
    background: rgba(99,102,241,.15);
}

/* ================================================================
   HISTORY TABLE
   ================================================================ */
.custom-table { background: transparent; }
.custom-table th {
    background: transparent;
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: .70rem;
    letter-spacing: .05em;
    white-space: nowrap;
}
.custom-table td {
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,.04);
    padding: .85rem .75rem;
    vertical-align: middle;
    transition: background var(--t-fast);
}
.custom-table tbody tr:hover td {
    background: rgba(255,255,255,.04);
}
[data-bs-theme="light"] .custom-table td {
    border-bottom-color: rgba(0,0,0,.04);
}
[data-bs-theme="light"] .custom-table tbody tr:hover td {
    background: rgba(99,102,241,.04);
}

/* ================================================================
   ANIMATIONS
   ================================================================ */
.result-reveal {
    animation: slide-up .45s cubic-bezier(.16,1,.3,1) both;
}
@keyframes slide-up {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   FLASH MESSAGES / TOAST
   ================================================================ */
.flash-container {
    position: fixed;
    top: calc(var(--nav-height) + 12px);
    right: 16px;
    z-index: 1060;
    width: min(360px, calc(100vw - 32px));
}

.ag-toast {
    position: fixed;
    top: calc(var(--nav-height) + 12px);
    right: 16px;
    z-index: 9999;
    background: rgba(12,12,20,.96);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(14px);
    box-shadow: 0 4px 24px rgba(0,0,0,.45);
    border: 1px solid;
    min-width: 200px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
    animation: toast-in .28s ease both;
    font-size: .88rem;
    font-weight: 500;
}
[data-bs-theme="light"] .ag-toast {
    background: rgba(255,255,255,.95);
    color: #1e293b;
    box-shadow: 0 4px 24px rgba(0,0,0,.15);
}
@keyframes toast-in  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateX(0); opacity: 1; }    to { transform: translateX(110%); opacity: 0; } }

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ================================================================
   SCROLLBAR
   ================================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }
[data-bs-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); }

/* ================================================================
   RESPONSIVE — MOBILE FIRST
   ================================================================ */

/* Small phones ≤ 360px */
@media (max-width: 360px) {
    .hero-title { font-size: 1.4rem; }
    .playfair-cell { width: 36px; height: 36px; font-size: .9rem; margin: 1px; }
    .matrix-input-cell { width: 46px; height: 46px; font-size: .82rem; }
    .matrix-cell { min-width: 2rem; font-size: .82rem; }
    .glass-card { border-radius: .75rem; }
}

/* Phones 360–575px */
@media (max-width: 575px) {
    body { font-size: .9rem; }

    .hero-title { font-size: 1.55rem; letter-spacing: -.03em; }
    .hero-subtitle { font-size: .82rem; }

    /* Stack form buttons vertically */
    #cryptoForm .d-flex.justify-content-end { justify-content: stretch !important; }
    #cryptoForm .d-flex.justify-content-end .btn { flex: 1; }

    /* Full-width mode buttons */
    .btn-group.w-100 .btn { font-size: .82rem; padding: .45rem .5rem; }

    /* Matrix cells smaller */
    .playfair-cell { width: 40px; height: 40px; font-size: .95rem; }
    .matrix-input-cell { width: 50px; height: 50px; }
    .matrix-val { min-width: 1.8rem; }

    /* Flash top snap full-width */
    .flash-container { right: 8px; left: 8px; width: auto; }
    .ag-toast { right: 8px; left: 8px; max-width: none; }

    /* History table horizontal scroll */
    .custom-table th,
    .custom-table td { padding: .55rem .5rem; font-size: .75rem; }

    /* Step detail table compact */
    .table-responsive table { font-size: .75rem; }

    /* Hill step visualization */
    .hill-block .d-flex { gap: .5rem !important; font-size: .72rem; }
    .matrix-display { padding: 5px 8px; }
    .matrix-cell { min-width: 2rem; font-size: .82rem; }
}

/* Tablets 576–767px */
@media (min-width: 576px) and (max-width: 767px) {
    .hero-title { font-size: 2rem; }
    .playfair-cell { width: 42px; height: 42px; }
}

/* Tablet / small laptop — disable card hover lift (touch device) */
@media (hover: none) {
    .glass-card:hover { transform: none; }
    .btn:hover:not(:disabled) { transform: none; }
    .playfair-cell:hover { transform: none; }
}

/* Larger screens ≥ 992px — slightly tighter spacing */
@media (min-width: 992px) {
    .hero-title { font-size: 2.7rem; }
}
