/* ============================================================
   SixPack Survey Management System
   Custom Styles
   Font: Bai Jamjuree | Primary: #2563EB | Secondary: #0F172A
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --primary:        #2563EB;
    --primary-dark:   #1D4ED8;
    --primary-light:  #DBEAFE;
    --secondary:      #0F172A;
    --success:        #10B981;
    --warning:        #F59E0B;
    --danger:         #EF4444;
    --info:           #06B6D4;

    --bg-body:        #F1F5F9;
    --bg-card:        #FFFFFF;
    --bg-sidebar:     #0F172A;

    --text-primary:   #1E293B;
    --text-muted:     #64748B;
    --text-light:     #94A3B8;

    --border-color:   #E2E8F0;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 12px rgba(0,0,0,.10);
    --shadow-lg:      0 10px 32px rgba(0,0,0,.14);

    --sidebar-width:  260px;
    --topbar-height:  64px;
    --radius:         8px;
    --radius-lg:      12px;
    --radius-xl:      16px;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: 'Bai Jamjuree', sans-serif;
    font-size:   14px;
    color:       var(--text-primary);
    background:  var(--bg-body);
    margin: 0; padding: 0;
}

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

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    position:        fixed;
    top: 0; left: 0;
    width:           var(--sidebar-width);
    height:          100vh;
    background:      var(--bg-sidebar);
    display:         flex;
    flex-direction:  column;
    z-index:         1040;
    transition:      transform .25s ease;
    overflow-y:      auto;
}

.sidebar-header {
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         20px 20px 16px;
    border-bottom:   1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.sidebar-logo {
    display:     flex;
    align-items: center;
    gap:         8px;
    font-size:   15px;
    font-weight: 700;
    color:       #fff;
    letter-spacing: .2px;
}
.sidebar-logo i { font-size: 20px; color: var(--primary); }

.btn-close-sidebar {
    background: none; border: none;
    color: rgba(255,255,255,.45); font-size: 18px; cursor: pointer; padding: 4px;
}
.btn-close-sidebar:hover { color: #fff; }

/* Sidebar Nav */
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-nav .nav { gap: 1px; }

.nav-section-label {
    font-size:      10px;
    font-weight:    700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color:          rgba(255,255,255,.3);
    padding:        14px 12px 4px;
}

.sidebar-nav .nav-link {
    display:     flex;
    align-items: center;
    gap:         10px;
    padding:     9px 12px;
    border-radius: var(--radius);
    color:       rgba(255,255,255,.6);
    font-size:   13.5px;
    font-weight: 500;
    transition:  all .18s ease;
}
.sidebar-nav .nav-link i { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,.4);
}

/* Sidebar Footer */
.sidebar-footer {
    padding:       14px 18px;
    border-top:    1px solid rgba(255,255,255,.08);
    display:       flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.sidebar-footer-link {
    display: flex; align-items: center;
    font-size: 13px; color: rgba(255,255,255,.45);
    transition: color .18s;
}
.sidebar-footer-link:hover { color: rgba(255,255,255,.85); }
.text-danger-soft { color: #FCA5A5 !important; }
.text-danger-soft:hover { color: #F87171 !important; }

/* Sidebar overlay */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 1039;
}
.sidebar-overlay.active { display: block; }

/* ── Main Wrapper ───────────────────────────────────────────── */
.main-wrapper {
    margin-left:    var(--sidebar-width);
    min-height:     100vh;
    display:        flex;
    flex-direction: column;
    transition:     margin-left .25s ease;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
    position:        sticky; top: 0;
    height:          var(--topbar-height);
    background:      var(--bg-card);
    border-bottom:   1px solid var(--border-color);
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    padding:         0 24px;
    z-index:         1030;
    box-shadow:      var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }

.btn-toggle-sidebar {
    background: none; border: none;
    font-size: 22px; color: var(--text-primary); cursor: pointer;
    padding: 4px 8px; border-radius: var(--radius);
}
.btn-toggle-sidebar:hover { background: var(--bg-body); }

.page-title {
    font-size: 18px; font-weight: 700;
    color: var(--text-primary); margin: 0; letter-spacing: -.2px;
}

.admin-badge {
    display:     flex;
    align-items: center;
    font-size:   13px;
    font-weight: 600;
    color:       var(--text-primary);
    background:  var(--bg-body);
    padding:     6px 14px;
    border-radius: 20px;
    border:      1px solid var(--border-color);
}

/* ── Page Content ───────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    border:        1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow:    var(--shadow-sm) !important;
    background:    var(--bg-card) !important;
}
.card-header {
    background:    var(--bg-card) !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding:       16px 20px !important;
    font-weight:   700;
    font-size:     14px;
    color:         var(--text-primary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    display: flex; align-items: center;
}
.card-body { padding: 20px !important; }

/* Stat Cards */
.stat-card {
    background:    var(--bg-card);
    border:        1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding:       20px;
    box-shadow:    var(--shadow-sm);
    transition:    box-shadow .2s, transform .2s;
    height: 100%;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; margin-bottom: 12px;
}
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-badge {
    font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 12px;
    margin-top: 8px; display: inline-block;
}

.icon-primary { background: #DBEAFE; color: var(--primary); }
.icon-success { background: #D1FAE5; color: var(--success); }
.icon-warning { background: #FEF3C7; color: var(--warning); }
.icon-info    { background: #CFFAFE; color: var(--info); }
.icon-danger  { background: #FEE2E2; color: var(--danger); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { font-family: 'Bai Jamjuree', sans-serif; font-weight: 600; border-radius: var(--radius); transition: all .18s ease; }
.btn-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.btn-primary:hover { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table { font-size: 14px; margin-bottom: 0; }
.table thead th {
    background:     #F8FAFC;
    font-weight:    700;
    font-size:      11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color:          var(--text-muted);
    border-color:   var(--border-color);
    padding:        11px 16px;
    white-space:    nowrap;
}
.table tbody td { padding: 13px 16px; border-color: var(--border-color); vertical-align: middle; }
.table tbody tr:hover td { background: #FAFBFC; }
.table-responsive { border-radius: var(--radius); border: 1px solid var(--border-color); overflow: hidden; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-control, .form-select {
    font-family:  'Bai Jamjuree', sans-serif;
    font-size:    14px;
    border-color: var(--border-color);
    border-radius: var(--radius);
    padding:      9px 13px;
    color:        var(--text-primary);
    transition:   border-color .18s, box-shadow .18s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow:   0 0 0 3px rgba(37,99,235,.12);
    outline:      none;
}
.form-label { font-weight: 600; font-size: 13px; color: var(--text-primary); margin-bottom: 5px; }
.form-text  { font-size: 12px; color: var(--text-muted); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { font-family: 'Bai Jamjuree', sans-serif; font-weight: 600; font-size: 11px; padding: 4px 8px; border-radius: 5px; }
.badge-industry { background: var(--primary-light); color: var(--primary); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { font-size: 14px; border-radius: var(--radius); border: none; font-weight: 500; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-danger  { background: #FEE2E2; color: #991B1B; }
.alert-info    { background: #DBEAFE; color: #1E40AF; }
.alert-warning { background: #FEF3C7; color: #92400E; }

/* ── Login Page ─────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0F172A 0%, #1E3A8A 60%, #2563EB 100%);
    padding: 24px;
}
.login-card {
    background: var(--bg-card); border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg); padding: 40px;
    width: 100%; max-width: 420px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo i { font-size: 42px; color: var(--primary); }
.login-logo h2 { font-size: 22px; font-weight: 700; color: var(--text-primary); margin: 8px 0 4px; }
.login-logo p { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ── Survey Form (Public) ───────────────────────────────────── */
.survey-wrapper {
    min-height: 100vh;
    background: linear-gradient(150deg, #EFF6FF 0%, #F0F9FF 50%, #F5F3FF 100%);
    padding: 32px 16px 48px;
}
.survey-header { text-align: center; margin-bottom: 32px; }
.survey-badge {
    display: inline-flex; align-items: center;
    background: var(--primary-light); color: var(--primary);
    font-size: 11px; font-weight: 700; padding: 5px 14px;
    border-radius: 20px; margin-bottom: 14px;
    text-transform: uppercase; letter-spacing: .9px;
}
.survey-header h1 { font-size: 28px; font-weight: 700; color: var(--secondary); margin-bottom: 8px; }
.survey-header p  { color: var(--text-muted); font-size: 15px; max-width: 580px; margin: 0 auto; line-height: 1.7; }

.survey-card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md); padding: 28px;
    margin-bottom: 20px; border: 1px solid var(--border-color);
    transition: box-shadow .2s;
}
.survey-card:hover { box-shadow: var(--shadow-lg); }

.question-label {
    font-size: 15px; font-weight: 600; color: var(--text-primary);
    display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; line-height: 1.5;
}
.question-number {
    display:         inline-flex;
    align-items:     center;
    justify-content: center;
    width: 28px; height: 28px; flex-shrink: 0;
    background:   var(--primary); color: #fff;
    border-radius: 50%; font-size: 13px; font-weight: 700;
}

.option-card {
    border:         2px solid var(--border-color);
    border-radius:  var(--radius);
    padding:        12px 16px;
    cursor:         pointer;
    transition:     all .18s ease;
    display:        flex;
    align-items:    center;
    gap:            12px;
    margin-bottom:  8px;
    user-select:    none;
}
.option-card:hover  { border-color: var(--primary); background: #EFF6FF; }
.option-card.selected { border-color: var(--primary); background: var(--primary-light); }
.option-card input[type="radio"] { accent-color: var(--primary); width: 17px; height: 17px; flex-shrink: 0; cursor: pointer; }
.option-text { font-size: 14px; font-weight: 500; }

.btn-submit-survey {
    background: var(--primary); color: #fff; border: none;
    padding: 13px 40px; font-size: 16px; font-weight: 700;
    border-radius: var(--radius); cursor: pointer;
    transition: all .2s ease; font-family: 'Bai Jamjuree', sans-serif;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn-submit-survey:hover { background: var(--primary-dark); box-shadow: 0 4px 16px rgba(37,99,235,.35); transform: translateY(-1px); }
.btn-submit-survey:active { transform: translateY(0); }

/* ── Thank You Page ─────────────────────────────────────────── */
.thankyou-wrapper {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: linear-gradient(150deg, #EFF6FF 0%, #F0F9FF 100%);
    padding: 32px 16px;
}
.thankyou-card {
    text-align: center; background: var(--bg-card);
    border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
    padding: 52px 40px; max-width: 500px; width: 100%;
}
.thankyou-icon {
    width: 80px; height: 80px; background: #D1FAE5;
    border-radius: 50%; display: flex;
    align-items: center; justify-content: center; margin: 0 auto 20px;
}
.thankyou-icon i { font-size: 40px; color: var(--success); }

/* ── Chart Containers ───────────────────────────────────────── */
.chart-container { position: relative; min-height: 280px; }

/* ── Insight Items ──────────────────────────────────────────── */
.insight-item {
    display: flex; align-items: center; gap: 14px;
    padding: 13px 0; border-bottom: 1px solid var(--border-color);
}
.insight-item:last-child { border-bottom: none; }
.insight-rank {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.rank-1     { background: #FEF3C7; color: #92400E; }
.rank-2     { background: #F3F4F6; color: #374151; }
.rank-3     { background: #FEE2E2; color: #991B1B; }
.rank-other { background: #F1F5F9; color: var(--text-muted); }
.insight-label { font-size: 14px; font-weight: 600; flex: 1; }
.insight-count { font-size: 13px; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.insight-bar-wrap { width: 80px; background: #E2E8F0; border-radius: 4px; height: 6px; overflow: hidden; }
.insight-bar-fill  { height: 100%; background: var(--primary); border-radius: 4px; transition: width 1s ease; }

/* ── Empty State ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state i { font-size: 48px; color: var(--text-light); display: block; margin-bottom: 12px; }
.empty-state h5 { font-size: 16px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.empty-state p  { font-size: 13px; color: var(--text-light); margin: 0; }

/* ── Question Builder ───────────────────────────────────────── */
.question-item {
    border: 1px solid var(--border-color); border-radius: var(--radius);
    padding: 15px 16px; margin-bottom: 10px; background: var(--bg-card);
    transition: box-shadow .18s;
}
.question-item:hover { box-shadow: var(--shadow-sm); }
.type-badge { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: .5px; }
.type-mc   { background: #DBEAFE; color: #1D4ED8; }
.type-text { background: #D1FAE5; color: #065F46; }

.options-preview { list-style: none; padding: 0; margin: 0; }
.options-preview li {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0; font-size: 12.5px; color: var(--text-muted);
}
.options-preview li::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

/* Dynamic options builder */
.option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.option-row .form-control { flex: 1; }
.btn-remove-option {
    background: none; border: none; color: var(--danger); cursor: pointer;
    padding: 6px 8px; border-radius: var(--radius); transition: background .18s; flex-shrink: 0;
}
.btn-remove-option:hover { background: #FEE2E2; }

/* ── Modal enhancements ─────────────────────────────────────── */
.modal-header { border-bottom: 1px solid var(--border-color); padding: 15px 20px; }
.modal-title  { font-size: 16px; font-weight: 700; }
.modal-body   { padding: 20px; }
.modal-footer { border-top: 1px solid var(--border-color); padding: 12px 20px; }

/* ── Search Box ─────────────────────────────────────────────── */
.search-box { position: relative; }
.search-box .form-control { padding-left: 36px; }
.search-box .bi-search { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; pointer-events: none; }

/* ── Response Detail ────────────────────────────────────────── */
.answer-item { padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.answer-item:last-child { border-bottom: none; }
.answer-q { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 3px; }
.answer-a { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* ── Utility ────────────────────────────────────────────────── */
.text-primary-custom { color: var(--primary) !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fs-13  { font-size: 13px !important; }
.fs-12  { font-size: 12px !important; }
.rounded-custom { border-radius: var(--radius) !important; }
.bg-light-custom { background: var(--bg-body) !important; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(calc(-1 * var(--sidebar-width))); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
}
@media (max-width: 575.98px) {
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .login-card { padding: 28px 20px; }
    .survey-card { padding: 20px 16px; }
    .page-title { font-size: 15px; }
    .stat-value { font-size: 22px; }
    .thankyou-card { padding: 36px 20px; }
}
