/* src/assets/styles/reports.css */

/* --- 1. Main Layout --- */
.rpt-container {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--secondary-bg);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.rpt-header {
    margin-bottom: 15px;
    color: var(--sidebar-bg);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

/* --- 2. Filter / Toolbar Area --- */
.rpt-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
    box-shadow: var(--shadow-soft);
}

.rpt-input,
.rpt-select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: #495057;
    outline: none;
    transition: border-color 0.2s;
}

.rpt-input:focus,
.rpt-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 75, 135, 0.15);
}

.rpt-spacer {
    flex-grow: 1;
}

/* --- 3. Data Table --- */
.rpt-table-wrapper {
    flex: 1;
    overflow: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-soft);
}

.rpt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    table-layout: fixed;
}

.rpt-table thead {
    background-color: var(--sidebar-bg);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.rpt-table th,
.rpt-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    vertical-align: top;
}

.rpt-table tbody tr:hover {
    background-color: var(--secondary-bg);
}

.rpt-table th {
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

/* --- 4. Buttons --- */
.rpt-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
    color: white;
}

.rpt-btn:hover {
    opacity: 0.9;
}

.rpt-btn-primary {
    background-color: var(--primary-color);
}

.rpt-btn-secondary {
    background-color: #95a5a6;
}

.rpt-btn-danger {
    background-color: var(--danger-color);
}

.rpt-btn-success {
    background-color: var(--success-color);
}

/* --- 5. Status Badges --- */
.rpt-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* =========================================================
   6. VERIFICATION REPORT SPECIFICS & PRINT FORMATTING
   ========================================================= */

#vv-report-table {
    table-layout: fixed;
}

#vv-report-table th:nth-child(1) {
    width: 16%;
}

#vv-report-table th:nth-child(2) {
    width: 14%;
}

#vv-report-table th:nth-child(3) {
    width: 14%;
}

#vv-report-table th:nth-child(4) {
    width: 10%;
}

#vv-report-table th:nth-child(5) {
    width: 14%;
}

#vv-report-table th:nth-child(6) {
    width: 10%;
}

#vv-report-table th:nth-child(7) {
    width: 22%;
}

#vv-report-table td {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    vertical-align: top;
}

/* Filter Summary — hidden on screen, visible on print */
#print-filter-summary {
    display: none;
    margin-bottom: 20px;
    padding: 10px;
    background: var(--secondary-bg);
    border-left: 4px solid var(--primary-color);
    font-size: 0.9em;
    color: var(--text-main);
}

/* =========================================================
   REPORT-SPECIFIC COLUMN WIDTHS
   ========================================================= */

/* Transaction Report */
#transaction-report-table th:nth-child(1) {
    width: 16%;
}

#transaction-report-table th:nth-child(2) {
    width: 12%;
}

#transaction-report-table th:nth-child(3) {
    width: 12%;
}

#transaction-report-table th:nth-child(4) {
    width: 12%;
}

#transaction-report-table th:nth-child(5) {
    width: 12%;
}

#transaction-report-table th:nth-child(6) {
    width: 12%;
}

#transaction-report-table th:nth-child(7) {
    width: 24%;
}

/* User Permission Report */
#user-perm-table th:nth-child(1) {
    width: 15%;
}

#user-perm-table th:nth-child(2) {
    width: 18%;
}

#user-perm-table th:nth-child(3) {
    width: 18%;
}

#user-perm-table th:nth-child(4) {
    width: 16%;
}

#user-perm-table th:nth-child(5) {
    width: 16%;
}

#user-perm-table th:nth-child(6) {
    width: 17%;
}

/* Workorder Report */
#wo-report-table th:nth-child(1) {
    width: 15%;
}

#wo-report-table th:nth-child(2) {
    width: 30%;
}

#wo-report-table th:nth-child(3) {
    width: 12%;
}

#wo-report-table th:nth-child(4) {
    width: 12%;
}

#wo-report-table th:nth-child(5) {
    width: 16%;
}

#wo-report-table th:nth-child(6) {
    width: 15%;
}

/* =================================================================
   CABLE INSTALLATION CARD
   Portrait, letter (8.5×11). Left margin 1.25in for 3-hole punch.
   ================================================================= */

/* ── Card container ─────────────────────────────────── */
.ic-card {
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 9pt;
    color: #000;
    background: #fff;
    padding: 0.40in 0.45in 0.25in 1.25in;
    box-sizing: border-box;
    width: 8.5in;
    min-height: 10.5in;
    position: relative;
    display: flex;
    flex-direction: column;
}
.ic-page-break { page-break-after: always; }

/* ── Title bar ──────────────────────────────────────── */
.ic-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 2.5pt solid #003366;
    padding-bottom: 4pt;
    margin-bottom: 7pt;
}
.ic-title-left  { display: flex; align-items: baseline; gap: 8pt; }
.ic-title-text  { font-size: 14pt; font-weight: 700; color: #003366; letter-spacing: 0.3pt; }
.ic-rs-badge {
    font-size: 7.5pt; font-weight: 700;
    padding: 1pt 6pt; border-radius: 3pt;
    letter-spacing: 0.3pt;
}
.ic-print-date  { font-size: 8pt; color: #444; }
.ic-underline   { border-bottom: 1pt solid #888; display: inline-block; }

/* ── Identity ───────────────────────────────────────── */
.ic-identity    { margin-bottom: 5pt; }
.ic-id-row      { display: flex; align-items: baseline; gap: 5pt; flex-wrap: wrap; }
.ic-desc        { font-size: 8pt; color: #444; margin-top: 2pt; }

.ic-lbl {
    font-weight: 600;
    color: #003366;
    font-size: 7.5pt;
    white-space: nowrap;
}
.ic-val {
    font-size: 8.5pt;
    border-bottom: 1pt solid #bbb;
    padding-bottom: 1pt;
    min-width: 50pt;
}
.ic-mono  { font-family: "Consolas", monospace; }
.ic-large { font-size: 11pt; font-weight: 700; }

/* ── FROM / TO endpoints ────────────────────────────── */
.ic-endpoints   { margin-bottom: 5pt; }
.ic-endpoint-row {
    display: grid;
    grid-template-columns: 36pt 1fr 1fr 40pt;
    gap: 3pt 8pt;
    align-items: start;
    margin-bottom: 3pt;
}
.ic-endpoint-tag {
    font-weight: 700; font-size: 7.5pt;
    color: #fff; text-align: center;
    padding: 2pt 0; border-radius: 3pt;
    letter-spacing: 1pt;
}
.ic-endpoint-body   { display: flex; flex-direction: column; gap: 1pt; }
.ic-endpoint-name   { font-size: 11pt; font-weight: 700; font-family: "Consolas", monospace; line-height: 1.2; }
.ic-endpoint-type   { font-size: 7.5pt; color: #555; }
.ic-endpoint-desc   { font-size: 7.5pt; color: #777; }
.ic-endpoint-room   { font-size: 8pt; color: #224; font-style: italic; align-self: center; }
.ic-endpoint-len    { font-size: 8pt; font-family: "Consolas", monospace; text-align: right; align-self: center; color: #444; }

/* ── Attributes bar ─────────────────────────────────── */
.ic-attribs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3pt 8pt;
    background: #f0f4f8;
    border: 1pt solid #c0cfe0;
    border-radius: 3pt;
    padding: 5pt 8pt;
    margin-bottom: 6pt;
}
.ic-attrib-cell .ic-lbl { display: block; margin-bottom: 1pt; }
.ic-attrib-cell .ic-val { font-size: 8.5pt; border-bottom: none; font-weight: 600; min-width: 0; }

/* ── Section header ─────────────────────────────────── */
.ic-section-hdr {
    font-size: 7.5pt; font-weight: 700;
    color: #003366; text-transform: uppercase;
    letter-spacing: 0.4pt; border-bottom: 1pt solid #003366;
    padding-bottom: 2pt; margin-bottom: 4pt;
}

/* ── Routing wrapper — this is the flex child that expands ── */
.ic-routing-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ── Routing grid ───────────────────────────────────── */
.ic-routing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14pt;
    margin-bottom: 4pt;
    flex: 1;
    align-content: start;
}
.ic-rt {
    width: 100%;
    border-collapse: collapse;
    font-size: 8pt;
}
.ic-rt thead tr { background: #003366; color: #fff; }
.ic-rt th {
    padding: 2.5pt 4pt;
    text-align: left;
    font-size: 7pt;
    font-weight: 600;
    letter-spacing: 0.2pt;
}
.ic-rt td       { padding: 2.5pt 4pt; border-bottom: 0.5pt solid #dde4ec; vertical-align: top; }
.ic-rt .ic-alt td { background: #f5f8fc; }

.ic-rt-seq  { width: 20pt; text-align: right; font-family: "Consolas", monospace; font-size: 7pt; color: #888; }
.ic-rt-name { font-family: "Consolas", monospace; font-weight: 600; font-size: 8pt; }
.ic-rt-type { font-size: 7pt; color: #555; width: 48pt; }
.ic-rt-room { font-size: 7pt; color: #336; font-style: italic; }
.ic-rt-len  { width: 30pt; text-align: right; font-size: 7.5pt; font-family: "Consolas", monospace; color: #444; }

.ic-ep-row td   { background: #e8eef4 !important; font-size: 7.5pt; }
.ic-total-row td {
    border-top: 1pt solid #003366;
    font-weight: 700; font-size: 8pt;
    background: #f0f4f8 !important;
}
.ic-empty-msg {
    font-style: italic; color: #aaa; font-size: 7.5pt;
    text-align: center; padding: 8pt 0 !important;
}

/* ── Comments ───────────────────────────────────────── */
.ic-comment-line { display: flex; align-items: flex-end; gap: 5pt; }
.ic-fill-line    { flex: 1; border-bottom: 1pt solid #888; height: 14pt; }

/* ── Sign-off ───────────────────────────────────────── */
.ic-signoff {
    display: grid;
    grid-template-columns: 2fr 1fr 2fr 1fr;
    gap: 4pt 10pt;
    border: 1pt solid #c0cfe0;
    border-radius: 3pt;
    padding: 6pt 10pt;
    background: #fafcff;
}
.ic-sig-cell .ic-lbl  { display: block; margin-bottom: 2pt; }
.ic-sig-line { border-bottom: 1pt solid #555; height: 16pt; display: block; }

/* ── Footer ─────────────────────────────────────────── */
.ic-spacer { flex: 1; }   /* pushes footer to bottom inside flex column */
.ic-footer {
    display: flex;
    justify-content: space-between;
    border-top: 1pt solid #c0cfe0;
    margin-top: 8pt; padding-top: 3pt;
    font-size: 6.5pt; color: #888;
}
/* Page counter — blank on screen, "Page N of M" on print */
.ic-footer-pagenum::after { content: ""; }

/* ── Screen preview wrapper (non-print) ─────────────── */
#card-shell { background: #e0e0e0; min-height: 100vh; padding: 20px; }
.ic-card {
    background: white;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    margin: 0 auto 30px;
    border: 1px solid #ccc;
}

/* --- PDF / Print Isolation Engine --- */
@media print {

    body * {
        visibility: hidden;
    }

    .sidebar,
    .topbar,
    .rpt-toolbar {
        display: none !important;
    }

    .rpt-container,
    .rpt-container * {
        visibility: visible;
    }

    .rpt-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border-radius: 0;
        background-color: white;
        height: auto;
    }

    #print-filter-summary {
        display: block !important;
    }

    .rpt-table-wrapper {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        border: none !important;
        box-shadow: none !important;
    }

    .rpt-badge {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ── Cable Installation Card print overrides ── */

    /* CSS page counter — "Page N of M" in footer right slot */
    body { counter-reset: ic-page; }
    .ic-card { counter-increment: ic-page; }
    .ic-footer-pagenum::after {
        content: "Page " counter(ic-page);
    }

    #card-shell,
    #card-shell * {
        visibility: visible;
    }
    #card-shell {
        position: absolute;
        left: 0; top: 0;
        background: white;
        padding: 0;
        margin: 0;
        width: 100%;
    }
    .ic-card {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        width: 8.5in;
        padding: 0.40in 0.45in 0.35in 1.25in;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .ic-page-break { page-break-after: always; }
    /* Hide screen-only controls */
    #btn-print, #btn-back, #card-status { display: none !important; }

    @page {
        size: letter portrait;
        margin: 0;
    }
}