/* --- Google Font --- */
@import url('/npm/@fontsource/prompt/index.css');

/* --- CSS Variables (ตัวแปรสี) --- */
:root {
    --primary-color: #41826e;
    --primary-color-darker: #356a5a;
    --white-color: #ffffff;
    --dark-grey-color: #333333;
    --light-grey-color: #f4f7f6;
    --border-color: #e0e0e0;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: 'Prompt', sans-serif;
    line-height: 1.7;
    color: var(--dark-grey-color);
    background-color: var(--white-color);
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

h1,
h2,
h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.5rem;
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
}

.section-bg {
    background-color: var(--light-grey-color);
}

a {
    text-decoration: none;
}

/* --- Header & Navbar --- */
.header {
    background-color: var(--white-color);
    box-shadow: var(--shadow);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
}

.logo img {
    height: 50px;
}

/* --- General UI Components --- */
.btn-save {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--white-color);
    padding: 12px 30px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    font-size: 1rem;
}

.btn-save:hover {
    background-color: var(--primary-color-darker);
}

.btn-submit:disabled,
.btn-save:disabled,
.parcel-mark-btn:disabled {
    background-color: #8b8b8b;
    cursor: not-allowed;
    transition: 0.3s;
}

.btn-submit:hover:disabled,
.parcel-mark-btn:hover:disabled {
    background: #646464;
    border-color: var(--primary-color);
}

/* [เพิ่ม] สไตล์สำหรับปุ่มรอง */
.btn-secondary {
    background-color: var(--light-grey-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-secondary:hover,
.parcel-mark-btn:hover {
    background-color: #e9f2ef;
    color: var(--primary-color-darker);
    border-color: var(--primary-color-darker);
}

.register-department-select,
input[type="password"],
input[type="text"],
input[type="tel"],
input[type="email"],
.custom-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: 'Prompt', sans-serif;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--white-color);
    color: var(--dark-grey-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.register-department-select:focus,
.page-size-select:focus,
input[type="password"]:focus,
input[type="text"]:focus,
input[type="tel"]:focus,
.custom-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(65, 130, 110, 0.2);
}

input:disabled {
    cursor: default;
    background-color: light-dark(rgba(239, 239, 239, 0.3), rgba(59, 59, 59, 0.3));
    color: light-dark(rgb(84, 84, 84), rgb(170, 170, 170));
}

/* --- Table Styles (Public Page) --- */
.center-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}
.long-text {
    max-width: 200px;
    word-wrap: break-word;
}
.parcel-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white-color);
    box-shadow: var(--shadow);
    border-radius: 10px;
    overflow: hidden;
    font-size: 0.95rem;
}

.parcel-table thead tr {
    background-color: var(--primary-color);
    color: var(--white-color);
    text-align: left;
}

.parcel-table th,
.parcel-table td {
    padding: 12px 15px;
}

.parcel-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}

.parcel-table tbody tr:nth-of-type(even) {
    background-color: var(--light-grey-color);
}

.parcel-table tbody tr:last-of-type {
    border-bottom: none;
}

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

.status-received {
    color: var(--success-color);
    font-weight: 600;
}

.status-pending {
    color: #e67e22;
    font-weight: 600;
}

.status-returned {
    color: var(--danger-color);
    font-weight: 600;
}


/* --- Admin Page Specific Styles --- */
.admin-panel {
    max-width: 850px;
    margin: 0 auto;
    background: var(--white-color);
    padding: 3rem 2.5rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    position: relative;
}

.admin-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-nav-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    font-size: 1.1rem;
    font-weight: 400;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: color 0.3s ease, border-color 0.3s ease;
}

.admin-nav-btn:hover {
    color: var(--primary-color);
}

.admin-nav-btn.active {
    color: var(--primary-color);
    font-weight: 600;
    border-bottom-color: var(--primary-color);
}

.admin-section {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.admin-section.active {
    display: block;
    opacity: 1;
}

.send-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

/* Message status for JS feedback */
.form-message {
    margin-top: 1rem;
    padding: 0.8rem;
    border-radius: 8px;
    font-weight: 600;
}

.form-message.success {
    background-color: #d4edda;
    color: #155724;
}

.form-message.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* --- Styles for Committee Search Page (โค้ดเดิม) --- */
#uni-board-page {
    padding-top: 120px;
    padding-bottom: 80px;
    min-height: calc(100vh - 275px);
}

.section-subtitle {
    text-align: center;
    margin-top: -2.5rem;
    margin-bottom: 3rem;
    color: #666;
    font-size: 1.1rem;
}

.search-filters {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    background-color: var(--light-grey-color);
    border-radius: 10px;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 600;
    color: var(--primary-color);
}


/* --- Responsive (for Mobile) --- */
@media (max-width: 768px) {
    .section-title {
        font-size: 2rem;
    }

    .admin-nav {
        flex-direction: column;
        gap: 0.5rem;
    }

    .admin-panel {
        padding: 1.5rem;
        padding-top: 3rem;
    }
}

.receiver-special {
    color: #e67e22;
    /* สีส้ม */
    font-weight: 600;
}

/* === MODAL (POPUP) STYLES === */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(0);
}

.modal.active {
    display: flex;
    opacity: 1;
    pointer-events: all;
    animation: blurFadeIn 0.3s ease forwards;
}

.modal.hide {
    animation: blurFadeOut 0.3s ease forwards;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 600px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    transform: translateY(15px);
    opacity: 0;
}

.modal.active .modal-content,
.modal.active .confirm-modal-content

/* Add this for confirmation modal animation */
    {
    animation: slideUpBlurred 0.3s cubic-bezier(0.2, 0, 0, 1) 0.1s forwards;
}

.modal-close-btn {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

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

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.login-result {
    padding-top: 0.5rem;
}

.login-result.shake {
    animation: horizontalShaking 0.5s;
}

.btn-submit {
    background-color: #4a7c59;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-submit:hover {
    background-color: #3a6249;
}

.btn-cancel {
    background-color: #f8f9fa;
    color: #495057;
    padding: 0.75rem 1.5rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.required:after {
    content: " *";
    color: red;
}

.login-text {
    position: absolute;
    top: 5px;
    right: 16px;
    transition: 0.3s;
}

.login-text_hover:hover {
    color: var(--primary-color);
    transition: 0.3s;
    transform: translateY(-1px);
    cursor: pointer;
}

@keyframes blurFadeIn {
    0% {
        opacity: 0;
        backdrop-filter: blur(0);
    }

    100% {
        opacity: 1;
        backdrop-filter: blur(10px);
    }
}

@keyframes blurFadeOut {
    0% {
        opacity: 1;
        backdrop-filter: blur(10px);
    }

    100% {
        opacity: 0;
        backdrop-filter: blur(0);
    }
}

@keyframes slideUpBlurred {
    0% {
        transform: translateY(15px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes horizontalShaking {
    0% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(5px)
    }

    50% {
        transform: translateX(-5px)
    }

    75% {
        transform: translateX(5px)
    }

    100% {
        transform: translateX(0)
    }
}

button, input, select, textarea {
    font-family: 'Prompt', sans-serif;
}

/* Barcode Scanner Modal */
#scanner-container {
    position: relative;
    margin: 15px 0;
}

#scanner-video {
    display: block;
    width: 100%;
    max-height: 300px;
}

/* Timer styles */
#scanner-timer {
    font-size: 1.1em;
    transition: color 0.3s;
}

/* Flash button active state */
#toggleFlash.active {
    background: #fff3cd !important;
    color: #856404 !important;
}

/* Camera button styles */
.camera-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.camera-btn:hover {
    background: #218838;
    transform: translateY(-1px);
}

.camera-btn:disabled {
    background-color: #6c757d;
    cursor: default;
}

.camera-btn i {
    margin-right: 5px;
}

/* Input with camera container */
.input-with-camera {
    position: relative;
    display: flex;
    width: 100%;
}

.input-with-camera input {
    flex: 1;
}

/* Responsive adjustments for scanner modal */
@media (min-width: 600px) {
    #scanner-container {
        height: 250px;
    }

    .scanner-laser {
        height: 25% !important;
    }
}

/* ========== PAGINATION STYLES ========== */
.pagination-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
    align-items: center;
}

.pagination-info {
    color: #666;
    font-size: 0.9rem;
    text-align: center;
    width: 100%;
}

.pagination-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

.page-size-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    justify-content: center;
    width: 100%;
}

.page-size-select {
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-family: 'Prompt', sans-serif;
    font-size: 0.9rem;
    background-color: var(--white-color);
    color: var(--dark-grey-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.page-btn {
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s;
    min-width: 36px;
    text-align: center;
}

.page-btn:hover:not(:disabled) {
    background: var(--light-grey-color);
    border-color: var(--primary-color);
}

.page-btn:disabled {
    cursor: not-allowed;
}

.page-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transition: 0.3s;
}

.page-numbers {
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.refresh-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    margin-bottom: 1rem;
}

.track-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: var(--primary-color-darker);
}

@media (max-width: 760px) {
    .pagination-controls {
        flex-direction: column;
    }

    .page-size-container {
        flex-direction: column;
        gap: 0.3rem;
    }

    .page-numbers {
        order: -1;
        margin-bottom: 1rem;
    }

    .refresh-btn {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0,0,0,.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state styling */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
}

.empty-state i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 1rem;
}

.parcel-mark-btn {
    padding: 4px 12px;
    background-color: var(--light-grey-color);
    color: var(--dark-grey-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}