/* FILE: css/style.css */
:root {
    --primary-blue: #03508c;
    --deped-green: #2c883f;   /* CHANGED: was #15803d */
    --text-main: #334155;
    --border-light: #e2e8f0;
    --bg-page: #f8f9fa;

    /* Shared timing/easing for every modal in the app -- ported from
       the reference contact-us.php modal system. */
    --modal-duration: 0.3s;
    --modal-ease: ease;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Nunito', sans-serif;
    color: var(--text-main);
    background: var(--bg-page);
}

/* MAIN APP BACKGROUND — same diagonal pattern as login */
.page-shell {
    position: relative;   /* anchor point for the pattern layer */
    display: flex;
    flex-direction: column;
    min-height: 100vh;    /* lets the footer stick to the bottom when content is short */
}
.page-shell::before {
    content: "";
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: -1;
    background-image: url('../assets/deped_nir_pattern.webp');
    background-repeat: repeat;
    background-size: 120px 120px;
    transform: rotate(-45deg);
    opacity: 0.06;             /* slightly lighter than login's 0.08 — see note below */
    filter: grayscale(100%);
}

.page-shell.modal-frame-shell::before {
    display: none; /* no watermark inside a modal iframe -- it's not a standalone page */
}
.page-shell.modal-frame-shell {
    background: #fff; /* blend seamlessly with the modal box instead of showing the page's off-white bg */
}

.page-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.app-header {
    background: var(--deped-green);   /* CHANGED: was var(--primary-blue) */
    color: #fff;
}
.app-header-inner {
    max-width: 1800px;
    margin: 0 auto;
    padding: 10px 32px;      /* CHANGED: was 16px 32px — shorter bar */
    display: flex;
    align-items: center;      /* CHANGED: was baseline — vertical centering */
    gap: 12px;                 /* CHANGED: was 10px — a touch more breathing room next to bigger logo */
}
.app-header-title { font-weight: 700; font-size: 1.2rem; }
.app-header-sub { font-size: 0.85rem; opacity: 0.8; }
.app-header-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-header-pill {
    display: inline-flex;
    align-items: center;
    background: #fff;
    color: var(--deped-green);
    padding: 8px 18px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.app-header-pill:hover {
    background: #f0fdf4;
}
.app-header-pill--danger {
    background: #fef2f2;
    color: #b91c1c;
}
.app-header-pill--danger:hover {
    background: #fee2e2;
}
.app-header-logo {
    height: 40px;      /* CHANGED: was 32px — bigger logo */
    width: auto;
    display: block;
}

/* TABS (real links styled as folder tabs) */
.tabs {
    max-width: 1800px;
    width: 100%;
    margin: 20px auto 0;
    padding: 0 32px;
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    box-sizing: border-box;
    position: relative;       /* NEW: anchor point for the border line below */
    /* border-bottom removed from here */
}

.tabs::after {
    content: "";
    position: absolute;
    left: 32px;                /* matches .tabs padding */
    right: 32px;                /* matches .tabs padding */
    bottom: 0;
    border-bottom: 3px solid var(--border-light);
}

.tabs-row {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    border-bottom: 3px solid var(--border-light);  /* moved here */
}

.tab-link {
    flex: 1;
    text-align: center;
    padding: 10px 18px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    background: #eef1f4;
    border: 1px solid var(--border-light);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    transform: translateY(1px);
    white-space: nowrap;
    position: relative;   /* NEW */
    z-index: 1;            /* NEW: sits above the border line */
}

.tabs::after {
    content: "";
    position: absolute;
    left: 32px;
    right: 32px;
    bottom: 0;
    border-bottom: 3px solid var(--border-light);
    z-index: 0;             /* NEW: explicitly behind the tabs */
}

.page-main {
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
    padding: 0 32px 32px;
    box-sizing: border-box;
}
.tab-link {
    display: inline-block;
    padding: 10px 18px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    background: #eef1f4;
    border: 1px solid var(--border-light);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    transform: translateY(1px);
}
.tab-link:hover { background: #e2e8f0; }
.tab-link.active {
    background: var(--deped-green);   /* CHANGED: was #fff */
    border-color: var(--deped-green); /* CHANGED: was var(--border-light) */
    color: #fff;                      /* CHANGED: was var(--primary-blue) */
    transform: translateY(1px);       /* CHANGED: was translateY(3px) — see note below */
}

/* PAGE BODY / CONTENT CARD */
.tab-container-wrapper {
    width: 100%;
    flex: 1;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 0 0 12px 12px;
    padding: 30px 40px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    box-sizing: border-box;
}

h1, h2, h3 { color: var(--text-main); }

/* FORMS */
.entry-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
    margin-bottom: 30px;
    padding-bottom: 24px;
    border-bottom: 2px dotted #ccc;
}
.entry-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.entry-form label .hint {
    font-weight: 400;
    color: #64748b;
}
.entry-form input,
.entry-form select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
}
.entry-form button {
    background: var(--deped-green);   /* CHANGED: was var(--primary-blue) */
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
}
.entry-form button:hover { background: #206b32; }  /* CHANGED: darker green, was #023d6d */
.entry-form button:hover { background: rgb(1, 124, 56); }

/* TABLE */
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
table.data-table th,
table.data-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
}
table.data-table th {
    background: #f1f5f9;
    font-weight: 700;
}
table.data-table td.amount { text-align: right; }
table.data-table tfoot td {
    font-weight: 700;
    border-top: 2px solid var(--text-main);
}

.upload-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 12px;
}
.upload-row label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.upload-row select,
.upload-row input[type="file"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
}
.remove-row-btn {
    background: #fff;
    border: 1px solid #b91c1c;
    color: #b91c1c;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.add-row-btn {
    background: #fff;
    border: 2px dashed var(--border-light);
    color: var(--text-main);
    padding: 8px 18px;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
}
.add-row-btn:hover {
    border-color: var(--deped-green);
    color: var(--deped-green);
}

.placeholder-note {
    color: #64748b;
    font-style: italic;
}

.batch-details {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: 8px;
}
.batch-details summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--primary-blue);
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.filter-bar label {
    font-weight: 700;
}
.filter-bar input,
.filter-bar select {
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
}
.filter-bar select#per_page {
    margin-right: 12px;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-main);
}
.pagination-links {
    display: flex;
    align-items: center;
    gap: 14px;
}
.pagination-links a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 700;
}
.pagination-links a:hover {
    text-decoration: underline;
}
.pagination-current {
    color: #64748b;
}

.badge-list {
    display: inline-block;
    background: #eef2ff;
    color: var(--deped-green);   /* CHANGED: was var(--primary-blue) */
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.modern-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 2px solid var(--border-light);
    padding: 10px 22px;
    border-radius: 50px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.modern-download-btn:hover {
    border-color: var(--deped-green);   /* CHANGED: was var(--primary-blue) */
    color: var(--deped-green);          /* CHANGED: was var(--primary-blue) */
}
.modern-download-btn.small {
    padding: 6px 16px;
    font-size: 0.85rem;
}
/* Edit / View Itemized buttons in the table's action column -- same width
   regardless of label length ("Edit" vs "View Itemized (31)"), even
   though a long label wrapping to 2-3 lines means the button itself ends
   up taller. Scoped to this specific class rather than all
   .modern-download-btn.small buttons, since those are reused elsewhere
   (Download, Create Batch, etc.) where auto-width is what we want. */
.action-btn {
    width: 120px;
    justify-content: center;
    text-align: center;
    white-space: normal;
    line-height: 1.3;
}

.monitoring-table th, .monitoring-table td {
    vertical-align: top;
}

/* MODAL VIEWER */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--modal-duration) var(--modal-ease), visibility var(--modal-duration) var(--modal-ease);
}
.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}
.modal-box {
    position: relative;
    width: 90vw;
    height: 90vh;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(20px) scale(0.98);
    transition: transform var(--modal-duration) var(--modal-ease);
}
.modal-overlay.open .modal-box {
    transform: translateY(0) scale(1);
}
.modal-frame {
    width: 100%;
    height: 100%;
    border: none;
}
.modal-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    z-index: 1001;
}

/* Content-sized modal variant -- for edit-entry/manage forms where the
   content is much shorter than 90vh. The PDF/image attachment viewer
   still uses the plain full-height .modal-box, since that benefits from
   filling the available space. */
.modal-box.auto-height {
    height: auto;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
}
.modal-box.auto-height .modal-frame {
    height: auto;
    display: block;
}
.modal-box.narrow {
    width: min(90vw, 600px); /* for simple single-column forms -- no need for the full 90vw meant for wide multi-column forms */
}

/* Itemize modal: header (title + close) and footer (total) stay fixed;
   only the middle row list scrolls. Overrides .modal-box.auto-height's own
   overflow-y since this variant manages its own inner scroll region
   instead of scrolling the whole box. */
.modal-box.itemize-modal-box {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.itemize-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 50px 16px 30px; /* room on the right for the close button */
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.itemize-modal-header h3 {
    margin: 0;
}
.itemize-modal-scroll {
    padding: 20px 30px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0; /* required for a flex child to actually be scrollable */
}
.itemize-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 30px;
    border-top: 1px solid var(--border-light);
    font-weight: 700;
    flex-shrink: 0;
}

/* LOGIN PAGE */
.login-page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.login-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
}
.login-page .login-shell {
    background: transparent;   /* NEW: let body's pattern show through */
}
.login-box {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.login-box h2 {
    font-size: 1.3rem;
    margin-top: 0;
    margin-bottom: 20px;
}
.login-box div {
    margin-bottom: 16px;
}
.login-box label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.login-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
}
.login-box button {
    width: 100%;
    background: var(--deped-green);   /* CHANGED: was var(--primary-blue) */
    color: #fff;
    border: none;
    padding: 12px;
    border-radius: 20px;
    font-weight: 700;
    cursor: pointer;
}
.login-box button:hover { background: #206b32; }  /* CHANGED: darker green, was #023d6d */

/* FOOTER */
.app-footer {
    margin-top: 40px;
    padding: 16px 0;
    text-align: center;
    color: #64748b;
    font-size: 0.85rem;
}

/* LOGIN PAGE — REDESIGN */
body.login-page {
    margin: 0;
    background-color: #f3f4f6;
    position: relative;
}
body.login-page::before {
    content: "";
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: -1;
    background-image: url('../assets/deped_nir_pattern.webp');
    background-repeat: repeat;
    background-size: 120px 120px;
    transform: rotate(-45deg);
    opacity: 0.08;
    filter: grayscale(100%);
}

.login-box {
    padding: 0;                 /* overrides old .login-box padding — header/body handle their own now */
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--deped-green) 0%, #1a5c28 100%);
    position: relative;
    overflow: hidden;
    padding: 36px 40px 28px;
    text-align: center;
}
.login-header-watermark {
    position: absolute;
    top: -75%;
    left: -75%;
    width: 250%;
    height: 250%;
    background-image: url('../assets/deped_nir.webp');   /* CHANGED: removed .net typo */
    background-repeat: repeat;
    background-size: 150px 150px;
    opacity: 0.15;
    transform: rotate(-15deg) scale(1.5);
    pointer-events: none;
}
.login-header-content { position: relative; z-index: 1; }
.login-logo {
    height: 64px;
    width: 64px;
    display: block;
    margin: 0 auto 12px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}
.login-header h1 {
    color: #fff;
    font-size: 1.25rem;
    margin: 0;
    font-weight: 800;
    letter-spacing: 0.3px;
}
.login-header p {
    color: #dcfce7;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 8px;
    opacity: 0.9;
}

.login-body { padding: 32px 40px 28px; }

.login-field-wrap { position: relative; }
.login-field-wrap input {
    padding-left: 38px;
    padding-right: 38px;
}
.login-field-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
    display: flex;
}
.login-toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    width: auto;
    padding: 4px;
    display: flex;
}
.login-toggle-password:hover { color: var(--deped-green); }

.login-error {
    background: #fef2f2;
    border-left: 4px solid #b91c1c;
    color: #b91c1c;
    padding: 10px 12px;
    margin-bottom: 18px;
    font-size: 0.85rem;
    font-weight: 600;
}

.login-box button.login-toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    width: auto;
    padding: 4px;
    display: flex;
}
.login-box button.login-toggle-password:hover { color: var(--deped-green); }

/* Attachments grid (Modal A body): buttons laid out in a wrapping grid */
.att-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}
.att-grid-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: var(--text-main, #1e293b);
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: left;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.att-grid-btn:hover {
    background: #e2e8f0;
    border-color: var(--primary-blue, #2563eb);
}

/* The viewer modal (Modal B) must stack above the attachments grid modal
   (Modal A) when opened from within it. Explicit !important since the
   exact base .modal-overlay z-index isn't known from here -- this
   guarantees correct stacking regardless of that value. */
.modal-overlay.nested-modal.open {
    z-index: 10000 !important;
}

/* Checkbox-based batch creation: a small sticky action bar that appears
   once at least one entry checkbox is selected. */
.batch-select-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f0fdf4;
    border: 1px solid var(--deped-green);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.batch-select-bar span {
    font-weight: 700;
    color: var(--deped-green);
    white-space: nowrap;
}
.batch-select-bar input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
}
.batch-select-bar button {
    background: var(--deped-green);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.batch-select-bar button:hover {
    background: #206b32;
}

/* Search tab: narrower than the other flex-grown tabs, just wide enough
   for the icon + label. Always last in the $tabs array, so it naturally
   sits at the far right of the bar. Dark grey at rest (not the same light
   grey as the content tabs) so it reads as a distinct utility, not just
   another section -- green when active, same as every other tab. */
.tab-link-search {
    flex: 0 0 auto;
    padding-left: 14px;
    padding-right: 14px;
    background: #475569;
    border-color: #475569;
    color: #fff;
}
.tab-link-search:hover {
    background: #334155;
    border-color: #334155;
    color: #fff;
}
.tab-link-search.active {
    background: var(--deped-green);
    border-color: var(--deped-green);
    color: #fff;
}

/* Middle z-index tier: sits above the base itemize modal but below the
   attachment viewer, so "Attachments grid -> Viewer" still nests correctly
   even when opened from within the itemize modal (three-level stack:
   itemize=default 1000, attachments-grid=5000, viewer=10000). */
.modal-overlay.mid-modal.open {
    z-index: 5000 !important;
}