/**
 * TNN Corporation - E-Report System
 * Main Stylesheet
 * สีธีมตามโลโก้: แดง #E31E24 + เทา
 */

/* ===== ROOT VARIABLES ===== */
:root {
    --primary-red: #E31E24;
    --primary-red-dark: #c51a1f;
    --primary-red-light: #ff4d4d;
    --light-gray: #F5F5F5;
    --medium-gray: #E0E0E0;
    --dark-gray: #424242;
    --text-dark: #212121;
    --white: #FFFFFF;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --info: #2196F3;
    --border-radius: 8px;
    --box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ===== RESET & GLOBAL ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-gray);
    color: var(--text-dark);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.container-fluid {
    width: 100%;
    padding: 20px;
}

/* ===== HEADER ===== */
.header {
    background: linear-gradient(135deg, var(--primary-red) 0%, var(--primary-red-dark) 100%);
    color: var(--white);
    padding: 15px 20px;
    box-shadow: var(--box-shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo img {
    height: 50px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--white);
    color: var(--primary-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* ===== NAVIGATION ===== */
.nav {
    background: var(--white);
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
}

.nav-list {
    list-style: none;
    display: flex;
    gap: 5px;
    padding: 0 20px;
}

.nav-item a {
    display: block;
    padding: 15px 20px;
    color: var(--text-dark);
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.nav-item a:hover,
.nav-item a.active {
    color: var(--primary-red);
    border-bottom-color: var(--primary-red);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s;
    text-align: center;
}

.btn-primary {
    background: var(--primary-red);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-red-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(227, 30, 36, 0.3);
}

.btn-secondary {
    background: var(--medium-gray);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: var(--dark-gray);
    color: var(--white);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-warning {
    background: var(--warning);
    color: var(--white);
}

.btn-info {
    background: var(--info);
    color: var(--white);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 18px;
}

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    border-bottom: 2px solid var(--light-gray);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-red);
}

.card-body {
    padding: 10px 0;
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
}

.form-label.required::after {
    content: " *";
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(227, 30, 36, 0.1);
}

.form-control.error {
    border-color: var(--danger);
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

/* ===== ALERTS ===== */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ===== TABLES ===== */
.table-responsive {
    overflow-x: auto;
    margin: 20px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

table thead {
    background: var(--primary-red);
    color: var(--white);
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--medium-gray);
}

table tbody tr:hover {
    background: var(--light-gray);
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.badge-success {
    background: var(--success);
    color: var(--white);
}

.badge-danger {
    background: var(--danger);
    color: var(--white);
}

.badge-warning {
    background: var(--warning);
    color: var(--white);
}

.badge-info {
    background: var(--info);
    color: var(--white);
}

.badge-secondary {
    background: var(--medium-gray);
    color: var(--text-dark);
}

/* ===== DASHBOARD STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-red);
    margin-bottom: 5px;
}

.stat-info p {
    color: var(--dark-gray);
    font-size: 14px;
}

.stat-icon {
    font-size: 48px;
    color: var(--primary-red);
    opacity: 0.2;
}

/* ===== IMAGE UPLOAD ===== */
.image-upload-area {
    border: 2px dashed var(--medium-gray);
    border-radius: var(--border-radius);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.image-upload-area:hover {
    border-color: var(--primary-red);
    background: rgba(227, 30, 36, 0.05);
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.image-preview-item {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.image-preview-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.image-preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== SIGNATURE PAD ===== */
.signature-pad-wrapper {
    border: 2px solid var(--medium-gray);
    border-radius: var(--border-radius);
    background: var(--white);
    padding: 10px;
}

.signature-pad {
    width: 100%;
    height: 200px;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    cursor: crosshair;
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 30px 0;
}

.pagination a,
.pagination span {
    padding: 10px 15px;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    color: var(--text-dark);
    transition: all 0.3s;
}

.pagination a:hover {
    background: var(--primary-red);
    color: var(--white);
    border-color: var(--primary-red);
}

.pagination span.current {
    background: var(--primary-red);
    color: var(--white);
    border-color: var(--primary-red);
}

/* ===== LOADING SPINNER ===== */
.loading-spinner {
    border: 4px solid var(--light-gray);
    border-top: 4px solid var(--primary-red);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    font-size: 28px;
    cursor: pointer;
    color: var(--dark-gray);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-list {
        flex-direction: column;
        padding: 0;
    }
    
    .nav-item a {
        border-bottom: none;
        border-left: 3px solid transparent;
    }
    
    .nav-item a:hover,
    .nav-item a.active {
        border-left-color: var(--primary-red);
        border-bottom-color: transparent;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }
.w-100 { width: 100%; }
.hidden { display: none; }