/* =========================================================
   ROOT VARIABLES
   ========================================================= */

:root {
    --primary: #2563eb;
    --bg: #e4dad6;

    --text: #111827;
    --card: #ffffff;
    --border: #d1d5db;
}


/* =========================================================
   GLOBAL RESET
   ========================================================= */

* {
    box-sizing: border-box;
}


/* =========================================================
   BODY
   ========================================================= */

body {
    margin: 0;

    font-family: Arial, sans-serif;

    background: var(--bg);
    color: var(--text);
}


/* =========================================================
   APP HEADER
   ========================================================= */

.app-header {
    position: relative;

    text-align: center;

    padding: 12px 0;

    background: #ffffff;

    border-bottom: 1px solid #868687;
}


/* Company logo */

.app-header img {
    display: block;

    margin: 0 auto;

    width: 220px;

    max-width: 90%;

    height: auto;
}


/* =========================================================
   PAGE CONTAINER
   ========================================================= */

.page {
    display: none;

    padding: 16px;

    max-width: 500px;

    margin: auto;
}


/* Active page */

.page.active {
    display: block;
}


/* =========================================================
   COMMON HEADINGS
   ========================================================= */

h2 {
    text-align: center;

    margin-bottom: 12px;
}


/* =========================================================
   FORM CONTROLS
   ========================================================= */

input,
select,
textarea {
    width: 100%;

    padding: 12px;

    margin: 8px 0;

    font-size: 16px;

    border-radius: 8px;

    border: 1px solid #d1d5db;

    background: #ffffff;

    color: #111827;

    transition: all 0.2s ease;
}


/* =========================================================
   FORM CONTROL FOCUS
   ========================================================= */

input:focus,
select:focus,
textarea:focus {
    outline: none;

    border-color: #2563eb;

    box-shadow:
        0 0 0 2px rgba(37, 99, 235, 0.2);
}


/* =========================================================
   FORM CONTROL HOVER
   ========================================================= */

input:hover,
select:hover,
textarea:hover {
    border-color: #9ca3af;
}


/* =========================================================
   SELECT CUSTOM ARROW
   ========================================================= */

select {
    appearance: none;

    -webkit-appearance: none;

    -moz-appearance: none;

    cursor: pointer;

    background-image:
        url("data:image/svg+xml;utf8,<svg fill='%23666' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M5 7l5 5 5-5z'/></svg>");

    background-repeat: no-repeat;

    background-position: right 12px center;

    background-size: 18px;
}


/* =========================================================
   READONLY INPUT
   ========================================================= */

input[readonly] {
    background: #f3f4f6;

    cursor: not-allowed;
}


/* =========================================================
   PLACEHOLDER
   ========================================================= */

input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}


/* =========================================================
   NUMBER INPUT
   ========================================================= */

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;

    margin: 0;
}


input[type="number"] {
    appearance: textfield;

    -webkit-appearance: none;

    -moz-appearance: textfield;
}


/* =========================================================
   DATE INPUT
   ========================================================= */

input[type="date"] {
    color: #111827;

    color-scheme: light;
}


/* =========================================================
   BUTTONS
   ========================================================= */

button {
    background: var(--primary);

    color: #ffffff;

    border: none;

    border-radius: 6px;

    cursor: pointer;

    transition: 0.2s;
}


button:hover {
    opacity: 0.9;
}


/* Secondary button */

button.secondary {
    background: #444444;
}


/* =========================================================
   COMMON BROWSE PAGE
   ========================================================= */

.page.browse {
    max-width: 100%;

    margin: 0;
}


.page.browse .page-inner {
    width: 100%;

    max-width: none;

    margin: 0;

    display: flex;

    flex-direction: column;

    height: calc(100vh - 90px);
}


/* =========================================================
   BROWSE TOP BAR
   ========================================================= */

.browse-top {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 10px;

    flex-wrap: wrap;

    position: sticky;

    top: 0;

    background: var(--bg);

    z-index: 5;

    padding-bottom: 8px;
}


/* =========================================================
   TABLE WRAPPER
   ========================================================= */

.table-wrapper {
    background: #ffffff;

    border-radius: 10px;

    border: 1px solid #e5e7eb;

    overflow-x: auto;

    overflow-y: auto;

    position: relative;

    flex: 1;
}


/* =========================================================
   TABLE
   ========================================================= */

table {
    width: max-content;

    min-width: 100%;

    border-collapse: collapse;

    font-size: 14px;

    table-layout: fixed;

    border: 1px solid #e5e7eb;
}


/* =========================================================
   TABLE HEADER
   ========================================================= */

thead th {
    background: #f9fafb;

    color: #374151;

    padding: 12px 14px;

    border: 1px solid #e5e7eb;

    text-align: left;

    position: sticky;

    top: 0;

    z-index: 1000;

    background-clip: padding-box;
}


/* Table header cells */

th {
    position: relative;

    overflow: hidden;

    white-space: nowrap;
}


/* =========================================================
   TABLE RESIZE HANDLE
   ========================================================= */

.resizer {
    position: absolute;

    top: 0;

    right: -3px;

    width: 8px;

    height: 100%;

    cursor: col-resize;

    user-select: none;

    touch-action: none;

    z-index: 10;
}


/* =========================================================
   TABLE BODY
   ========================================================= */

tbody td {
    padding: 12px 14px;

    border: 1px solid #f1f5f9;
}


/* Vertical separators */

thead th:not(:last-child),
tbody td:not(:last-child) {
    border-right: 2px solid #d1d5db;
}


/* Row hover */

tbody tr:hover {
    background: #f8fafc;
}


/* =========================================================
   TABLE ACTION BUTTON
   ========================================================= */

.action-btn {
    width: auto;

    background: none;

    border: none;

    color: #2563eb;

    cursor: pointer;

    font-size: 13px;

    padding: 4px 8px;

    margin: 0;
}


.action-btn.delete {
    color: #dc2626;
}


/* Prevent last column wrapping */

td:last-child {
    white-space: nowrap;
}


/* =========================================================
   MOBILE CARDS
   ========================================================= */

.mobile-cards {
    display: none;
}


.card {
    background: #ffffff;

    padding: 12px;

    margin: 10px 0;

    border-radius: 8px;

    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.05);
}


/* Card buttons */

.card button {
    width: auto;

    padding: 6px 10px;

    font-size: 14px;

    margin-right: 6px;
}


/* =========================================================
   BROWSE HEADER
   ========================================================= */

.browse-header {
    display: flex;

    justify-content: flex-start;

    margin-bottom: 12px;
}


/* =========================================================
   PAGINATION
   ========================================================= */

.pagination {
    display: flex;

    justify-content: center;

    align-items: center;

    gap: 8px;

    margin: 1px 0;
}


.page-btn {
    width: auto !important;

    padding: 6px 10px;

    font-size: 13px;

    border-radius: 6px;
}


#pageNo {
    min-width: 5px;

    text-align: center;

    font-weight: bold;

    font-size: 15px;
}


/* =========================================================
   MOBILE TABLE → CARDS
   ========================================================= */

@media (max-width: 768px) {

    .table-wrapper {
        display: none;
    }

    .mobile-cards {
        display: block;
    }

}


/* =========================================================
   COMMON CONTAINER
   ========================================================= */

.container {
    max-width: 900px;

    margin: 20px auto;

    padding: 25px;

    background: #ffffff;

    border-radius: 10px;

    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.12);
}


/* =========================================================
   BACK BUTTON
   ========================================================= */

#backBtn {
    position: absolute;

    left: 15px;

    top: 50%;

    transform: translateY(-50%);

    padding: 6px 10px;

    font-size: 14px;
}


/* =========================================================
   DARK MODE BUTTON
   ========================================================= */

.app-header button:last-child {
    position: absolute;

    right: 15px;

    top: 50%;

    transform: translateY(-50%);

    padding: 6px 10px;

    font-size: 14px;
}


/* =========================================================
   DARK MODE
   ========================================================= */

html.dark {
    color-scheme: dark;

    --bg: #172137;

    --text: #f9fafb;

    --card: #031123;

    --border: #374151;
}


html:not(.dark) {
    color-scheme: light;
}


/* Page/body */

html.dark {
    background: var(--bg);

    color: var(--text);
}


/* Header */

html.dark .app-header {
    background: var(--card);

    border-color: var(--border);
}


/* Inputs */

html.dark input,
html.dark select,
html.dark textarea {
    background: var(--card);

    color: var(--text);

    border-color: var(--border);
}


/* Date input */

html.dark input[type="date"] {
    background: var(--card);

    color: var(--text);

    border-color: var(--border);

    color-scheme: dark;
}


/* Date calendar icon */

html.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(100%);

    opacity: 1;
}


/* Browse table */

html.dark .table-wrapper {
    background: var(--card);

    border-color: var(--border);
}


html.dark thead th {
    background: var(--card);

    color: var(--text);

    border-color: var(--border);
}


html.dark tbody td {
    border-color: var(--border);
}


html.dark tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}


/* Cards */

html.dark .card {
    background: var(--card);

    border: 1px solid var(--border);
}


/* Browse top */

html.dark .browse-top {
    background: var(--bg);
}


/* Common container */

html.dark .container {
    background: var(--card);

    color: var(--text);
}


/* =========================================================
   DARK MODE SCROLLBAR
   ========================================================= */

html.dark ::-webkit-scrollbar {
    width: 10px;

    height: 10px;
}


html.dark ::-webkit-scrollbar-track {
    background: #111827;
}


html.dark ::-webkit-scrollbar-thumb {
    background: #4b5563;

    border-radius: 6px;
}


html.dark ::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}


html.dark {
    scrollbar-color: #4b5563 #111827;
}


/* =========================================================
   RESPONSIVE COMMON
   ========================================================= */

@media (max-width: 768px) {

    .page {
        padding: 12px;
    }

}


/* =========================================================
   PDF OVERLAY
   ========================================================= */

#pdfOverlay {
    position: fixed;

    inset: 0;

    z-index: 9999;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 20px;

    box-sizing: border-box;

    background: rgba(0, 0, 0, 0.65);
}


/*
   If JS changes display to block,
   this makes the overlay content centered.
*/

#pdfOverlay[style*="block"] {
    display: flex !important;
}


/* =========================================================
   PDF CONTAINER
   ========================================================= */

#pdfOverlay .pdf-container {
    width: min(100%, 1000px);

    height: min(92vh, 850px);

    display: flex;

    flex-direction: column;

    overflow: hidden;

    background: #ffffff;

    border-radius: 18px;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.35);
}


/* =========================================================
   PDF HEADER
   ========================================================= */

#pdfOverlay .pdf-header {
    min-height: 54px;

    padding: 10px 14px;

    box-sizing: border-box;

    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 12px;

    background: #f3f4f6;

    border-bottom: 1px solid #e5e7eb;
}

#pdfOverlay .pdf-header b {
    font-size: 15px;
}


/* PDF close button */

#pdfOverlay .pdf-header button {
    width: auto;

    margin: 0;

    padding: 7px 13px;

    border: none;
    border-radius: 8px;

    background: #374151;
    color: #ffffff;

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;
}


/* =========================================================
   PDF VIEWER
   ========================================================= */

#pdfViewer {
    width: 100%;

    flex: 1;

    min-height: 0;

    border: none;

    background: #ffffff;
}

