/* =========================================================
   1. GLOBAL / BASE LAYOUT
========================================================= */

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f2f2f2;
}

/* Main page container (scanner pages) */
.container {
    max-width: 500px;
    margin: 15px auto 0;
    padding: 15px;
    text-align: center;
}

/* Wider layout for admin pages */
.admin-container {
    max-width: 1100px;
    margin: auto;
    padding: 20px;
}


/* =========================================================
   2. TYPOGRAPHY
========================================================= */

h2 {
    text-align: center;
}


/* =========================================================
   3. FORM CONTROLS (GLOBAL)
========================================================= */

select,
input,
button {
    width: 100%;
    padding: 14px;
    font-size: 18px;
    margin: 8px 0;
    border-radius: 6px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

button {
    background-color: #2c3e50;
    color: white;
    border: none;
    cursor: pointer;
}

button:active {
    opacity: 0.85;
}

/* Button Variants */
.logout-btn {
    background-color: #c0392b;
}

.export-btn {
    background-color: #27ae60;
}


/* =========================================================
   4. HEADER / TOP BAR
========================================================= */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background-color: #f2f2f2;
    position: relative;
    z-index: 9999; /* Above scanner */
}

/* Fixed side width ensures perfect title centering */
.header-left,
.header-right {
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Center title expands */
.header-center {
    flex: 1;
    text-align: center;
    padding: 0 10px;
}

.header-center h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
}

/* Logo */
.header-logo {
    width: 60px;
    height: auto;
    display: block;
}

.header-logo-admin {
    text-align: center;
    width: 60px;
}


/* =========================================================
   5. HAMBURGER MENU
========================================================= */

/* Prevent global 100% width rule affecting header buttons */
.top-bar button {
    width: auto;
    margin: 0;
}

/* Menu wrapper */
.menu {
    position: relative;
}

/* Hamburger button */
#menuToggle {
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

/* Dropdown panel */
.dropdown {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.2);
    width: 220px;
    overflow: hidden;
    z-index: 10000;
}

.dropdown.open {
    display: block;
}

/* Dropdown buttons */
.dropdown button {
    width: 100%;
    background: white;
    color: black;
    border: none;
    padding: 12px 16px;
    text-align: left;
    font-size: 16px;
    cursor: pointer;
}

.dropdown button:hover {
    background: #f2f2f2;
}


/* =========================================================
   6. SCANNER PAGE
========================================================= */

#reader {
    width: 100%;
    margin-top: 10px;
    position: relative;
    z-index: 1; /* Below header */
}

/* Prevent camera video from blocking taps */
video {
    pointer-events: none;
}

/* Scan result display */
#result {
    margin-top: 15px;
    font-size: 28px;
    font-weight: bold;
    min-height: 60px;
    padding: 10px;
    border-radius: 8px;
}

/* Confirmation panel */
.confirm-panel {
    display: none;
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.confirm-name {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 10px;
}

.confirm-details {
    margin-bottom: 15px;
}

.confirm {
    background: #27ae60;
}

.cancel {
    background: #c0392b;
}


/* =========================================================
   7. ACTIVE SCAN MODE DISPLAY
========================================================= */

#activeModeDisplay {
    display: none;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 12px;
    text-align: center;
}

.mode-entry {
    color: #27ae60;
}

.mode-exit {
    color: #c0392b;
}


/* =========================================================
   8. ADMIN PAGE
========================================================= */

/* Control bar */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.controls input,
.controls select,
.controls button {
    width: auto;
    flex: 1;
    padding: 10px;
    font-size: 16px;
}

/* Admin login width fix */
#loginSection {
    max-width: 500px;
    margin: 0 auto;
}

/* Data table */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th,
td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

th {
    background-color: #2c3e50;
    color: white;
}


/* =========================================================
   9. SCAN HISTORY LIST
========================================================= */

#scanList div {
    font-size: 15px;
}


/* =========================================================
   10. FOOTER / NAVIGATION
========================================================= */

#footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.8em;
}

.back-container {
    margin-top: 20px;
    text-align: center;
}

.back-btn {
    padding: 10px 20px;
}


/* =========================================================
   11. UTILITY CLASSES
========================================================= */

.hidden {
    display: none;
}


/* =========================================================
   12. RESPONSIVE ADJUSTMENTS
========================================================= */

@media (max-width: 768px) {

    .admin-container {
        padding: 15px;
    }

    .controls {
        flex-direction: column;
    }

    .controls input,
    .controls select,
    .controls button {
        width: 100%;
    }
}

/* Tighten header text on very small devices */
@media (max-width: 480px) {
    .header-center h1 {
        font-size: 15px;
    }
}

/* =========================================================
   ADMIN PAGINATION
========================================================= */

.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

/* Override global full-width button rule */
.pagination-controls button {
    width: auto;
    min-width: 120px;
    padding: 10px 20px;
}

#pageInfo {
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

/* =========================================================
   PAGINATION BUTTON STATES
========================================================= */

.pagination-controls button {
    width: auto;
    min-width: 120px;
    padding: 10px 20px;
    transition: background 0.2s ease, opacity 0.2s ease;
}

/* Active state */
.pagination-controls button:not(:disabled) {
    background-color: #2c3e50;
    color: white;
    cursor: pointer;
}

/* Hover only when enabled */
.pagination-controls button:not(:disabled):hover {
    background-color: #34495e;
}

/* Disabled state */
.pagination-controls button:disabled {
    background-color: #2c3e50;
    opacity: 0.45;
    cursor: not-allowed;
}

/* =========================================================
   ADMIN BACK BUTTON ALIGNMENT
========================================================= */

.back-container {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.back-container .back-btn {
    width: auto;          /* Override global 100% */
    min-width: 120px;     /* Match pagination buttons */
    padding: 10px 20px;
}

#searchResults {
    margin-top: 10px;
}

.search-result-item {
    padding: 8px;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
}

.search-result-item:hover {
    background-color: #f1f1f1;
}