/* ============================================
   DII GEN 7 x GEN 8 - Main Stylesheet
   Inspired by CAMT CMU Design
   ============================================ */

:root {
    --primary: #003F6B;
    --primary-light: #005A9C;
    --secondary: #0066CC;
    --accent: #C9A227;
    --accent-light: #E8C547;
    --bg: #F4F6F9;
    --card-bg: #FFFFFF;
    --text-dark: #1A2540;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --success: #28a745;
    --warning: #ffc107;
    --danger: #dc3545;
    --shadow-sm: 0 2px 8px rgba(0,63,107,0.08);
    --shadow-md: 0 4px 20px rgba(0,63,107,0.12);
    --shadow-lg: 0 8px 40px rgba(0,63,107,0.18);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Sarabun', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    min-height: 100vh;
}

/* ============ HEADER ============ */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 60%, var(--secondary) 100%);
    box-shadow: 0 4px 20px rgba(0,63,107,0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.site-header .brand {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-main {
    font-size: 1.3rem;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--accent-light);
    font-weight: 400;
    letter-spacing: 1px;
}

.header-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    color: rgba(255,255,255,0.85);
    transition: all var(--transition);
    border: 1.5px solid transparent;
    font-family: 'Sarabun', sans-serif;
}

.nav-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.nav-btn.active {
    background: var(--accent);
    color: var(--primary);
    font-weight: 700;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(201,162,39,0.4);
}

/* ============ LAYOUT ============ */
.main-layout {
    display: flex;
    min-height: calc(100vh - 68px);
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: 300px;
    min-width: 280px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,63,107,0.06);
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg);
}

.sidebar-title i {
    color: var(--accent);
}

/* ============ AUTOCOMPLETE ============ */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}

.autocomplete-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.15);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 999;
    max-height: 240px;
    overflow-y: auto;
    display: none;
    margin-top: 4px;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background var(--transition);
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #EEF4FF;
    color: var(--primary);
}

.autocomplete-item .nickname {
    font-weight: 600;
    color: var(--primary);
}

.autocomplete-item .fullname {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ============ JUNIOR CARD (SIDEBAR) ============ */
.junior-info-card {
    background: linear-gradient(135deg, #EEF4FF 0%, #F8FAFF 100%);
    border: 1px solid rgba(0,102,204,0.15);
    border-radius: var(--radius);
    padding: 16px;
    display: none;
}

.junior-info-card.show {
    display: block;
}

.junior-info-card .j-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.junior-info-card .j-fullname {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============ STATUS BADGES ============ */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-waiting {
    background: #FFF3CD;
    color: #856404;
    border: 1px solid #FFECB5;
}

.status-drawn {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

/* ============ BUTTONS ============ */
.btn-random {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-family: 'Sarabun', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: all var(--transition);
    box-shadow: 0 4px 15px rgba(0,63,107,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-random:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,63,107,0.4);
}

.btn-random:active:not(:disabled) {
    transform: translateY(0);
}

.btn-random:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-login-danger {
    background: linear-gradient(135deg, #dc3545 0%, #b02a37 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 12px 28px;
    font-family: 'Sarabun', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 15px rgba(220,53,69,0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.btn-login-danger:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(220,53,69,0.4);
}

.btn-login-danger:active:not(:disabled) {
    transform: translateY(0);
}

.btn-login-danger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    color: var(--primary);
    border: none;
    padding: 10px 24px;
    border-radius: 50px;
    font-family: 'Sarabun', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 12px rgba(201,162,39,0.3);
}

.btn-accent:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(201,162,39,0.45);
}

.btn-accent:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============ MAIN CONTENT AREA ============ */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* ============ WELCOME BANNER ============ */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius);
    padding: 48px 40px;
    text-align: center;
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.welcome-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    border-radius: 50%;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(201,162,39,0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.welcome-banner h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.welcome-banner p {
    font-size: 1.1rem;
    opacity: 0.9;
    position: relative;
    z-index: 1;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.7;
}

.welcome-accent {
    color: var(--accent-light);
    font-weight: 700;
}

/* ============ FLIP CARDS ============ */
.draw-title {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.35rem;
    margin-bottom: 8px;
}

.draw-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0 auto;
    max-width: 520px;
    line-height: 1.6;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(250px, 290px));
    gap: 28px;
    justify-content: center;
    align-items: center;
    padding: 18px 0 8px;
}

.flip-card-wrapper {
    perspective: 1200px;
    width: 100%;
    height: 420px;
    cursor: pointer;
    user-select: none;
}

.flip-card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.flip-card-wrapper.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-wrapper.disabled {
    cursor: default;
    opacity: 0;
    transform: scale(0.96);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.flip-card-wrapper.selected {
    transform: scale(1.04);
    transition: transform 0.3s ease;
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,63,107,0.15);
}

/* Card Front (face-down design) */
.flip-card-front {
    background: linear-gradient(145deg, var(--primary) 0%, #005A9C 50%, var(--secondary) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.flip-card-front::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 2px solid rgba(201,162,39,0.4);
    border-radius: 10px;
}

.flip-card-front::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(201,162,39,0.1) 0%, transparent 50%),
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 20px,
            rgba(255,255,255,0.02) 20px,
            rgba(255,255,255,0.02) 21px
        );
}

.card-front-text {
    position: relative;
    z-index: 1;
    text-align: center;
}

.card-front-dii {
    font-size: 4.5rem;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    text-shadow: 0 4px 12px rgba(0,0,0,0.3);
    letter-spacing: 2px;
}

.card-front-subtitle {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.7);
    letter-spacing: 0;
    text-transform: uppercase;
    margin-top: 4px;
}

.card-front-gen {
    font-size: 1rem;
    color: rgba(255,255,255,0.8);
    margin-top: 8px;
    letter-spacing: 0;
}

.card-front-icon {
    font-size: 2.2rem;
    color: rgba(255,255,255,0.3);
    position: relative;
    z-index: 1;
}

/* Card Back (revealed) */
.flip-card-back {
    transform: rotateY(180deg);
    background: white;
    overflow-y: auto;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card-back-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    padding: 12px 14px;
    border-radius: 8px;
    text-align: center;
    width: 100%;
    margin-bottom: 14px;
}

.card-back-group {
    font-size: 1.3rem;
    font-weight: 800;
}

.card-back-label {
    font-size: 1rem;
    font-weight: 700;
    opacity: 0.95;
    letter-spacing: 0;
}

.card-back-hints {
    width: 100%;
}

.hint-item {
    background: #F7F9FC;
    border-left: 3px solid var(--accent);
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: 0 6px 6px 0;
    font-size: 0.82rem;
}

.hint-order {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.96rem;
    margin-bottom: 3px;
}

.hint-text {
    color: var(--text-dark);
    font-size: 0.95rem;
    line-height: 1.45;
}

/* ============ CONFIRM SECTION ============ */
.confirm-section {
    text-align: center;
    margin-top: 24px;
    animation: fadeInUp 0.5s ease;
}

.confirm-section .selected-info {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ============ RESULT DISPLAY ============ */
.result-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: celebrationIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 500px;
    margin: 0 auto;
}

.result-group-number {
    font-size: 4rem;
    font-weight: 800;
    color: var(--accent-light);
    line-height: 1;
    text-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.result-group-label {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 24px;
    letter-spacing: 1px;
}

.result-seniors {
    background: rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: left;
    backdrop-filter: blur(5px);
}

.result-senior-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.result-senior-item:last-child {
    border-bottom: none;
}

.result-senior-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-light);
}

.result-senior-hint {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-top: 4px;
    line-height: 1.5;
}

/* ============ DASHBOARD ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid var(--border-color);
}

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

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.blue { background: rgba(0,102,204,0.1); color: var(--secondary); }
.stat-icon.gold { background: rgba(201,162,39,0.1); color: var(--accent); }
.stat-icon.green { background: rgba(40,167,69,0.1); color: var(--success); }
.stat-icon.purple { background: rgba(111,66,193,0.1); color: #6f42c1; }

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-dark);
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.progress-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.progress-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.progress-percent {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--secondary);
}

.progress-bar-container {
    background: #e9ecef;
    border-radius: 50px;
    height: 16px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
    border-radius: 50px;
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ GROUP CARDS (Dashboard) ============ */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.group-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform var(--transition), box-shadow var(--transition);
}

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

.group-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg);
}

.group-number-badge {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    padding: 6px 14px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
}

.group-junior-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.group-senior-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.group-senior-list li {
    padding: 5px 0;
    font-size: 0.875rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.group-senior-list li::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

/* ============ TABLE STYLES ============ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    background: var(--primary);
    color: #fff;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
}

.data-table th:first-child { border-radius: 8px 0 0 0; }
.data-table th:last-child { border-radius: 0 8px 0 0; }

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: #EEF4FF;
}

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

/* ============ ADMIN TABS ============ */
.admin-tabs {
    display: flex;
    gap: 0;
    background: var(--card-bg);
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: 2px solid var(--border-color);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.admin-tab-btn {
    padding: 14px 24px;
    background: none;
    border: none;
    font-family: 'Sarabun', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    border-bottom: 3px solid transparent;
    position: relative;
    white-space: nowrap;
}

.admin-tab-btn:hover {
    color: var(--primary);
    background: rgba(0,63,107,0.04);
}

.admin-tab-btn.active {
    color: var(--primary);
    font-weight: 700;
    border-bottom-color: var(--secondary);
    background: rgba(0,102,204,0.05);
}

.tab-content-panel {
    display: none;
    background: var(--card-bg);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-top: none;
}

.tab-content-panel.active {
    display: block;
}

/* ============ FORM STYLES ============ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
    color: var(--text-dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}

.form-control:disabled {
    background: #f8f9fa;
    color: #adb5bd;
    cursor: not-allowed;
}

/* ============ ADMIN GROUP CARDS ============ */
.admin-group-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.admin-group-card:hover {
    box-shadow: var(--shadow-md);
}

.admin-group-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--bg);
    margin-bottom: 16px;
}

.senior-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #EEF4FF;
    border: 1px solid rgba(0,102,204,0.2);
    border-radius: 50px;
    padding: 5px 12px;
    font-size: 0.82rem;
    color: var(--primary);
    font-weight: 500;
    margin: 3px;
}

.senior-tag .remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0;
    font-size: 0.75rem;
    line-height: 1;
    transition: transform var(--transition);
}

.senior-tag .remove-btn:hover {
    transform: scale(1.3);
}

.ungrouped-section {
    background: #FFF8E6;
    border: 1px solid rgba(201,162,39,0.3);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 24px;
}

.ungrouped-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #856404;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============ LOGIN PAGE ============ */
#loginPage {
    width: 100%;
    min-height: 100vh;
}

.login-wrapper {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(0,63,107,0.94) 0%, rgba(0,102,204,0.88) 100%),
        repeating-linear-gradient(135deg, rgba(255,255,255,0.06) 0 1px, transparent 1px 26px);
    padding: 0;
}

.login-shell {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(460px, 0.85fr);
    background: #fff;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    animation: fadeInUp 0.5s ease;
}

.login-brand-panel {
    background: linear-gradient(135deg, var(--primary) 0%, #005A9C 58%, var(--secondary) 100%);
    color: #fff;
    padding: clamp(56px, 6vw, 92px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.login-brand-panel::before {
    content: '';
    position: absolute;
    inset: 18px;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 12px;
    pointer-events: none;
}

.login-brand-mark {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    background: rgba(255,255,255,0.13);
    border: 1px solid rgba(255,255,255,0.18);
    color: var(--accent-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    position: relative;
    z-index: 1;
}

.login-brand-panel h1 {
    font-size: clamp(3rem, 5vw, 5rem);
    font-weight: 800;
    margin: 12px 0 14px;
    letter-spacing: 0;
    position: relative;
    z-index: 1;
}

.login-brand-panel p {
    font-size: clamp(1.05rem, 1.3vw, 1.25rem);
    line-height: 1.7;
    color: rgba(255,255,255,0.82);
    max-width: 420px;
    margin: 0;
    position: relative;
    z-index: 1;
}

.login-brand-kicker {
    color: var(--accent-light);
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    position: relative;
    z-index: 1;
}

.login-card {
    background: #fff;
    padding: clamp(56px, 6vw, 92px);
    width: 100%;
    max-width: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-logo {
    text-align: left;
    margin-bottom: 34px;
}

.login-logo-text {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    display: block;
    line-height: 1.15;
}

.login-logo-sub {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 46px;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
}

.password-toggle:hover {
    background: #EEF4FF;
    color: var(--primary);
}

.login-error {
    font-size: 0.9rem;
}

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-item {
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--secondary);
    max-width: 360px;
    animation: toastIn 0.4s ease;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
}

.toast-item.success { border-left-color: var(--success); }
.toast-item.error { border-left-color: var(--danger); }
.toast-item.warning { border-left-color: var(--warning); }

.toast-item i { font-size: 1.1rem; }
.toast-item.success i { color: var(--success); }
.toast-item.error i { color: var(--danger); }
.toast-item.warning i { color: var(--warning); }
.toast-item.info i { color: var(--secondary); }

/* ============ LOADING ============ */
.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.loading-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 32px 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

/* ============ MODAL ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-box {
    background: #fff;
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 4px;
    transition: color var(--transition);
}

.modal-close:hover { color: var(--danger); }

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============ SECTION CARDS ============ */
.section-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.section-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-card-title i {
    color: var(--accent);
}

/* ============ EXPORT OPTIONS ============ */
.export-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.export-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition);
    user-select: none;
}

.export-checkbox-label:hover {
    background: #EEF4FF;
    border-color: var(--secondary);
    color: var(--primary);
}

.export-checkbox-label input:checked + span {
    color: var(--primary);
    font-weight: 600;
}

.export-checkbox-label input[type=checkbox]:checked ~ * {
    color: var(--primary);
}

/* ============ DANGER ZONE ============ */
.danger-zone {
    background: #FFF5F5;
    border: 1px solid rgba(220,53,69,0.2);
    border-radius: var(--radius);
    padding: 24px;
}

.danger-zone-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============ ANIMATIONS ============ */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes celebrationIn {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-5deg);
    }
    60% {
        transform: scale(1.05) rotate(1deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes confetti {
    0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes cardHover {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.flip-card-wrapper:not(.disabled):not(.flipped):hover .flip-card-inner {
    animation: cardHover 2s ease infinite;
}

/* ============ CONTACT PAGE ============ */
.contact-step {
    display: none;
    animation: fadeInUp 0.4s ease;
}

.contact-step.active {
    display: block;
}

.contact-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.contact-actions .btn-random {
    min-width: 0;
}

.contact-back-btn {
    border-radius: 50px;
    font-family: 'Sarabun', sans-serif;
    font-weight: 600;
    white-space: nowrap;
    min-width: 118px;
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.social-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    margin-right: 8px;
}

.social-icon.ig { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); color: #fff; }
.social-icon.fb { background: #1877F2; color: #fff; }
.social-icon.dc { background: #5865F2; color: #fff; }

/* ============ CONFETTI ============ */
.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 9999;
    animation: confetti 3s ease-in forwards;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 992px) {
    .login-wrapper {
        padding: 0;
    }

    .login-shell {
        min-height: 100vh;
        grid-template-columns: 1fr;
    }

    .login-brand-panel {
        padding: 34px 34px 40px;
        gap: 34px;
    }

    .login-brand-panel h1 {
        font-size: 2.2rem;
    }

    .login-card {
        padding: 42px 34px;
    }

    .main-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: unset;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
    }

    .main-content {
        padding: 20px 16px;
    }

    .cards-container {
        grid-template-columns: repeat(3, minmax(190px, 230px));
        gap: 18px;
    }

    .flip-card-wrapper {
        height: 330px;
    }

    .welcome-banner h1 {
        font-size: 1.8rem;
    }
}

@media (max-width: 768px) {
    .login-wrapper {
        align-items: stretch;
        padding: 0;
    }

    .login-shell {
        border-radius: 0;
    }

    .login-brand-panel {
        padding: 26px;
    }

    .login-brand-mark {
        width: 56px;
        height: 56px;
        font-size: 1.45rem;
    }

    .login-brand-panel h1 {
        font-size: 1.75rem;
    }

    .login-brand-panel p {
        font-size: 0.94rem;
    }

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

    .login-logo-text {
        font-size: 1.55rem;
    }

    .header-nav {
        gap: 4px;
    }

    .nav-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .brand-main {
        font-size: 1rem;
    }

    .admin-tabs {
        overflow-x: auto;
    }

    .admin-tab-btn {
        padding: 12px 16px;
        font-size: 0.85rem;
    }

    .flip-card-wrapper {
        height: 420px;
    }

    .cards-container {
        grid-template-columns: 1fr;
        max-width: 320px;
        margin: 0 auto;
        gap: 12px;
    }

    .contact-actions {
        grid-template-columns: 1fr;
    }

    .contact-back-btn {
        width: 100%;
    }
}

/* ============ SEARCH BAR ROW ============ */
.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.9rem;
    transition: border-color var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}

/* ============ TABLE WRAPPER ============ */
.table-wrapper {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow-x: auto;
}

/* ============ BTN UTILITIES ============ */
.btn-sm-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-edit { background: #EEF4FF; color: var(--secondary); }
.btn-edit:hover { background: var(--secondary); color: #fff; }
.btn-delete { background: #FFF5F5; color: var(--danger); }
.btn-delete:hover { background: var(--danger); color: #fff; }

/* ============ Already drawn info ============ */
.drawn-result {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid rgba(16,185,129,0.3);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-top: 12px;
}

.drawn-result-group {
    font-size: 1.3rem;
    font-weight: 800;
    color: #065F46;
}

.drawn-hint-item {
    padding: 5px 0;
    font-size: 0.875rem;
    color: #064E3B;
}
