/* =============================================
   Centralized Survey Platform - Premium Red Theme
   ธีมแดงหรูหรา + ฟอนต์ไทยคมชัด
   ============================================= */

/* --- Google Fonts: Noto Sans Thai (คมชัดทุกขนาด) + Sarabun fallback --- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700;800;900&family=Sarabun:wght@300;400;500;600;700;800&display=swap');

/* TH Sarabun New จากเครื่อง (fallback) */
@font-face {
    font-family: 'TH Sarabun New';
    src: local('TH Sarabun New'), local('THSarabunNew');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: 'TH Sarabun New';
    src: local('TH Sarabun New Bold'), local('THSarabunNew-Bold');
    font-weight: bold;
    font-style: normal;
}

/* --- CSS Variables: Luxury Red Palette --- */
:root {
    /* แดงหลัก - โทนหรูหรา */
    --primary: #C62828;
    --primary-dark: #8E0000;
    --primary-light: #FFEBEE;
    --primary-glow: rgba(198, 40, 40, 0.15);

    /* ทอง - accent หรูหรา */
    --gold: #D4A843;
    --gold-light: #FFF8E7;
    --gold-dark: #B8860B;

    /* สีรอง */
    --secondary: #FF5252;
    --success: #2E7D32;
    --success-light: #E8F5E9;
    --warning: #F9A825;
    --warning-light: #FFF8E1;
    --danger: #D32F2F;
    --info: #1565C0;
    --info-light: #E3F2FD;

    /* พื้นหลัง */
    --bg-main: #FAFAFA;
    --bg-card: #FFFFFF;
    --bg-dark: #1A1A2E;

    /* ข้อความ */
    --text-primary: #212121;
    --text-secondary: #616161;
    --text-muted: #9E9E9E;
    --text-on-primary: #FFFFFF;

    /* เส้นขอบ */
    --border: #E0E0E0;
    --border-light: #F5F5F5;
    --border-focus: var(--primary);

    /* เงา */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    --shadow-red: 0 4px 20px rgba(198, 40, 40, 0.25);

    /* ขอบมน */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* ฟอนต์: Noto Sans Thai อ่านง่าย คมชัด */
    --font-main: 'Noto Sans Thai', 'TH Sarabun New', 'Sarabun', sans-serif;
    --font-heading: 'Noto Sans Thai', 'TH Sarabun New', sans-serif;
}

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

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

body {
    font-family: var(--font-main);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.3;
}

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

::selection {
    background: var(--primary);
    color: #fff;
}

/* --- Layout --- */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* --- Card Component (Premium) --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 28px 32px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    transition: box-shadow 0.3s, transform 0.3s;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 32px 32px 24px;
    margin: -28px -32px 24px;
    position: relative;
}

.card-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 32px;
    right: 32px;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--gold-dark));
    border-radius: 2px;
}

.card-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.card-header p {
    font-size: 1rem;
    opacity: 0.85;
    font-weight: 300;
}

/* --- Accent Bar (แถบทอง-แดง) --- */
.accent-bar {
    height: 8px;
    background: linear-gradient(90deg, var(--primary), var(--gold), var(--primary));
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    margin: -28px -32px 24px;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.form-group label .required {
    color: var(--danger);
    margin-left: 4px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    color: var(--text-primary);
    background: #FAFAFA;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.25s ease;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: #fff;
}

.form-control::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23616161' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* --- Radio & Checkbox Premium Style --- */
.option-group {
    padding: 4px 0;
}

.option-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 6px;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

.option-item:hover {
    background: var(--primary-light);
    border-color: rgba(198, 40, 40, 0.15);
}

.option-item input[type="radio"],
.option-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 14px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.option-item label {
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 0;
    font-weight: 400;
    flex: 1;
}

/* --- Question Number Badge --- */
.q-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 700;
    margin-right: 10px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
}

.question-title {
    display: flex;
    align-items: flex-start;
    margin-bottom: 16px;
}

.question-title .q-text {
    font-size: 1.05rem;
    font-weight: 600;
    padding-top: 4px;
}

/* --- Buttons (Premium) --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #D32F2F 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: var(--shadow-red);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #1B5E20 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.3);
}
.btn-success:hover {
    box-shadow: 0 4px 16px rgba(46, 125, 50, 0.35);
    color: #fff;
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, #E53935 0%, #C62828 100%);
    color: #fff;
}
.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.35);
    color: #fff;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-red);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(212, 168, 67, 0.35);
}
.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(212, 168, 67, 0.45);
    color: #fff;
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 13px 32px;
    font-size: 1.05rem;
}

.btn-block {
    width: 100%;
}

/* --- Navbar (Premium Dark Top) --- */
.navbar {
    background: linear-gradient(135deg, #1A1A2E 0%, #2D1B3D 50%, #1A1A2E 100%);
    border-bottom: 3px solid var(--primary);
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 16px rgba(0,0,0,0.2);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.02em;
}

.navbar-brand svg {
    width: 26px;
    height: 26px;
    stroke: var(--gold);
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
}

.navbar-menu a {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.2s;
}

.navbar-menu a:hover {
    background: rgba(198, 40, 40, 0.2);
    color: #fff;
}

.navbar-menu a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(198, 40, 40, 0.4);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.85);
    font-size: 0.92rem;
}

.navbar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
}

.navbar-user .btn-outline {
    border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.8);
    font-size: 0.82rem;
    padding: 5px 12px;
}

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

/* --- Table (Premium) --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

table th {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    font-size: 0.88rem;
    letter-spacing: 0.02em;
}

table th:first-child { border-radius: var(--radius-md) 0 0 0; }
table th:last-child { border-radius: 0 var(--radius-md) 0 0; }

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

table tr:hover td {
    background: var(--primary-light);
}

table tr:last-child td {
    border-bottom: none;
}

/* --- Badge (Premium) --- */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-active {
    background: var(--success-light);
    color: var(--success);
}

.badge-inactive {
    background: #FFEBEE;
    color: #C62828;
}

/* --- Alert (Premium) --- */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.92rem;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border-color: var(--success);
}

.alert-danger {
    background: #FFEBEE;
    color: #C62828;
    border-color: var(--danger);
}

.alert-info {
    background: var(--info-light);
    color: var(--info);
    border-color: var(--info);
}

/* --- Stats Cards (Dashboard Premium) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--gold));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-number {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 6px;
    font-weight: 500;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.4rem;
}

/* --- Thank You Page --- */
.thank-you {
    text-align: center;
    padding: 60px 20px;
}

.thank-you .checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success) 0%, #1B5E20 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 2.5rem;
    box-shadow: 0 4px 20px rgba(46, 125, 50, 0.3);
}

.thank-you h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.thank-you p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* --- Login Page (Luxury Red) --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(198, 40, 40, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(212, 168, 67, 0.1) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 100%, rgba(198, 40, 40, 0.08) 0%, transparent 50%),
        linear-gradient(160deg, #1A1A2E 0%, #16213E 40%, #0F3460 70%, #1A1A2E 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 100px,
        rgba(198, 40, 40, 0.02) 100px,
        rgba(198, 40, 40, 0.02) 200px
    );
    animation: subtle-shift 30s linear infinite;
}

@keyframes subtle-shift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(100px, 100px); }
}

.login-card {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    z-index: 1;
    border-top: 4px solid var(--primary);
}

.login-card h1 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-card .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
    font-weight: 400;
}

.login-card .logo-icon {
    width: 68px;
    height: 68px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 2rem;
    box-shadow: 0 4px 20px rgba(198, 40, 40, 0.35);
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-top: 4px solid var(--primary);
}

.modal-content h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* --- Share Link (Premium) --- */
.share-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #FAFAFA;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    transition: border-color 0.2s;
}

.share-box:focus-within {
    border-color: var(--primary);
}

.share-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-main);
    font-size: 0.82rem;
    color: var(--text-primary);
    outline: none;
}

.share-box .btn-copy {
    padding: 5px 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.share-box .btn-copy:hover {
    box-shadow: var(--shadow-red);
}

/* --- Chart Container --- */
.chart-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 20px auto;
}

/* --- Page Heading Style --- */
.page-heading {
    margin-bottom: 24px;
}

.page-heading h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 2px;
    letter-spacing: -0.02em;
}

.page-heading p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 400;
}

/* --- Divider with Gold --- */
.divider-gold {
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--gold), var(--primary));
    border: none;
    margin: 20px 0;
    border-radius: 2px;
    opacity: 0.4;
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.text-gold { color: var(--gold); }
.text-red { color: var(--primary); }

/* --- Mobile Menu Toggle --- */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    padding: 4px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .container { padding: 12px; }

    .card {
        padding: 20px;
        margin-bottom: 12px;
    }

    .card-header {
        padding: 24px 20px 20px;
        margin: -20px -20px 20px;
    }

    .card-header::after {
        left: 20px;
        right: 20px;
    }

    .accent-bar {
        margin: -20px -20px 20px;
    }

    .card-header h1 { font-size: 1.3rem; }

    .navbar {
        padding: 0 16px;
    }

    .menu-toggle {
        display: block;
    }

    .navbar-menu {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: #1A1A2E;
        flex-direction: column;
        padding: 12px;
        border-bottom: 3px solid var(--primary);
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    }

    .navbar-menu.open {
        display: flex;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-number {
        font-size: 1.8rem;
    }

    .login-card {
        padding: 32px 24px;
    }

    table {
        font-size: 0.85rem;
    }

    table th, table td {
        padding: 10px 12px;
    }

    .btn {
        padding: 9px 18px;
        font-size: 0.88rem;
    }

    .modal-content {
        padding: 24px 20px;
        width: 95%;
    }

    .page-heading h1 {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .share-box {
        flex-direction: column;
    }

    .share-box input {
        width: 100%;
        text-align: center;
    }
}

/* --- Scrollbar (Premium) --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #F5F5F5;
}

::-webkit-scrollbar-thumb {
    background: #BDBDBD;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}
