/* Smith Fresh & Clean - Estimate Builder
   Mobile-first stylesheet. No external dependencies. */

:root {
    --brand: #1c7c54;
    --brand-dark: #145c3f;
    --brand-light: #e8f5ee;
    --ink: #1f2933;
    --muted: #6b7280;
    --border: #dfe3e8;
    --danger: #c0392b;
    --warn: #b9770e;
    --bg: #f5f7f6;
    --card: #ffffff;
    --radius: 10px;
}

* { box-sizing: border-box; }

img { max-width: 100%; height: auto; }

input[type=checkbox], input[type=radio] {
    width: 18px;
    height: 18px;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

a { color: var(--brand-dark); }

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

/* ---- Top nav ---- */
header.topbar {
    background: var(--brand);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
}

.brand img { height: 32px; width: auto; display: block; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

nav.mainnav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

nav.mainnav > a {
    color: #fff;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.92rem;
    opacity: 0.92;
}

nav.mainnav > a.active,
nav.mainnav > a:hover {
    background: rgba(255,255,255,0.18);
    opacity: 1;
}

.navtoggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ---- Nav dropdowns (Admin menu, user menu) ---- */
.navdrop, .navuser {
    position: relative;
}

.navdrop-toggle, .navuser-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #fff;
    font: inherit;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.92rem;
    opacity: 0.92;
    cursor: pointer;
}

.navdrop.active .navdrop-toggle,
.navdrop-toggle:hover,
.navuser-toggle:hover {
    background: rgba(255,255,255,0.18);
    opacity: 1;
}

.caret { font-size: 0.65em; }

.navdrop-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    min-width: 180px;
    padding: 6px;
    z-index: 60;
}

.navuser .navdrop-menu { left: auto; right: 0; min-width: 140px; }

.navdrop.open .navdrop-menu,
.navuser.open .navdrop-menu {
    display: block;
}

.navdrop-menu a {
    display: block;
    color: var(--ink);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
}

.navdrop-menu a.active,
.navdrop-menu a:hover {
    background: var(--brand-light);
    color: var(--brand-dark);
}

@media (max-width: 720px) {
    .nav-right {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        padding-top: 8px;
    }
    .nav-right.open { display: flex; }
    .topbar-inner { flex-wrap: wrap; }
    .navtoggle { display: block; }

    nav.mainnav { flex-direction: column; }
    .navdrop, .navuser { width: 100%; }
    .navdrop-toggle, .navuser-toggle { width: 100%; justify-content: space-between; }
    .navdrop-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: transparent;
        margin-top: 0;
        padding-left: 14px;
    }
    .navuser .navdrop-menu { right: auto; }
}

/* On narrow phones, let fixed-px form fields (payment/pay-rate inputs that
   set an inline width for desktop table/row alignment) grow to fill the
   available width instead of staying pinned to a cramped fixed size. */
@media (max-width: 480px) {
    .btn-row { align-items: stretch; }
    .btn-row > div { flex: 1 1 140px; }
    .btn-row input[style*="width"],
    .btn-row select[style*="width"] {
        width: 100% !important;
        min-width: 0;
    }
}

/* ---- Cards / layout ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 16px;
}

.page-title h1 { margin: 0; font-size: 1.4rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    line-height: 1.2;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #fff; color: var(--brand-dark); border-color: var(--brand); }
.btn.secondary:hover { background: var(--brand-light); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Forms ---- */
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 0.9rem; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }

input[type=text], input[type=number], input[type=email], input[type=tel],
input[type=password], input[type=search], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
    color: var(--ink);
    font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0 16px;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    background: #fff;
}
.checkbox-row input { width: 18px; height: 18px; margin-top: 2px; }
.checkbox-row .meta { flex: 1; }
.checkbox-row .name { font-weight: 600; }
.checkbox-row .desc { color: var(--muted); font-size: 0.85rem; }
.checkbox-row .price { font-weight: 700; color: var(--brand-dark); white-space: nowrap; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 16px; padding: 12px; }
legend { font-weight: 700; padding: 0 6px; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
.table-wrap { overflow-x: auto; }

.price-matrix td, .price-matrix th { text-align: center; }
.price-matrix td:first-child, .price-matrix th:first-child { text-align: left; }
.price-matrix .highlight { background: var(--brand-light); font-weight: 700; }

/* ---- Status badges ---- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge.pending { background: #fdecea; color: var(--danger); }
.badge.on_site { background: #fdf2e3; color: var(--warn); }
.badge.estimated, .badge.finalized { background: var(--brand-light); color: var(--brand-dark); }
.badge.draft { background: #eef1f4; color: var(--muted); }
.badge.scheduled { background: #eef4fb; color: #1c4e80; }
.badge.completed { background: var(--brand-light); color: var(--brand-dark); }
.badge.canceled { background: #eef1f4; color: var(--muted); }

/* ---- Alerts ---- */
.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.92rem; }
.alert.error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }
.alert.success { background: var(--brand-light); color: var(--brand-dark); border: 1px solid #b9e3cb; }
.alert.info { background: #eef4fb; color: #1c4e80; border: 1px solid #c7defa; }

/* ---- Login page ---- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card .logo { text-align: center; margin-bottom: 12px; }
.login-card .logo img { max-height: 60px; }

/* ---- Dashboard list ---- */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--brand-light); }
.list-item .title { font-weight: 700; }
.list-item .subtitle { color: var(--muted); font-size: 0.85rem; }

/* ---- SOS nav link / admin badges ---- */
.nav-sos { background: var(--danger) !important; opacity: 1 !important; }
.nav-sos:hover { background: #a5281b !important; }
.nav-badge {
    display: inline-block;
    background: #fff;
    color: var(--danger);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 1px 6px;
    margin-left: 4px;
}
.badge.triggered { background: #fdecea; color: var(--danger); }
.badge.acknowledged { background: #fdf2e3; color: var(--warn); }
.badge.resolved { background: var(--brand-light); color: var(--brand-dark); }
.badge.cancelled { background: #eef1f4; color: var(--muted); }

/* ---- SOS button page ---- */
.sos-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 24px 16px;
    max-width: 420px;
    margin: 0 auto;
}
.sos-title { margin: 0; text-align: center; }
.sos-button {
    position: relative;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: #fff;
    font-size: 1.3rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    box-shadow: 0 6px 18px rgba(192,57,43,0.4);
}
.sos-button-fill {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0%;
    height: 100%;
    background: rgba(255,255,255,0.28);
    pointer-events: none;
}
.sos-button span:not(.sos-button-fill) { position: relative; z-index: 2; }
.sos-button.holding { background: #a5281b; }
.sos-button.sent { background: var(--muted); box-shadow: none; }
.sos-button:disabled { cursor: not-allowed; }

/* ---- Utility ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ---- Job check-in page (checkin.php) ---- */
.checkin-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 16px 32px;
    max-width: 480px;
    margin: 0 auto;
}
.checkin-wrap .card { margin-bottom: 0; }
.checkin-job .title { font-weight: 700; font-size: 1.05rem; }
.checkin-job .subtitle { color: var(--muted); font-size: 0.9rem; }
.checkin-job-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 4px; }
.checkin-time { white-space: nowrap; font-weight: 700; color: var(--brand-dark); font-size: 0.9rem; }
.checkin-status { margin-top: 10px; padding: 8px 10px; border-radius: 8px; font-size: 0.92rem; }
.checkin-status.in { background: #eef4fb; color: #1c4e80; }
.checkin-status.done { background: var(--brand-light); color: var(--brand-dark); }
.checkin-action { margin-top: 12px; }
.checkin-btn {
    width: 100%;
    min-height: 64px;
    border: none;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}
.checkin-btn:active { background: var(--brand-dark); }
.checkin-btn.done { background: #1c4e80; }
.checkin-btn.done.confirming { background: var(--warn); }
.checkin-btn:disabled { opacity: 0.6; cursor: wait; }
.badge.flag { background: #fdecea; color: var(--danger); }
