@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

/*
  Premium military-academic UI system
  Palette (STRICT):
  - Background: #FFFDF1
  - Soft:       #FFCE99
  - Accent:     #FF9644
  - Dark:       #562F00
*/

:root {
    --bg: #FFFDF1;
    --soft: #FFCE99;
    --accent: #FF9644;
    --dark: #562F00;
    --white: #ffffff;

    --border: rgba(255, 206, 153, 0.65);
    --border-strong: rgba(255, 206, 153, 0.95);

    --shadow-sm: 0 10px 25px rgba(86, 47, 0, 0.08);
    --shadow-md: 0 16px 45px rgba(86, 47, 0, 0.12);
    --shadow-lg: 0 22px 70px rgba(86, 47, 0, 0.16);

    --radius-sm: 12px;
    --radius-md: 14px;
    --radius-lg: 16px;

    --transition: 0.3s ease;

    /* Contextual feedback (minimal extra colors; used only where required) */
    --success: #1f9d55;
    --danger: #d6453d;

    /* Backwards-compatible aliases (so existing PHP inline styles/JS don't break) */
    --primary-color: var(--dark);
    --secondary-color: var(--dark);
    --accent-navy: var(--dark);
    --accent-green: var(--dark);
    --danger-red: var(--danger);
    --warning-yellow: var(--accent);
    --light-gray: rgba(255, 206, 153, 0.35);
    --dark-gray: rgba(86, 47, 0, 0.65);
    --shadow: var(--shadow-sm);
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
    min-height: 100%;
    margin: 0;
    font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background: var(--bg);
    overflow-x: hidden;
}

a { color: inherit; }

.container {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 18px;
}

/* Type scale */
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(24px, 3.2vw, 34px); font-weight: 700; }
h2 { font-size: clamp(18px, 2.2vw, 24px); font-weight: 700; margin-top: 22px; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0.45rem 0 0; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
    user-select: none;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 3px solid rgba(255, 150, 68, 0.35); outline-offset: 2px; }

.btn-primary,
.btn-success {
    background: var(--accent);
    color: var(--dark);
    box-shadow: 0 10px 18px rgba(255, 150, 68, 0.25);
}
.btn-primary:hover,
.btn-success:hover {
    transform: translateY(-2px);
    filter: brightness(0.95);
    box-shadow: 0 16px 30px rgba(255, 150, 68, 0.32);
}

.btn-secondary {
    background: rgba(255, 206, 153, 0.18);
    color: var(--dark);
    border-color: var(--border);
}
.btn-secondary:hover {
    transform: translateY(-2px);
    background: rgba(255, 206, 153, 0.32);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.btn-danger {
    background: rgba(214, 69, 61, 0.12);
    color: var(--dark);
    border-color: rgba(214, 69, 61, 0.35);
}
.btn-danger:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

.btn-sm { padding: 8px 10px; font-size: 12px; border-radius: 10px; }
.btn-block { width: 100%; }

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

/* Stats (User/Admin shared) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stat-card h3 {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(86, 47, 0, 0.65);
}
.stat-number { margin: 10px 0 0; font-size: 30px; font-weight: 800; }

.subscription-card {
    background:
        radial-gradient(620px 240px at 15% 20%, rgba(255, 150, 68, 0.26), transparent 58%),
        radial-gradient(520px 220px at 85% 65%, rgba(255, 206, 153, 0.65), transparent 62%),
        linear-gradient(180deg, rgba(86, 47, 0, 0.92), rgba(86, 47, 0, 0.82));
    color: rgba(255, 253, 241, 0.95);
    border-color: rgba(255, 206, 153, 0.22);
}
.subscription-card h3 { color: rgba(255, 253, 241, 0.96); }
.subscription-card p { color: rgba(255, 253, 241, 0.88); }

/* Tables */
.table-container {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--white);
    box-shadow: var(--shadow-sm);
    margin: 18px 0 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 253, 241, 0.92);
    background: var(--dark);
    padding: 14px 14px;
}

td {
    padding: 14px 14px;
    border-top: 1px solid rgba(255, 206, 153, 0.55);
    vertical-align: top;
}

tbody tr:nth-child(odd) td { background: rgba(255, 206, 153, 0.12); }
tbody tr:hover td { background: rgba(255, 150, 68, 0.12); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}
.badge-pending {
    background: rgba(255, 150, 68, 0.18);
    border-color: rgba(255, 150, 68, 0.45);
    color: var(--dark);
}
.badge-approved {
    background: rgba(86, 47, 0, 0.12);
    border-color: rgba(86, 47, 0, 0.3);
    color: var(--dark);
}
.badge-rejected {
    background: rgba(255, 206, 153, 0.32);
    border-color: rgba(255, 206, 153, 0.75);
    color: var(--dark);
}

/* Alerts (avoid inline styles) */
.alert {
    border-radius: var(--radius-md);
    padding: 12px 14px;
    border: 1px solid var(--border);
    background: rgba(255, 206, 153, 0.18);
    color: var(--dark);
    box-shadow: var(--shadow-sm);
    margin: 0 0 16px;
}
.alert-danger { border-color: rgba(214, 69, 61, 0.35); background: rgba(214, 69, 61, 0.10); }
.alert-success { border-color: rgba(86, 47, 0, 0.25); background: rgba(86, 47, 0, 0.06); }
.alert-warning { border-color: rgba(255, 150, 68, 0.45); background: rgba(255, 150, 68, 0.12); }

/* Form controls */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin: 0 0 8px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(255, 253, 241, 0.75);
    color: var(--dark);
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: rgba(255, 150, 68, 0.9);
    box-shadow: 0 0 0 4px rgba(255, 150, 68, 0.18);
    background: rgba(255, 253, 241, 0.95);
}
.form-control.error { border-color: rgba(214, 69, 61, 0.55); }

/* Floating labels (opt-in via .form-floating wrapper) */
.form-floating {
    position: relative;
    margin-bottom: 16px;
}
.form-floating .form-control {
    padding: 18px 14px 10px;
}
.form-floating label {
    position: absolute;
    left: 14px;
    top: 13px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: rgba(86, 47, 0, 0.72);
    pointer-events: none;
    transform-origin: left top;
    transition: transform var(--transition), top var(--transition), opacity var(--transition);
}
.form-floating .form-control::placeholder { color: transparent; }
.form-floating .form-control:focus + label,
.form-floating .form-control:not(:placeholder-shown) + label {
    top: 6px;
    transform: scale(0.86);
    opacity: 0.95;
}

/* Wizard (Register) */
.wizard-steps {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0 18px;
}

.wizard-step {
    position: relative;
    padding: 12px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: rgba(86, 47, 0, 0.75);
}

.step-number {
    width: 30px;
    height: 30px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(255, 206, 153, 0.25);
    border: 1px solid rgba(255, 206, 153, 0.6);
    color: var(--dark);
    font-weight: 800;
}

.wizard-step.active {
    border-color: rgba(255, 150, 68, 0.8);
    background: rgba(255, 150, 68, 0.16);
}
.wizard-step.active .step-number {
    background: rgba(255, 150, 68, 0.95);
    border-color: rgba(255, 150, 68, 0.95);
}

.wizard-step.completed {
    border-color: rgba(86, 47, 0, 0.35);
    background: rgba(86, 47, 0, 0.06);
}
.wizard-step.completed .step-number {
    background: rgba(86, 47, 0, 0.14);
    border-color: rgba(86, 47, 0, 0.25);
}

/* Payment */
.payment-methods {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.payment-method {
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-sm);
    padding: 14px;
    text-align: center;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.payment-method:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}
.payment-method img {
    width: 68px;
    height: 68px;
    object-fit: contain;
    margin-bottom: 8px;
    filter: drop-shadow(0 10px 18px rgba(86, 47, 0, 0.12));
}
.payment-method h4 { margin: 0; font-size: 14px; }

.payment-number {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 206, 153, 0.65);
    background: rgba(255, 206, 153, 0.18);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--dark);
}

.note-section {
    border-radius: 18px;
    border: 1px solid rgba(255, 150, 68, 0.45);
    background: rgba(255, 150, 68, 0.12);
    padding: 12px 14px;
    color: rgba(86, 47, 0, 0.85);
}

.upload-dropzone {
    border-radius: 18px;
    border: 1.5px dashed rgba(255, 150, 68, 0.75);
    background: rgba(255, 150, 68, 0.08);
    padding: 14px;
    display: grid;
    gap: 8px;
    place-items: center;
    text-align: center;
}
.upload-dropzone strong { font-size: 13px; }
.upload-dropzone small { color: rgba(86, 47, 0, 0.7); }

.success-message {
    text-align: center;
    padding: 16px 0;
}
.success-message h2 { margin: 0; }
.success-message p { color: rgba(86, 47, 0, 0.75); }

/* Auth layout (split screen + glass card) */
.auth-container {
    min-height: 100vh;
    padding: 24px 18px;
    display: grid;
    place-items: center;
    background:
        radial-gradient(900px 520px at 15% 20%, rgba(255, 150, 68, 0.28), transparent 60%),
        radial-gradient(700px 420px at 80% 30%, rgba(255, 206, 153, 0.55), transparent 62%),
        linear-gradient(180deg, var(--bg), var(--bg));
}

.auth-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 18px;
    align-items: stretch;
}

.auth-panel {
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
}

.auth-left {
    padding: 26px 22px;
    background:
        radial-gradient(900px 520px at 20% 25%, rgba(255, 206, 153, 0.65), transparent 62%),
        radial-gradient(800px 460px at 75% 65%, rgba(255, 150, 68, 0.35), transparent 55%),
        linear-gradient(180deg, rgba(255, 253, 241, 0.9), rgba(255, 253, 241, 0.6));
}

.auth-right {
    padding: 26px 22px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.auth-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--dark);
    position: relative;
    box-shadow: 0 16px 35px rgba(86, 47, 0, 0.22);
}
.auth-mark:after {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 10px;
    background: var(--accent);
    opacity: 0.95;
}
.auth-brand h1 { font-size: 22px; }
.auth-subtitle { margin-top: 10px; color: rgba(86, 47, 0, 0.75); }

/* Backwards-compatible auth-card (if still used) */
.auth-card { background: transparent; box-shadow: none; border-radius: 0; overflow: visible; width: 100%; max-width: none; }
.auth-header { display: none; }
.auth-body { padding: 0; }

/* User navigation */
.dashboard-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--dark);
    color: rgba(255, 253, 241, 0.95);
    border-bottom: 1px solid rgba(255, 206, 153, 0.28);
}
.dashboard-nav .nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
}

.nav-brand {
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 12px;
    color: rgba(255, 253, 241, 0.92);
}
.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 206, 153, 0.35);
    color: rgba(255, 253, 241, 0.95);
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    width: 44px;
    height: 44px;
}

.nav-toggle .bars {
    width: 18px;
    height: 12px;
    position: relative;
    margin: 0 auto;
}
.nav-toggle .bars span {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 253, 241, 0.95);
    transition: transform var(--transition), top var(--transition), opacity var(--transition);
}
.nav-toggle .bars span:nth-child(1) { top: 0; }
.nav-toggle .bars span:nth-child(2) { top: 5px; }
.nav-toggle .bars span:nth-child(3) { top: 10px; }

body.nav-open .nav-toggle .bars span:nth-child(1) { top: 5px; transform: rotate(45deg); }
body.nav-open .nav-toggle .bars span:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle .bars span:nth-child(3) { top: 5px; transform: rotate(-45deg); }
.dashboard-nav ul {
    list-style: none;
    display: flex;
    gap: 10px;
    margin: 0;
    padding: 0;
    align-items: center;
}
.dashboard-nav a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: rgba(255, 253, 241, 0.92);
    transition: background var(--transition), transform var(--transition);
}
.dashboard-nav a:hover { background: rgba(255, 150, 68, 0.16); }
.dashboard-nav a.active {
    background: rgba(255, 150, 68, 0.95);
    color: var(--dark);
}

/* Dashboard header */
.dashboard-header {
    margin: 18px 0 0;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.dashboard-header p { color: rgba(86, 47, 0, 0.75); }

/* Test UI */
.test-container { max-width: 920px; margin: 22px auto; }
.test-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.test-progress { font-weight: 700; color: rgba(86, 47, 0, 0.72); }
.test-progressbar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 206, 153, 0.35);
    overflow: hidden;
    border: 1px solid rgba(255, 206, 153, 0.55);
}
.test-progressbar > span {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.question-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 22px;
    box-shadow: var(--shadow-md);
}
.question-number { color: rgba(86, 47, 0, 0.65); font-weight: 700; }
.question-text { font-size: 18px; font-weight: 600; margin-top: 10px; }
.options-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; }
.option-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 14px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 253, 241, 0.75);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
}
.option-label:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--border-strong);
}
.option-label.selected {
    background: rgba(255, 150, 68, 0.22);
    border-color: rgba(255, 150, 68, 0.75);
}
.option-label.correct {
    background: rgba(31, 157, 85, 0.14);
    border-color: rgba(31, 157, 85, 0.45);
}
.option-label.incorrect {
    background: rgba(214, 69, 61, 0.12);
    border-color: rgba(214, 69, 61, 0.45);
}

.test-controls {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 14px;
}

.loading { padding: 12px; color: rgba(86, 47, 0, 0.72); }

.results-card {
    text-align: center;
    padding: 10px 0 0;
}
.results-score {
    font-size: 44px;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-top: 14px;
}
.results-meta {
    margin-top: 8px;
    display: inline-flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}
.results-pill {
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 206, 153, 0.18);
    font-weight: 800;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Responsive */
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-left { display: none; }
}

@media (max-width: 768px) {
    .nav-toggle { display: inline-flex; }
    .dashboard-nav ul {
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 12px 0;
    }
    body.nav-open .dashboard-nav ul { display: flex; }
    .btn { width: 100%; }
    .test-controls { flex-direction: column; }
    .card-grid { grid-template-columns: 1fr; }
    .table-container { overflow-x: auto; }
}