/**
 * BuildPro — Global Cohesion & Readability Layer
 *
 * Field report: "The whole platform is confusing and not cohesive, doesn't
 * flow well, is clunky, the areas and lines are hard to read — doesn't feel
 * like an enterprise-level product."
 *
 * One stylesheet, loaded last, that normalizes EVERY page to a single
 * enterprise design language:
 *   - bigger, calmer type scale (no more 10-11px squint text)
 *   - consistent buttons, tables, cards, pills, inputs
 *   - real row spacing + zebra tables so lines are readable
 *   - one accent color story, consistent section headers
 *   - larger touch targets on iPad/iPhone
 */

/* ── Type scale: readable by default ─────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }
body { font-size: 15px; line-height: 1.5; letter-spacing: 0.005em; }

/* Kill the micro-text plague: anything styled 10-12px gets lifted */
.card, .page, .modal, [id$="-container"] { font-size: 14.5px; }
.dash-list-sub, .cat-row-sub, .po-meta, small { font-size: 13px !important; line-height: 1.45; }
.dash-list-title, .cat-row-title { font-size: 15px !important; }

/* Section headers: one consistent style everywhere */
.card-title, .cat-section-title, h3.card-title {
    font-size: 16px; font-weight: 700; color: #111827;
    letter-spacing: -0.01em;
}
.card-title i { color: #2563eb; margin-right: 8px; }

/* ── Cards: consistent surfaces, breathing room ──────────────────── */
.card {
    border-radius: 14px;
    border: 1px solid #e8eaee;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
    padding: 20px 22px;
}
.card + .card { margin-top: 16px; }

/* ── Tables: readable lines (the "hard to read" complaint) ───────── */
table { font-size: 14px !important; }
th {
    font-size: 12px !important; font-weight: 700 !important;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: #6b7280 !important; padding: 10px 8px !important;
}
td { padding: 12px 8px !important; line-height: 1.45; }
tbody tr { border-bottom: 1px solid #f1f3f6; }
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #f3f6fb; }

/* ── Buttons: one system, real touch targets ─────────────────────── */
.btn {
    border-radius: 10px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    min-height: 40px;
    padding: 9px 16px;
    transition: transform .06s ease, box-shadow .12s ease, background .12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-sm { min-height: 34px; font-size: 13px !important; padding: 6px 12px; }
.btn-primary { box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25); }
.btn i { margin-right: 6px; }
.btn-sm i { margin-right: 4px; }

/* ── Inputs: consistent, comfortable ─────────────────────────────── */
input[type="text"], input[type="search"], input[type="number"],
input[type="email"], input[type="date"], select, textarea {
    font-size: 14px !important;
    border-radius: 10px !important;
    min-height: 40px;
    border: 1px solid #d7dbe2 !important;
    background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none !important;
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
}

/* ── Status pills: one consistent shape everywhere ───────────────── */
[class*="status"], .pill, .badge {
    border-radius: 999px;
}

/* ── Nav: clearer active state, larger targets ───────────────────── */
.topnav-item {
    font-size: 14px !important;
    font-weight: 600 !important;
    padding: 14px 14px !important;
}
.nav-item { min-height: 42px; font-size: 14px !important; }

/* ── Overlays/modals: consistent frame ───────────────────────────── */
[id$="-overlay"] > div { border-radius: 16px !important; }

/* ── Touch targets on tablet/phone ───────────────────────────────── */
@media (max-width: 1024px) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 38px; }
    td { padding: 13px 8px !important; }
    body { font-size: 16px; }
}

/* ══════════════════════════════════════════════════════════════════
   ENTERPRISE SMOOTHNESS LAYER — "not QuickBooks smooth" fix
   Page transitions, press feedback, skeletons, motion discipline.
   All GPU-friendly (opacity/transform only), honors reduced-motion.
   ══════════════════════════════════════════════════════════════════ */

/* Page switches: content eases in instead of snapping */
.page.active { animation: pageIn .22s ease-out; }
@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* Cards + list rows: gentle hover lift on pointer devices */
@media (hover: hover) {
    .card { transition: box-shadow .18s ease, transform .18s ease; }
    .dash-list-item, .cat-row, .qrw { transition: background .12s ease; }
    .dash-list-item:hover, .cat-row:hover { background: #f6f8fc; }
}

/* Everything tappable gives press feedback (iPad "did it register?" fix) */
button:not(:disabled):active,
.nav-item:active, .topnav-item:active,
[onclick]:not(input):not(select):active {
    transform: scale(0.98);
    transition: transform .05s ease;
}
button, [onclick] { -webkit-tap-highlight-color: rgba(37, 99, 235, 0.08); }

/* Modals/overlays: fade + settle instead of popping into existence */
[id$="-overlay"] { animation: overlayIn .16s ease-out; }
[id$="-overlay"] > div { animation: sheetIn .2s cubic-bezier(.2,.9,.3,1.1); }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetIn {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

/* Loading skeleton: any element with .skeleton shimmers consistently */
.skeleton {
    background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 50%, #eef1f5 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s infinite linear;
    border-radius: 8px; color: transparent !important;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Toasts slide up softly */
.toast, [class*="toast"] { animation: toastIn .22s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Smooth scrolling + momentum on touch */
html { scroll-behavior: smooth; }
.page, [id$="-container"] { -webkit-overflow-scrolling: touch; }

/* Focus ring: visible for keyboards, calm for touch */
:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; border-radius: 6px; }

/* Respect users who turn motion off */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ── Turn-flow shared components (used by js/turn-flow.js) ───────── */
.tf-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
    z-index: 9998; display: flex; align-items: center; justify-content: center;
    padding: 14px;
}
.tf-sheet {
    background: #fff; border-radius: 16px; max-width: 640px; width: 100%;
    max-height: 92vh; max-height: 92dvh; overflow: auto; position: relative;
    -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding: 22px 24px;
}
.tf-close {
    position: absolute; top: 12px; right: 12px; z-index: 2;
    padding: 4px 0 !important; min-height: 40px !important;
    width: 40px; font-size: 20px !important; line-height: 1;
    border-radius: 50% !important;
}
/* leave room for the floating close button so it never covers the title */
.tf-sheet #turnflow-body { padding-right: 40px; }

.tf-stepper { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: 6px 0 14px; }
.tf-step { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 72px; position: relative; cursor: pointer; border: none; background: transparent; padding: 0; }
.tf-step-dot {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; color: #fff; background: #d1d5db;
    transition: box-shadow .15s ease;
}
.tf-step.done .tf-step-dot { background: #16a34a; }
.tf-step.current .tf-step-dot { background: #2563eb; box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.18); }
.tf-step-label { font-size: 12px; font-weight: 600; color: #9ca3af; margin-top: 7px; text-align: center; line-height: 1.25; }
.tf-step.done .tf-step-label { color: #16a34a; }
.tf-step.current .tf-step-label { color: #2563eb; font-weight: 800; }
.tf-connector { flex: 0 0 18px; height: 3px; background: #e5e7eb; margin-top: 16px; border-radius: 2px; }
.tf-connector.done { background: #16a34a; }

.tf-action-card {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 14px;
    padding: 22px; text-align: center; margin-top: 6px;
}
.tf-action-card h4 { margin: 0 0 6px; font-size: 17px; color: #111827; }
.tf-action-card p { margin: 0 0 16px; font-size: 14px; color: #6b7280; }
.tf-done-line { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 8px 0; color: #374151; }
.tf-done-line i { color: #16a34a; }

/* Phones: full-width bottom sheet — easier to reach, nothing clipped.
   MUST stay after the base tf-* rules (cascade), and the radius needs
   !important to beat the generic [id$="-overlay"] > div frame rule. */
@media (max-width: 640px) {
    .tf-overlay { padding: 0; align-items: flex-end; }
    /* .tf-overlay > .tf-sheet outranks the generic [id$="-overlay"] > div
       16px-radius frame rule (0,2,0 vs 0,1,1) */
    .tf-overlay > .tf-sheet {
        max-width: none;
        border-radius: 18px 18px 0 0 !important;
        max-height: 94vh; max-height: 94dvh;
        padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
    }
    .tf-sheet #turnflow-body { padding-right: 34px; }
    .tf-step { min-width: 58px; }
    .tf-connector { flex: 0 0 8px; }
    .tf-action-card { padding: 18px 14px; }
    .tf-action-card .btn { width: 100%; }
    .tf-done-line { align-items: flex-start; }
    .tf-done-line strong { min-width: 74px !important; }
}
