/* ========================================= */
/* ==           GLOBAL STYLES             == */
/* ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;600;700&display=swap');

body {
    font-family: 'Sarabun', sans-serif;
    background-color: #f4f6f9;
    color: #343a40;
    margin: 0;
    font-size: 16px;
    line-height: 1.65;
}

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

header {
    text-align: center;
    margin-bottom: 35px;
}
header h1 {
    color: #2c5e3A;
    margin: 0 0 10px 0;
    font-size: 2.1em;
    font-weight: 700;
}
header p {
    color: #5a6268;
    font-size: 1.1em;
    margin-top: 0;
}

.card {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    margin-bottom: 30px;
    border: 1px solid #e9ecef;
}
.card h2 {
    margin-top: 0;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 15px;
    margin-bottom: 20px;
    font-size: 1.4em;
    color: #343a40;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.card h2 .filter-icon {
    width: 20px;
    height: 20px;
    opacity: 0.6;
}

/* ========================================= */
/* ==           BUTTON STYLES (GLOBAL)    == */
/* ========================================= */
.button-base {
    padding: 9px 18px; border: 1px solid transparent; border-radius: 5px; cursor: pointer;
    font-size: 0.95em; font-family: 'Sarabun', sans-serif; font-weight: 600;
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.15s ease-in-out; min-width: 100px; text-align: center;
    line-height: 1.5; box-shadow: 0 1px 2px rgba(0,0,0,0.05); vertical-align: middle;
}
.button-base:hover { box-shadow: 0 2px 4px rgba(0,0,0,0.1); transform: translateY(-1px); }
.button-base:active { transform: translateY(0px); box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); }
.button-primary { background-color: #2c5e3A; color: white; border-color: #2c5e3A; }
.button-primary:hover { background-color: #234d30; border-color: #234d30; }
.button-secondary { background-color: #6c757d; color: white; border-color: #6c757d; }
.button-secondary:hover { background-color: #5a6268; border-color: #545b62; }
.button-danger { background-color: #dc3545; color: white; border-color: #dc3545;}
.button-danger:hover { background-color: #c82333; border-color: #bd2130;}
.button-info { background-color: #007bff; color: white; border-color: #007bff;} 
.button-info:hover { background-color: #0056b3; border-color: #0056b3;}
.button-logout {
    background-color: #6c757d; color: white; border-color: #6c757d;
    padding: 7px 14px; font-size: 0.9em; min-width: auto;
}
.button-logout:hover { background-color: #5a6268; border-color: #545b62;}
.button-base:disabled, .button-logout:disabled {
    background-color: #e9ecef; color: #adb5bd; border-color: #e9ecef;
    cursor: not-allowed; transform: none; box-shadow: none;
}

/* ========================================= */
/* ==        FORM & INPUT STYLES (GLOBAL) == */
/* ========================================= */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #495057; font-size: 0.9em; }
.form-control,
.form-group input[type="text"], .form-group input[type="password"],
.form-group input[type="email"], .form-group input[type="url"],
.form-group input[type="tel"], .form-group input[type="number"],
.form-group input[type="date"], .form-group input[type="file"],
.form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #ced4da; border-radius: 5px;
    box-sizing: border-box; font-family: 'Sarabun', sans-serif; font-size: 0.95em;
    background-color: #fff; color: #495057;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.form-group input[type="file"].form-control { padding: 8px 10px; }
.form-control:focus {
    border-color: #86b7fe; outline: 0; box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}
.form-row { display: flex; flex-wrap: wrap; gap: 20px; }
.form-row .form-group { flex: 1; min-width: 200px; }
.form-actions {
    margin-top: 25px; padding-top: 20px; border-top: 1px solid #e9ecef;
    display: flex; gap: 10px; justify-content: flex-end; 
}
.form-group small { font-size: 0.85em; color: #6c757d; margin-top: 5px; display: block; }

/* ========================================= */
/* ==           TABLE STYLES (GLOBAL)     == */
/* ========================================= */
.table-container { overflow-x: auto; margin-bottom: 20px;}
table { width: 100%;   font-size: 0.9em; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #dee2e6; vertical-align: middle; }
th { background-color: #f8f9fa; font-weight: 600; color: #495057; white-space: nowrap;}
tbody tr:hover { background-color: #f1f9ff; }
table td.actions-column { 
    display: flex; align-items: center; gap: 8px; white-space: nowrap; 
}
table .button-base.button-table-action { 
    padding: 5px 10px; min-width: auto; font-size: 0.8em; font-weight: 500;
}

/* ========================================= */
/* ==       SHARED UTILITY STYLES         == */
/* ========================================= */
.filter-icon { width: 16px; height: 16px; vertical-align: middle; margin-right: 6px; opacity: 0.7;}
.filter-form-layout {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); 
    gap: 15px; align-items: flex-end; 
}
.filter-form-layout .form-group { margin-bottom: 0; }
.filter-form-layout .form-group.filter-actions {
    display: flex; gap: 10px; align-self: flex-end;
    /* justify-content will be in specific admin/sales CSS */
}

.status-badge {
    padding: 4px 10px; border-radius: 12px; color: #fff;
    font-size: 0.85em; font-weight: 500; text-transform: capitalize; 
    display: inline-block; line-height: 1.4;
}
.status-pending { background-color: #ffc107; color: #212529; }
.status-processing { background-color: #007bff; }
.status-completed, .status-active { background-color: #28a745; }
.status-cancelled, .status-inactive { background-color: #dc3545; }

.message-box {
    padding: 12px 15px; margin-top: 20px; border-radius: 5px; color: #fff; font-size: 0.9em;
}
.message-box.success { background-color: #28a745; }
.message-box.error { background-color: #dc3545; }

.loading-text, .error-text { 
    text-align: center; font-size: 1.1em; color: #888; padding: 30px 0; 
}
.product-grid .loading-text, .product-grid .error-text { grid-column: 1 / -1; }


/* ========================================= */
/* ==         STYLES FOR LOGIN PAGE       == */
/* ========================================= */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background-color: #f0f2f5; padding: 20px; }
.login-container { width: 100%; max-width: 380px; }
.login-box { background: #fff; padding: 30px 35px; border-radius: 10px; box-shadow: 0 5px 25px rgba(0,0,0,0.1); }
.login-header { text-align: center; margin-bottom: 25px; }
.login-header h2 { margin: 0; color: #2c5e3A; font-size: 1.7em; }
.login-header p { margin: 5px 0 0; color: #6c757d; font-size: 1em; }
.login-box .button-primary { width: 100%; padding: 12px; font-size: 1em; }


/* ========================================= */
/* ==   RESPONSIVE MEDIA QUERIES (GLOBAL) == */
/* ========================================= */
@media (max-width: 992px) { 
    .order-layout { grid-template-columns: 1fr; } /* Create Order Page */
    .filter-form-layout { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    /* Admin Nav specific responsive is in admin_style.css */
    /* Sales Nav specific responsive is in sales_style.css */
}
@media (max-width: 767.98px) { 
    .container { padding: 0 15px; }
    header h1 { font-size: 1.8em; }
    .card h2 { font-size: 1.3em; }
    .filter-form-layout { grid-template-columns: 1fr; } 
    .form-row { flex-direction: column; gap: 0; }
    .form-row .form-group { margin-bottom: 15px; }
    /* Base for user-bar/admin-nav on mobile is handled in their specific files or here if truly global */
}


/* =================================== */
/* == MODAL STYLES (สำหรับ Pop-up) == */
/* =================================== */

.modal {
    display: none; /* ซ่อนไว้เป็นค่าเริ่มต้น */
    position: fixed; /* ทำให้ลอยอยู่กับที่ */
    z-index: 1000; /* ทำให้ลอยอยู่บนสุด */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* ทำให้เลื่อนได้ถ้าเนื้อหาเยอะ */
    background-color: rgba(0,0,0,0.6); /* ฉากหลังสีดำโปร่งแสง */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 25px 30px;
    border: 1px solid #888;
    width: 95%;
    max-width: 500px; /* ขนาดกว้างสุดของ Modal */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation-name: animatetop;
    animation-duration: 0.4s
}

/* Animation for Modal */
@keyframes animatetop {
    from {transform: translateY(-50px); opacity: 0}
    to {transform: translateY(0); opacity: 1}
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
}

.close-btn {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    transition: color 0.2s;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-body {
    padding-top: 10px;
}

/* Style for image preview inside modal */
.image-preview-wrapper {
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    border: 1px dashed #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.image-preview-wrapper img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

/* ========================================= */
/* ==         STYLES FOR LOGIN PAGE       == */
/* ========================================= */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background-color: #f0f2f5; padding: 20px; }
.login-container { width: 100%; max-width: 380px; }
.login-box { background: #fff; padding: 30px 35px; border-radius: 10px; box-shadow: 0 5px 25px rgba(0,0,0,0.1); }
.login-header { text-align: center; margin-bottom: 25px; }
.login-header h2 { margin: 0; color: #2c5e3A; font-size: 1.7em; }
.login-header p { margin: 5px 0 0; color: #6c757d; font-size: 1em; }
.login-box .button-primary { width: 100%; padding: 12px; font-size: 1em; }

/* ========== START: สไตล์สำหรับ Remember Me Checkbox ========== */
.form-group-checkbox {
    display: flex;
    align-items: center;
    margin-bottom: 20px; /* หรือปรับตามความเหมาะสม */
}
.form-group-checkbox input[type="checkbox"] {
    width: auto; /* ไม่ให้ checkbox เต็มความกว้าง */
    margin-right: 8px;
    /* เพิ่มสไตล์อื่นๆ ถ้าต้องการ เช่น ขนาด, สี */
}
.form-group-checkbox .checkbox-label {
    font-weight: normal; /* ไม่ต้องตัวหนาเหมือน label อื่น */
    font-size: 0.9em;   /* ปรับขนาด font */
    color: #495057;
    margin-bottom: 0; /* Override default margin-bottom ของ label */
    cursor: pointer;
}