/* ============================================================
   POLISH.CSS — Readability overlay for the Sierra theme.
   Purely additive: no layout changes, no functional changes.
   Loaded AFTER sierra-theme.css so these rules win on ties.
   ============================================================ */

/* ---------- Typography ---------- */
html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { line-height: 1.55; letter-spacing: 0.005em; color: #1a1a1a; }
h1, h2, h3, h4, h5, h6 { letter-spacing: -0.01em; color: #0f1117; line-height: 1.25; }
p, li, dd, label, input, select, textarea, button, td, th { line-height: 1.55; }
small, .text-muted, .muted { color: #4b5563 !important; }

/* Tighter tracking on dense labels, bolder emphasis on stats */
.stat-value, .kpi-value, .metric-value { letter-spacing: -0.015em; font-weight: 700; }

/* ---------- Focus states (accessibility) ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Forms: breathe & be legible ---------- */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
    padding: 9px 12px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    background: #ffffff !important;
    color: #111827 !important;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover:not([disabled]),
select:hover:not([disabled]),
textarea:hover:not([disabled]) { border-color: #9ca3af !important; }
input:focus,
select:focus,
textarea:focus {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
    outline: none !important;
}
input[disabled], select[disabled], textarea[disabled] {
    background: #f3f4f6 !important;
    color: #6b7280 !important;
    cursor: not-allowed;
}
label { font-weight: 600; color: #374151; margin-bottom: 6px; display: inline-block; }
::placeholder { color: #9ca3af !important; opacity: 1; }

/* ---------- Buttons: taller touch targets, clearer hierarchy ---------- */
button, .btn {
    min-height: 36px;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: transform 0.05s ease, box-shadow 0.15s ease, background 0.15s ease;
}
button:not([disabled]):hover, .btn:not([disabled]):hover { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
button:not([disabled]):active, .btn:not([disabled]):active { transform: translateY(1px); box-shadow: none; }
.btn-primary, button[type="submit"]:not(.btn-secondary):not(.btn-ghost) {
    background: #111827;
    color: #ffffff;
    border: 1px solid #111827;
}
.btn-primary:hover, button[type="submit"]:not(.btn-secondary):not(.btn-ghost):hover {
    background: #1f2937;
    border-color: #1f2937;
}
.btn-danger { background: #dc2626; color: #fff; border: 1px solid #dc2626; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-success { background: #16a34a; color: #fff; border: 1px solid #16a34a; }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-secondary, .btn-ghost { background: #ffffff; color: #111827; border: 1px solid #d1d5db; }
.btn-secondary:hover, .btn-ghost:hover { background: #f3f4f6; }
button[disabled], .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- Cards: softer, more readable ---------- */
.card, .panel, .widget, .kpi-card, .stat-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.03);
}
.card-header, .panel-header, .widget-header {
    padding: 14px 18px;
    border-bottom: 1px solid #eef0f3;
    font-weight: 600;
    color: #111827;
    letter-spacing: -0.005em;
}
.card-body, .panel-body, .widget-body { padding: 18px; }

/* ---------- Tables: zebra + comfortable rows ---------- */
table { border-collapse: collapse; width: 100%; }
table th {
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #374151;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 14px;
    text-align: left;
}
table td {
    padding: 12px 14px;
    border-bottom: 1px solid #eef0f3;
    color: #1f2937;
    vertical-align: middle;
}
table tbody tr:hover td { background: #f9fafb; }
table tbody tr:nth-child(even) td { background: #fcfcfd; }
table tbody tr:nth-child(even):hover td { background: #f4f6f8; }

/* ---------- Badges / tags ---------- */
.badge, .tag, .chip, .status-badge, .pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 999px;
    line-height: 1.4;
    letter-spacing: 0.02em;
}

/* ---------- Links ---------- */
a { text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

/* ---------- Modals: keep focus, readable body ---------- */
.modal, .modal-content, .modal-dialog {
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(16, 24, 40, 0.18), 0 4px 12px rgba(16, 24, 40, 0.08);
}
.modal-header { padding: 16px 20px; border-bottom: 1px solid #eef0f3; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid #eef0f3; display: flex; gap: 10px; justify-content: flex-end; }
.modal-overlay, .modal-backdrop { background: rgba(15, 17, 23, 0.55); backdrop-filter: blur(2px); }

/* ---------- Nav refinement (keep Sierra look, more readable) ---------- */
.sierra-topnav { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.sierra-topnav a,
.sierra-topnav .nav-link,
.sierra-topnav .nav-item { letter-spacing: 0.015em; }
.sierra-topnav .nav-item.active,
.sierra-topnav .nav-link.active { font-weight: 600; }

/* ---------- Page titles ---------- */
.page-title, h1.page-title { font-size: 22px; font-weight: 700; color: #0f1117; }
.page-subtitle { color: #6b7280; font-size: 14px; }

/* ---------- Empty states & loading ---------- */
.empty-state, .no-data {
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}
.loading, .spinner {
    color: #6b7280;
    letter-spacing: 0.02em;
}

/* ---------- Toast / flash messages ---------- */
.toast, .flash, .alert {
    border-radius: 8px;
    padding: 12px 16px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.10);
}
.toast-success, .alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.toast-error, .alert-error, .alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast-warning, .alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.toast-info, .alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---------- Kanban / pipeline readability ---------- */
.pipeline-column, .kanban-column { background: #f4f5f7; border-radius: 10px; padding: 12px; }
.pipeline-card, .kanban-card, .deal-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    margin-bottom: 10px;
    transition: box-shadow 0.15s, transform 0.05s;
}
.pipeline-card:hover, .kanban-card:hover, .deal-card:hover {
    box-shadow: 0 4px 12px rgba(16, 24, 40, 0.10);
}

/* ---------- Lead / list rows ---------- */
.list-item, .lead-row, .item-row {
    padding: 12px 14px;
    border-bottom: 1px solid #eef0f3;
    transition: background 0.1s;
}
.list-item:hover, .lead-row:hover, .item-row:hover { background: #f9fafb; }

/* ---------- Sidebar menu (subcontractor portal etc) ---------- */
.menu-item, .side-menu a {
    padding: 10px 14px;
    border-radius: 6px;
    color: #e5e7eb;
    letter-spacing: 0.01em;
}
.menu-item:hover, .side-menu a:hover { background: rgba(255,255,255,0.06); }
.menu-item.active, .side-menu a.active { background: rgba(255,255,255,0.10); color: #fff; font-weight: 600; }

/* ---------- Dashboard stat tiles ---------- */
.stat-card, .kpi-card, .metric-card {
    padding: 18px 20px;
    border-radius: 10px;
}
.stat-label, .kpi-label, .metric-label {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: #6b7280;
}
.stat-value, .kpi-value, .metric-value {
    font-size: 28px;
    line-height: 1.1;
    margin-top: 6px;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd1d8; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #9aa3ad; background-clip: padding-box; border: 2px solid transparent; }

/* ---------- Forms: helper / error text ---------- */
.form-hint, .help-text { color: #6b7280; font-size: 12.5px; margin-top: 4px; }
.form-error, .error-text { color: #b91c1c; font-size: 12.5px; margin-top: 4px; font-weight: 500; }
input.is-invalid, select.is-invalid, textarea.is-invalid, .invalid { border-color: #dc2626 !important; }
input.is-invalid:focus, select.is-invalid:focus, textarea.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18) !important;
}

/* ---------- Misc readability ---------- */
hr { border: none; border-top: 1px solid #e5e7eb; margin: 20px 0; }
code, pre, kbd, samp {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
    font-size: 0.92em;
}
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; }

/* ---------- Login page polish (centered card look) ---------- */
body.login-page, body.login {
    background: linear-gradient(180deg, #0f1117 0%, #1a1a1a 100%);
}
.login-card, .login-box, .login-container > .card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
    padding: 32px;
}

/* ---------- Reduce motion honoured ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
    }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .sierra-topnav, .topbar, .btn, button, .no-print { display: none !important; }
    .card, .panel { box-shadow: none !important; border: 1px solid #ccc !important; }
    body { background: #fff !important; color: #000 !important; }
}

/* ============================================================
   NAV DROPDOWN GROUPS (categorized top-nav)
   ============================================================ */
.sierra-topnav .nav-group {
    position: relative;
    height: 100%;
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
}
.sierra-topnav .nav-grp-btn {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.85);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    padding: 0 9px;
    height: 100%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-bottom: 3px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
}
.sierra-topnav .nav-grp-btn i.fa-caret-down {
    font-size: 10px;
    margin-left: 2px;
    opacity: 0.7;
    transition: transform 0.15s ease;
}
.sierra-topnav .nav-grp-btn:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}
.sierra-topnav .nav-group.active > .nav-grp-btn {
    color: #ffffff;
    border-bottom-color: var(--sierra-orange, #f97316);
    background: rgba(255,255,255,0.05);
}
.sierra-topnav .nav-group.open > .nav-grp-btn i.fa-caret-down {
    transform: rotate(180deg);
}

.sierra-topnav .nav-grp-menu,
body > .nav-grp-menu {
    position: fixed;
    top: 52px;
    left: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    padding: 6px;
    display: none;
    flex-direction: column;
    z-index: 99999;
    margin-top: 2px;
    animation: ngmFade 120ms ease-out;
}
.sierra-topnav .nav-group.open > .nav-grp-menu,
body > .nav-grp-menu.open { display: flex; }

@keyframes ngmFade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.sierra-topnav .nav-grp-menu a,
body > .nav-grp-menu a {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 9px 12px !important;
    color: #1f2937 !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    border-bottom: none !important;
    border-radius: 5px;
    height: auto !important;
    text-decoration: none;
    transition: background 0.1s ease;
    white-space: nowrap;
}
.sierra-topnav .nav-grp-menu a i,
body > .nav-grp-menu a i {
    color: var(--sierra-orange, #f97316);
    width: 16px;
    text-align: center;
    font-size: 13px;
}
.sierra-topnav .nav-grp-menu a:hover,
body > .nav-grp-menu a:hover {
    background: #f3f4f6 !important;
    color: #0f172a !important;
}
.sierra-topnav .nav-grp-menu a.active,
body > .nav-grp-menu a.active {
    background: #fff7ed !important;
    color: #9a3412 !important;
    font-weight: 600 !important;
}

/* Right-side admin group: open the menu to the LEFT so it doesn't clip */
.sierra-topnav .nav-right .nav-group .nav-grp-menu {
    left: auto;
    right: 0;
}

/* ============================================================
   PAGE TRANSITIONS — fast cross-fade between pages
   Eliminates the harsh "white flash" between navigations.
   Uses View Transitions API where supported (Chrome/Edge/Safari);
   falls back to a tiny CSS fade-in everywhere else.
   ============================================================ */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 140ms;
    animation-timing-function: ease-out;
}

/* Fallback fade-in (also runs in browsers that DO support view-transitions
   — harmless because View Transitions overrides during the transition). */
body {
    animation: pageFadeIn 140ms ease-out;
}
@keyframes pageFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* While the auth-guard is verifying, hide the page entirely (no flash) */
html.auth-cloak,
html.auth-cloak body { visibility: hidden !important; }
html.auth-cloak body { animation: none !important; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    body { animation: none !important; }
    .sierra-topnav .nav-grp-menu { animation: none !important; }
}

