/* ========================================
   ระบบสอบย้อนกลับผักอุดร - Main CSS
   ======================================== */

/* Global Styles */
:root {
    --primary-color: #198754;
    --secondary-color: #20c997;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
   /* padding-top: 76px;  Account for fixed navbar */
}

/* Import Thai Font */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ========================================
   Navigation Styles
   ======================================== */
.navbar {
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: all 0.3s ease;
}

.navbar-nav .nav-link:hover {
    transform: translateY(-1px);
}

/* ========================================
   Hero Section with Carousel
   ======================================== */
.hero-section {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.hero-section .carousel {
    height: 100vh;
}

.hero-section .carousel-inner,
.hero-section .carousel-item {
    height: 100%;
}

.hero-slide {
    height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.hero-slide::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    background-attachment: scroll;
    z-index: -1;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.hero-content h1 {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.hero-content p {
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.hero-icon {
    animation: float 3s ease-in-out infinite;
}

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

.feature-item {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 500;
    opacity: 0;
    animation: slideInLeft 0.6s ease forwards;
}

.feature-item:nth-child(1) { animation-delay: 0.2s; }
.feature-item:nth-child(2) { animation-delay: 0.4s; }
.feature-item:nth-child(3) { animation-delay: 0.6s; }

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Carousel Indicators */
.hero-section .carousel-indicators {
    bottom: 30px;
    z-index: 3;
}

.hero-section .carousel-indicators button {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin: 0 6px;
    background-color: rgba(255, 255, 255, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}

.hero-section .carousel-indicators button.active {
    background-color: rgba(255, 255, 255, 0.9);
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Carousel Controls */
.hero-section .carousel-control-prev,
.hero-section .carousel-control-next {
    width: 60px;
    height: 60px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.hero-section .carousel-control-prev {
    left: 30px;
}

.hero-section .carousel-control-next {
    right: 30px;
}

.hero-section .carousel-control-prev:hover,
.hero-section .carousel-control-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.hero-section .carousel-control-prev-icon,
.hero-section .carousel-control-next-icon {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Info Cards */
.info-card {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    opacity: 0;
    animation: fadeInUp 0.8s ease forwards;
}

.info-card:nth-child(1) { animation-delay: 0.3s; }
.info-card:nth-child(2) { animation-delay: 0.5s; }
.info-card:nth-child(3) { animation-delay: 0.7s; }

.info-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

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

/* Demo QR Card */
.demo-qr-card {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.demo-qr-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Background Blur Support */
.backdrop-blur {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Fallback for browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(10px)) {
    .demo-qr-card,
    .info-card {
        background: rgba(255, 255, 255, 0.2) !important;
    }
}

/* Hero Action Buttons */
.hero-action .btn {
    border-radius: 50px;
    padding: 12px 30px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.hero-action .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

/* ========================================
   Scanner Styles
   ======================================== */
.scanner-container {
    position: relative;
    z-index: 2;
}

.scanner-area {
    text-align: center;
}

.scanner-frame {
    position: relative;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

#qrVideo {
    width: 100%;
    height: 300px;
    object-fit: cover;
    background: #000;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-box {
    position: relative;
    width: 200px;
    height: 200px;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #fff;
}

.corner-tl {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
}

.corner-tr {
    top: -2px;
    right: -2px;
    border-left: none;
    border-bottom: none;
}

.corner-bl {
    bottom: -2px;
    left: -2px;
    border-right: none;
    border-top: none;
}

.corner-br {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
}

/* Demo QR Code */
.demo-section {
    padding: 2rem 0;
}

.demo-qr-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 300px;
    margin: 0 auto;
}

.qr-demo canvas {
    border-radius: 8px;
}

/* ========================================
   Card Styles
   ======================================== */
.card {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

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

.card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 16px 16px 0 0 !important;
    padding: 1.5rem;
}

.card-body {
    padding: 2rem;
}

/* ========================================
   Form Styles
   ======================================== */
.form-control {
    border-radius: 12px;
    border: 2px solid #e9ecef;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.form-text {
    font-size: 0.875rem;
    color: #6c757d;
}

/* ========================================
   Button Styles
   ======================================== */
.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    box-shadow: 0 4px 15px rgba(25, 135, 84, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #157347, #1aa179);
    box-shadow: 0 6px 20px rgba(25, 135, 84, 0.4);
}

.btn-outline-success {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-success:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* ========================================
   Modal Styles
   ======================================== */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 2px solid #e9ecef;
    padding: 1.5rem;
}

.modal-title {
    font-weight: 600;
    color: var(--dark-color);
}

.modal-body {
    padding: 2rem;
}

/* ========================================
   Alert Styles
   ======================================== */
.alert {
    border: none;
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: linear-gradient(135deg, #d1f2eb, #a3e6d4);
    color: #0f5132;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da, #f1aeb5);
    color: #721c24;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd, #ffecb5);
    color: #664d03;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1, #b8daff);
    color: #055160;
}

/* ========================================
   Table Styles
   ======================================== */
.table {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table thead th {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    font-weight: 600;
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-color: #e9ecef;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

/* ========================================
   Dashboard Styles
   ======================================== */
.dashboard-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    height: 100%;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.dashboard-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    margin-bottom: 1rem;
}

.icon-success {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.icon-info {
    background: linear-gradient(135deg, var(--info-color), #5bc0de);
}

.icon-warning {
    background: linear-gradient(135deg, var(--warning-color), #ffdb4d);
}

.icon-danger {
    background: linear-gradient(135deg, var(--danger-color), #e74c3c);
}

/* ========================================
   Loading Styles
   ======================================== */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ========================================
   Data Display Styles
   ======================================== */
.data-section {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.data-section h5 {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

.data-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #f8f9fa;
}

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

.data-label {
    font-weight: 600;
    color: var(--dark-color);
    flex: 0 0 40%;
}

.data-value {
    color: #6c757d;
    flex: 1;
    text-align: right;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .hero-section {
        text-align: center;
    }
    
    /* Hero Carousel Mobile */
    .hero-slide {
        background-attachment: scroll;
        padding: 0 15px;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
    
    .hero-action .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
        letter-spacing: 0.3px;
        width: auto;
        margin: 0.25rem;
    }
    
    /* Carousel Controls Hidden on Mobile */
    .hero-section .carousel-control-prev,
    .hero-section .carousel-control-next {
        display: none !important;
    }
    
    .hero-section .carousel-indicators {
        bottom: 20px;
    }
    
    .hero-section .carousel-indicators button {
        width: 10px;
        height: 10px;
        margin: 0 4px;
    }
    
    /* Info Cards Mobile */
    .info-card {
        padding: 1.5rem !important;
        margin-bottom: 1rem;
    }
    
    .info-card h5 {
        font-size: 1rem;
    }
    
    .info-card p {
        font-size: 0.85rem;
    }
    
    .info-icon i {
        font-size: 1.5rem !important;
    }
    
    /* Demo QR Card Mobile */
    .demo-qr-card {
        padding: 1.5rem !important;
    }
    
    .btn-lg {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .scanner-frame {
        max-width: 100%;
    }
    
    #qrVideo {
        height: 250px;
    }
    
    .scanner-box {
        width: 150px;
        height: 150px;
    }
    
    .data-item {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }
    
    .data-label {
        flex: none;
        margin-bottom: 0.25rem;
    }
    
    .data-value {
        flex: none;
        text-align: left;
        width: 100%;
    }
    
    .dashboard-card {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 576px) {
    body {
        font-size: 0.9rem;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .card-body {
        padding: 1.5rem;
    }
    
    .data-section {
        padding: 1.5rem;
    }
}

/* ========================================
   Animation Classes
   ======================================== */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-up {
    animation: slideUp 0.5s ease-out;
}

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

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ========================================
   Utility Classes
   ======================================== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient-success {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
}

.shadow-custom {
    box-shadow: var(--shadow-lg) !important;
}

.border-radius-lg {
    border-radius: 16px !important;
}

.border-radius-xl {
    border-radius: 24px !important;
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .navbar,
    .btn,
    .modal,
    .scanner-area {
        display: none !important;
    }
    
    body {
        padding-top: 0;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}
