/* ============================================================
   app-views.css
   View-specific selectors for MIS and Reports.
   Tokens come from style.css; no colours of our own here.
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   SHARED PAGE SHELL — used by mis.html and report.html
   ──────────────────────────────────────────────────────────── */

.wf-page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--surface);
    font-family: var(--font-body);
    color: var(--on-surface);
}

/* ────────────────────────────────────────────────────────────
   MIS — view selector tabs
   ──────────────────────────────────────────────────────────── */

.view-selector {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 10px;
    background: var(--surface-container-lowest);
    border-bottom: 2px solid var(--outline-variant);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.view-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--outline-variant);
    background: var(--surface-container-low);
    color: var(--on-surface-variant);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.view-btn i { font-size: 14px; }
.view-btn:hover { background: var(--surface-container); }
.view-btn.active {
    background: var(--primary);
    color: var(--on-primary);
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* ────────────────────────────────────────────────────────────
   MIS — graph selection cards (rotating M3 palette)
   ──────────────────────────────────────────────────────────── */

.graph-selection-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 40px 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ────────────────────────────────────────────────────────────
   MIS — chart layout
   ──────────────────────────────────────────────────────────── */

#MIS.tab-content {
    padding: 20px !important;
    overflow-y: auto !important;
    background: var(--surface);
    height: calc(100vh - 130px);
}

.main-layout { width: 100%; margin: 0 auto; max-width: 1400px; }
.section-fullscreen { width: 100%; margin-bottom: 20px; display: block; min-height: calc(100vh - 250px); }

.card-full {
    background: var(--surface-container-lowest);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    padding: 30px;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 500px;
    border: 1px solid var(--outline-variant);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--surface-container-high);
    padding-bottom: 12px;
    flex-shrink: 0;
}
.legend-sla { font-size: 11px !important; gap: 10px !important; }

.chart-container,
.pie-container {
    flex-grow: 1;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.pie-container { max-height: 500px; margin: 0 auto; }

.view-selector + .main-layout canvas,
.tab-content canvas {
    display: block !important;
    max-width: 100%;
    max-height: 100%;
}

/* ────────────────────────────────────────────────────────────
   Pagination — used in MIS drill-downs
   ──────────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
    user-select: none;
}
.page-info {
    font-weight: normal;
    color: var(--on-surface-variant);
    font-size: 13px;
    margin: 0 4px;
}
.btn-pagination {
    background: transparent;
    color: var(--on-surface-variant);
    border: none;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.btn-pagination:hover:not(:disabled) {
    background: var(--surface-container);
    color: var(--on-surface);
}
.btn-pagination:disabled { color: var(--outline-variant); cursor: default; }
.btn-pagination span { font-size: 14px; line-height: 1; }

/* ────────────────────────────────────────────────────────────
   MIS — drill-down overlay
   ──────────────────────────────────────────────────────────── */

#drillDownContainer {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    padding: 40px;
    box-sizing: border-box;
}
#drillDownCard {
    height: 85vh;
    width: 85%;
    margin: 6vh auto;
    background: var(--surface-container-lowest);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}
#drillDownCard h2 { font-size: 20px; color: var(--on-surface); margin-right: 20px; }

#drillDownCard > div:last-child {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    padding: 20px 10px;
}
#drillDownCard canvas {
    position: absolute !important;
    top: 20px !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 20px !important;
    width: calc(100% - 20px) !important;
    height: calc(100% - 40px) !important;
}

#drillPagination { display: none; gap: 10px; align-items: center; }

/* ────────────────────────────────────────────────────────────
   Download buttons (export PNG/PDF/CSV)
   ──────────────────────────────────────────────────────────── */

.btn-download {
    background: var(--success);
    color: var(--on-primary);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn-download:hover {
    background: var(--success-dim);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}
.btn-download:active { transform: translateY(0); }

/* ────────────────────────────────────────────────────────────
   OU breadcrumb + dashboard table (MIS)
   ──────────────────────────────────────────────────────────── */

.breadcrumb {
    font-size: 14px;
    color: var(--on-surface-variant);
    font-weight: 500;
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 5px;
}
.crumb {
    cursor: pointer;
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}
.crumb:hover { color: var(--primary-dim); text-decoration: underline; }
.crumb-sep { color: var(--outline); }
.current-crumb { color: var(--on-surface); font-weight: 700; cursor: default; }

.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--on-primary);
    display: inline-block;
    width: 90px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mis-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.mis-table th {
    background: var(--surface-container-low);
    padding: 12px 15px;
    text-align: left;
    border-bottom: 2px solid var(--outline-variant);
    position: sticky;
    top: 0;
    z-index: 10;
    color: var(--on-surface);
    font-weight: 600;
}
.mis-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--outline-variant);
    color: var(--on-surface-variant);
}
.mis-table tr:hover td { background: var(--surface-container-low); }
.mis-table thead th {
    position: sticky !important;
    top: 0;
    background-color: var(--surface-container-low) !important;
    z-index: 100;
}

/* ────────────────────────────────────────────────────────────
   MIS — column customizer modal
   ──────────────────────────────────────────────────────────── */

.col-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.col-modal-content {
    background: var(--surface-container-lowest);
    padding: 25px;
    border-radius: 12px;
    width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}
.col-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--outline-variant);
    border-radius: 8px;
    padding: 5px;
}
.col-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: var(--surface-container-lowest);
    border-bottom: 1px solid var(--surface-container-high);
    gap: 12px;
}
.col-item:last-child { border-bottom: none; }
.col-item:hover { background: var(--surface-container-low); }
.col-handle { cursor: grab; color: var(--outline); font-size: 18px; user-select: none; }
.col-item label { flex-grow: 1; cursor: pointer; font-size: 14px; font-weight: 500; }

/* ────────────────────────────────────────────────────────────
   MIS — filter dropdowns
   ──────────────────────────────────────────────────────────── */

.mis-filter {
    padding: 6px 10px;
    border: 1px solid var(--outline-variant);
    border-radius: 6px;
    font-size: 13px;
    color: var(--on-surface);
    background-color: var(--surface-container-lowest);
    outline: none;
    cursor: pointer;
    min-width: 120px;
}
.mis-filter:hover { border-color: var(--outline); }
.mis-filter:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 96, 173, 0.15);
}

#reportsView {
    padding: 20px;
    background-color: var(--surface-container-low);
    color: var(--on-surface-variant);
    font-size: 16px;
}

#ouTableContainer { animation: fadeIn 0.3s ease-in-out; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1200px) {
    .graph-selection-container { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .graph-selection-container { grid-template-columns: 1fr; gap: 20px; padding: 20px; }
}

/* ────────────────────────────────────────────────────────────
   Reports Center — sidebar + accordion + main
   ──────────────────────────────────────────────────────────── */

.report-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
}

.report-sidebar {
    width: 320px;
    background: var(--surface-container-lowest);
    border-right: 1px solid var(--outline-variant);
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}
.report-sidebar.closed { transform: translateX(-100%); width: 0; padding: 0; border: 0; }

.report-main {
    flex-grow: 1;
    padding: 20px 30px;
    overflow-y: auto;
    background: var(--surface);
    display: flex;
    flex-direction: column;
}

.accordion-item { border-bottom: 1px solid var(--surface-container-high); }
.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    cursor: pointer;
    color: var(--on-surface-variant);
    font-size: 13px;
    font-weight: 700;
    transition: color 0.2s;
}
.accordion-header:hover,
.accordion-header.active { color: var(--primary); }
.accordion-header i { transition: transform 0.3s; font-size: 11px; color: var(--outline); }
.accordion-header.active i { transform: rotate(180deg); }
.accordion-body { display: none; padding-bottom: 15px; }
.accordion-body.active { display: block; }

.tree-container {
    border: 1px solid var(--outline-variant);
    border-radius: 6px;
    height: 350px;
    overflow-y: auto;
    padding: 10px;
    background: var(--surface-container-low);
}
.node {
    font-size: 13px;
    padding: 4px 0;
    cursor: pointer;
    color: var(--on-surface);
    display: flex;
    align-items: center;
    gap: 5px;
}
.node:hover { color: var(--primary); }
.node.active {
    font-weight: 700;
    color: var(--primary);
    background: var(--surface-container);
    padding-left: 5px;
    border-radius: 4px;
}

.control-group { margin-bottom: 15px; }
.report-sidebar select,
.report-sidebar input[type="date"] {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--outline-variant);
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
    background: var(--surface-container-lowest);
    color: var(--on-surface);
}
.checkbox-group { display: flex; flex-direction: column; gap: 8px; margin-top: 5px; }
.check-item { font-size: 13px; display: flex; align-items: center; gap: 8px; color: var(--on-surface); }
.btn-apply {
    background: var(--primary);
    color: var(--on-primary);
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
}

.report-card {
    background: var(--surface-container-lowest);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    margin-bottom: 20px;
}
.report-toolbar {
    padding: 20px;
    border-bottom: 1px solid var(--outline-variant);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.report-title { font-size: 18px; font-weight: 700; color: var(--on-surface); }
.report-meta { font-size: 13px; color: var(--on-surface-variant); }
.action-btns button {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--outline-variant);
    background: var(--surface-container-lowest);
    border-radius: 6px;
    cursor: pointer;
    margin-left: 8px;
    color: var(--on-surface);
}
.table-container { flex-grow: 1; overflow-y: auto; }
.report-card table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.report-card th {
    text-align: left;
    padding: 12px 20px;
    background: var(--surface-container-low);
    border-bottom: 1px solid var(--outline-variant);
    color: var(--on-surface-variant);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 5;
}
.report-card td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--surface-container-high);
    color: var(--on-surface);
    word-wrap: break-word;
}
.report-card tr:hover { background: var(--surface-container-low); }

.val-safe { color: var(--success); font-weight: 600; }
.val-breach { color: var(--error); font-weight: 700; }

.global-tooltip {
    display: none;
    position: fixed;
    z-index: 99999;
    width: 260px;
    background-color: var(--inverse-surface);
    color: var(--on-primary);
    border-radius: 12px;
    padding: 16px;
    font-size: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 12px 24px -10px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.tooltip-trigger { cursor: help; text-decoration: underline dotted var(--outline-variant); }
.tooltip-trigger:hover { background: var(--surface-container-low); }
.breakdown-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--outline);
    padding-bottom: 4px;
}
.breakdown-row:last-child { border-bottom: none; margin-bottom: 0; }

/* ── Phase 1.5 — Submit preflight modal: callout component ──
   Used inside the preflight modal to surface attachment status
   and other pre-submit context (success / warning / info). */
.wf-callout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-left: 3px solid var(--outline);
  border-radius: var(--radius-md);
}
.wf-callout--success {
  border-left-color: var(--success);
  background: var(--success-bg);
}
.wf-callout--warning {
  border-left-color: var(--warning);
  background: var(--warning-bg);
}
.wf-callout--info {
  border-left-color: var(--info, var(--primary));
  background: var(--primary-container);
}
.wf-callout > .material-symbols-outlined {
  flex-shrink: 0;
  font-size: 22px;
  color: inherit;
  margin-top: 1px;
}
.wf-callout--success > .material-symbols-outlined { color: var(--success); }
.wf-callout--warning > .material-symbols-outlined { color: var(--warning); }
.wf-callout--info    > .material-symbols-outlined { color: var(--primary); }
.wf-callout__main {
  flex-grow: 1;
  min-width: 0;
}
.wf-callout__title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--on-surface);
  margin-bottom: 2px;
}
.wf-callout__body {
  font-size: 0.8125rem;
  color: var(--on-surface-variant);
  line-height: 1.5;
}
.wf-callout__action {
  flex-shrink: 0;
  margin-left: var(--space-2);
}