/* Import Google Fonts for Thai & English */
@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    --primary-color: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --accent-color: #ec4899;
    --accent-gradient: linear-gradient(135deg, #f472b6 0%, #ec4899 100%);
    
    --bg-main: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-color: #e2e8f0;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    
    --font-heading: 'Prompt', sans-serif;
    --font-body: 'Sarabun', sans-serif;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    padding-bottom: 3rem;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: #0f172a;
}

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

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

/* Page Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Glassmorphism Header */
header {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 2.75rem;
    height: 2.75rem;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.logo-text h1 {
    font-size: 1.25rem;
    line-height: 1.2;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    text-align: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.6);
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
    color: white;
}

/* Dashboard Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.3s ease;
}

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

.stat-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary { background: rgba(99, 102, 241, 0.1); color: var(--primary-color); }
.stat-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success-color); }
.stat-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning-color); }
.stat-icon.danger { background: rgba(239, 68, 68, 0.1); color: var(--danger-color); }

.stat-info h3 {
    font-size: 1.75rem;
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.stat-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Content Container Card */
.main-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin-bottom: 2rem;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Search and Filters */
.search-filter-bar {
    background: rgba(241, 245, 249, 0.6);
    padding: 1rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.search-input-group {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-input-group input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

.search-input-group input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.filter-select {
    padding: 0.625rem 1.75rem 0.625rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    min-width: 150px;
}

.filter-select:focus {
    border-color: var(--primary-light);
}

/* Modern Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

table.modern-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    text-align: left;
}

table.modern-table th {
    background: #f8fafc;
    padding: 1rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

table.modern-table td {
    padding: 1rem;
    font-size: 0.925rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table.modern-table tbody tr:hover {
    background: rgba(248, 250, 252, 0.7);
}

/* Badge System */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-heading);
}

.badge-very-good { background: rgba(16, 185, 129, 0.1); color: var(--success-color); }
.badge-good { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.badge-fair { background: rgba(245, 158, 11, 0.1); color: var(--warning-color); }
.badge-improve { background: rgba(249, 115, 22, 0.1); color: #ea580c; }
.badge-fail { background: rgba(239, 68, 68, 0.1); color: var(--danger-color); }

/* Form Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-control {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: white;
}

.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

/* Assessment Table styling for Input form */
.assessment-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: 0.95rem;
}

.assessment-table th {
    background: #f1f5f9;
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
    font-family: var(--font-heading);
    text-align: center;
}

.assessment-table td {
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
}

.assessment-table tr.section-title {
    background: #f8fafc;
    font-weight: 600;
    font-family: var(--font-heading);
}

.score-cell {
    text-align: center;
    width: 50px;
    cursor: pointer;
}

.score-cell input[type="radio"] {
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* Image Upload Previews */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    background: rgba(248, 250, 252, 0.5);
    transition: all 0.3s ease;
}

.upload-zone:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.03);
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.image-preview-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 4/3;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* Result summary panel inside creation form */
.summary-panel {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin: 1.5rem 0;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 1.5rem;
    text-align: center;
}

.summary-item h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: var(--font-heading);
}

/* Criteria Checklist representation */
.criteria-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.criteria-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    background: white;
    border: 1px solid var(--border-color);
}

.criteria-item.active {
    background: rgba(99, 102, 241, 0.05);
    border-color: var(--primary-light);
    font-weight: 600;
}

.criteria-checkbox {
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--text-light);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: transparent;
}

.criteria-item.active .criteria-checkbox {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Gallery inside View page */
.view-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.gallery-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.gallery-card:hover {
    transform: scale(1.02);
}

.gallery-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.gallery-caption {
    padding: 0.75rem 1rem;
    font-family: var(--font-heading);
    font-weight: 500;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-primary);
    background: #f8fafc;
}

/* Signatures structure */
.signature-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-top: 3rem;
    text-align: center;
}

.signature-block {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.signature-line {
    width: 250px;
    border-bottom: 1px dotted var(--text-primary);
    margin: 2.5rem 0 0.5rem 0;
}

/* Print CSS */
@media print {
    @page {
        size: A4 portrait;
        margin: 1.2cm;
    }
    
    body {
        background-color: white;
        color: black;
        padding-bottom: 0;
        font-size: 11pt;
    }
    
    header, 
    .btn, 
    .search-filter-bar, 
    .no-print,
    .remove-btn {
        display: none !important;
    }
    
    .container {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    
    .main-card {
        border: none;
        box-shadow: none;
        background: transparent;
        padding: 0;
        margin: 0;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    
    .assessment-table th, .report-table th {
        background: #f1f5f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color: black;
        border: 1px solid black;
        padding: 0.5rem;
    }

    .assessment-table td, .report-table td {
        border: 1px solid black;
        padding: 0.5rem;
    }
    
    .assessment-table tr.section-title {
        background: #f8fafc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color: black;
    }
    
    .score-cell input[type="radio"] {
        /* Hide radio and replace with print checkbox look */
        appearance: none;
        -webkit-appearance: none;
        width: 15px;
        height: 15px;
        border: 1px solid black;
        display: inline-block;
        position: relative;
    }
    
    .score-cell input[type="radio"]:checked::after {
        content: "\2713"; /* Checkmark */
        position: absolute;
        top: -3px;
        left: 2px;
        font-size: 12px;
        font-weight: bold;
        color: black;
    }

    .criteria-item {
        border: 1px solid black;
        background: transparent !important;
    }

    .criteria-item.active .criteria-checkbox {
        background: black !important;
        border-color: black !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .signature-line {
        border-bottom: 1px solid black;
    }
    
    /* Force page breaks for gallery if needed */
    .print-page-break {
        page-break-before: always;
    }
}

/* Report Table & Page Styling */
.report-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

.report-table th {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 0.75rem 0.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
}

.report-table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
}

.report-summary-flex {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

.report-summary-box {
    flex: 1;
    min-width: 280px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.report-summary-box h4 {
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 0.35rem;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    color: var(--primary-color);
}

.report-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.9rem;
    border-bottom: 1px dashed rgba(0,0,0,0.05);
}

