/* ============================================================
   Survey Tool – style.css
   Design: Clean Modern / Indigo Accent
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=DM+Mono:wght@400;500&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --primary:        #4f46e5;
    --primary-dark:   #3730a3;
    --primary-light:  #eef2ff;
    --success:        #059669;
    --success-light:  #d1fae5;
    --danger:         #dc2626;
    --danger-light:   #fee2e2;
    --warning:        #d97706;
    --warning-light:  #fef3c7;
    --gray-50:        #f8fafc;
    --gray-100:       #f1f5f9;
    --gray-200:       #e2e8f0;
    --gray-300:       #cbd5e1;
    --gray-400:       #94a3b8;
    --gray-500:       #64748b;
    --gray-600:       #475569;
    --gray-700:       #334155;
    --gray-800:       #1e293b;
    --gray-900:       #0f172a;
    --radius:         10px;
    --radius-sm:      6px;
    --radius-lg:      16px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
    --shadow:         0 4px 16px rgba(0,0,0,.08);
    --shadow-lg:      0 12px 40px rgba(0,0,0,.12);
    --nav-width:      240px;
    --font:           'DM Sans', system-ui, sans-serif;
    --font-mono:      'DM Mono', monospace;
    --transition:     0.2s ease;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.25; color: var(--gray-900); }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3;  color: var(--gray-800); margin-bottom: .75rem; }
h3 { font-size: 1.05rem; font-weight: 600; color: var(--gray-800); }

p  { margin-bottom: .5rem; }

.subtitle { font-size: .9rem; color: var(--gray-500); margin-top: .25rem; }
.muted    { color: var(--gray-400); font-size: .875rem; }
.required { color: var(--danger); font-weight: 600; margin-left: 2px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none !important;
    line-height: 1.4;
}
.btn:active { transform: scale(.97); }

.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-light); }

.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #047857; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; }

.btn-sm   { padding: .35rem .8rem; font-size: .8125rem; }
.btn-full { width: 100%; justify-content: center; padding: .75rem 1.5rem; font-size: 1rem; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .3rem .6rem;
    font-size: .75rem;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-icon:hover { background: #dde5ff; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: .9rem;
    border: 1.5px solid transparent;
}
.alert-success { background: var(--success-light); color: #065f46; border-color: #a7f3d0; }
.alert-error   { background: var(--danger-light);  color: #991b1b; border-color: #fca5a5; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fcd34d; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
}
.badge-active   { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--gray-100);      color: var(--gray-500); }
.badge-required { background: var(--danger-light);  color: var(--danger);   font-size: .7rem; }

.question-type-badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: .75rem;
    font-weight: 600;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1.1rem;
}
.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: .4rem;
}
.form-group-checkbox {
    display: flex;
    align-items: flex-end;
    padding-bottom: .25rem;
}
.form-group-checkbox label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 500;
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: .6rem .85rem;
    font-family: var(--font);
    font-size: .9rem;
    color: var(--gray-800);
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
textarea { resize: vertical; }

.form-actions {
    display: flex;
    gap: .75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1.5px solid var(--gray-100);
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}

/* ── ═══════════════ ADMIN LAYOUT ═══════════════ ── */
.admin-page {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Nav */
.admin-nav {
    width: var(--nav-width);
    min-height: 100vh;
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    font-weight: 700;
    font-size: 1.05rem;
}

.nav-links {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
}
.nav-links li a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem 1.25rem;
    color: rgba(255,255,255,.7);
    font-size: .9rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}
.nav-links li a:hover,
.nav-links li a.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left: 3px solid var(--primary);
    padding-left: calc(1.25rem - 3px);
}

.nav-footer {
    padding: 1rem 1.25rem 0;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .8rem;
    color: rgba(255,255,255,.5);
}
.nav-user {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: .5rem;
}
.btn-logout {
    color: rgba(255,255,255,.6);
    font-size: .8rem;
    text-decoration: none;
}
.btn-logout:hover { color: #fff; text-decoration: underline; }

/* Main content */
.admin-main {
    margin-left: var(--nav-width);
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1100px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
}
.header-actions { display: flex; gap: .5rem; align-items: center; }

@media (max-width: 960px) {
    .admin-nav { width: 200px; }
    .admin-main { margin-left: 200px; padding: 1.5rem; }
}
@media (max-width: 640px) {
    .admin-page { flex-direction: column; }
    .admin-nav  { width: 100%; min-height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: .75rem 1rem; }
    .admin-main { margin-left: 0; padding: 1rem; }
    .nav-brand  { padding-bottom: 0; border: none; }
    .nav-links  { display: flex; padding: 0; gap: .25rem; }
    .nav-links li a { padding: .4rem .75rem; border-left: none !important; }
    .nav-footer { display: none; }
}

/* ── Table ─────────────────────────────────────────────────── */
.table-wrapper {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.data-table thead th {
    background: var(--gray-50);
    padding: .85rem 1.1rem;
    text-align: left;
    font-size: .8rem;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1.5px solid var(--gray-200);
}
.data-table tbody td {
    padding: .95rem 1.1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }

.table-meta { display: flex; align-items: center; gap: .4rem; margin-top: .25rem; }
.token-preview { font-family: var(--font-mono); font-size: .75rem; color: var(--gray-400); }

.action-btns { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3.5rem 2rem;
    color: var(--gray-400);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.empty-state.small { padding: 1.5rem; }
.empty-state p { margin: 0; }

/* ── Questions Admin ───────────────────────────────────────── */
.questions-list { margin-bottom: 1.5rem; }

.question-card {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: .75rem;
    position: relative;
}
.question-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}
.question-num {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.question-text { font-weight: 500; color: var(--gray-800); margin-bottom: .5rem; }

.option-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: .5rem;
}
.option-list li {
    background: var(--gray-100);
    padding: .2rem .65rem;
    border-radius: 20px;
    font-size: .8rem;
    color: var(--gray-600);
}

.delete-form { position: absolute; top: 1rem; right: 1rem; }

/* Options builder */
.option-input-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-bottom: .5rem;
}
.option-input-row input { flex: 1; }

.btn-remove-option {
    background: none;
    border: none;
    color: var(--gray-400);
    font-size: 1rem;
    cursor: pointer;
    padding: .25rem .4rem;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
    flex-shrink: 0;
}
.btn-remove-option:hover { color: var(--danger); background: var(--danger-light); }

/* ── Link Box ──────────────────────────────────────────────── */
.link-box label { font-size: .8rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: .5rem; }
.link-row { display: flex; gap: .5rem; }
.link-row input { font-family: var(--font-mono); font-size: .8rem; flex: 1; background: var(--gray-50); }

/* ── Stats Row ─────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}
.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: .4rem;
}
.stat-label { font-size: .8rem; color: var(--gray-500); font-weight: 500; }
@media (max-width: 640px) { .stats-row { grid-template-columns: 1fr; } }

/* ── Result Cards ──────────────────────────────────────────── */
.result-card {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.result-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: .75rem;
    flex-wrap: wrap;
}
.result-header h3 { flex: 1; margin: 0; }
.result-note { font-size: .8rem; color: var(--gray-400); margin-top: .75rem; }

/* Bar chart */
.bar-chart { margin-top: .75rem; }
.bar-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .55rem;
    font-size: .875rem;
}
.bar-label { width: 160px; flex-shrink: 0; color: var(--gray-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 20px; background: var(--gray-100); border-radius: 10px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--primary); border-radius: 10px; transition: width .5s ease; }
.bar-count { width: 80px; flex-shrink: 0; font-weight: 600; color: var(--gray-700); }
.bar-count small { color: var(--gray-400); font-weight: 400; }

/* Text answers */
.text-answers { list-style: none; }
.text-answers li {
    padding: .75rem 1rem;
    border-left: 3px solid var(--primary-light);
    background: var(--gray-50);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: .5rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: .9rem;
}
.answer-text { flex: 1; }
.answer-meta { font-size: .75rem; color: var(--gray-400); flex-shrink: 0; }

/* ── ══════════════ LOGIN PAGE ══════════════ ── */
.login-page {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 1.75rem;
    color: var(--gray-800);
}

.login-container h1 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ── ══════════════ SURVEY PAGE ══════════════ ── */
.survey-page {
    background: var(--gray-50);
    padding: 2rem 1rem;
}

.survey-container {
    max-width: 720px;
    margin: 0 auto;
}

.survey-header {
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
}
.survey-header svg { margin: 0 auto .75rem; }
.survey-header h1 { color: #fff; font-size: 1.6rem; }
.survey-desc { color: rgba(255,255,255,.85); margin-top: .5rem; }
.survey-meta { color: rgba(255,255,255,.65); font-size: .8rem; margin-top: .5rem; }

/* Question blocks */
.question-block {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.question-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
    display: flex;
    gap: .5rem;
    align-items: flex-start;
    white-space: pre-line;
    line-height: 1.7;
}
.q-num {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.options-group { display: flex; flex-direction: column; gap: .5rem; }
.option-label {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .65rem .9rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-weight: 500;
    font-size: .9rem;
}
.option-label:hover { border-color: var(--primary); background: var(--primary-light); }
.option-label input { flex-shrink: 0; accent-color: var(--primary); }

.survey-input, .survey-textarea, .survey-select {
    width: 100%;
    padding: .65rem .9rem;
    font-family: var(--font);
    font-size: .9rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.survey-input:focus, .survey-textarea:focus, .survey-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.survey-textarea { resize: vertical; }

/* Privacy block */
.privacy-block {
    background: #fff;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.privacy-label {
    display: flex;
    gap: .75rem;
    cursor: pointer;
    font-size: .9rem;
    align-items: flex-start;
}
.privacy-label input { flex-shrink: 0; accent-color: var(--primary); margin-top: .25rem; }

/* ── Content Page ──────────────────────────────────────────── */
.content-page { padding: 2rem 1rem; }
.content-container {
    max-width: 760px;
    margin: 0 auto;
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow);
}
.content-container h2 { margin: 1.5rem 0 .5rem; }
.content-container ul { padding-left: 1.5rem; margin-bottom: 1rem; }
.content-container li { margin-bottom: .35rem; }
.back-link { display: inline-block; margin-bottom: 1.5rem; font-size: .875rem; }

/* ── Landing Page ──────────────────────────────────────────── */
.landing-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
}
.landing-container {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 480px;
}
.landing-logo { margin: 0 auto 1.5rem; }
.landing-container h1 { margin-bottom: .75rem; }
.landing-container p { color: var(--gray-500); margin-bottom: 2rem; }

/* ── Toast notification ────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--gray-900);
    color: #fff;
    padding: .75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: all .25s ease;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Selected option highlight ─────────────────────────────── */
.option-label.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

/* ── Field error highlight ─────────────────────────────────── */
.field-error {
    border: 1.5px solid var(--danger) !important;
    border-radius: var(--radius);
}
.section-title-block {
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
}
.section-title-block h3 {
    color: #fff;
    font-size: 1.05rem;
    margin: 0;
}