/* ============================================================
   ATB Build Hub — App Styles
   ============================================================ */
:root {
    --navy-deepest: #0a0e17;
    --navy-deep: #0d1321;
    --navy-medium: #141b2d;
    --navy-light: #1c2438;
    --gold: #c9a227;
    --gold-light: #e3c558;
    --white: #f5f6f8;
    --text: #cbd3e0;
    --text-muted: #7c8699;
    --border: rgba(201,162,39,0.15);
    --border-soft: rgba(255,255,255,0.06);
    --green: #22c55e;
    --blue: #3b82f6;
    --amber: #f59e0b;
    --red: #ef4444;
    --radius: 10px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--navy-deepest);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--gold-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--navy-deep);
    border-right: 1px solid var(--border-soft);
    padding: 1.5rem 1rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0 0.5rem 1.5rem;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 1rem;
}
.sidebar-brand-logo {
    width: 38px; height: 38px; border-radius: 8px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: var(--navy-deepest); font-size: 0.95rem;
}
.sidebar-brand-text { font-weight: 700; color: var(--white); font-size: 0.95rem; line-height: 1.2; }
.sidebar-brand-text small { display: block; font-weight: 400; color: var(--text-muted); font-size: 0.7rem; }

.nav-section { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin: 1rem 0.5rem 0.4rem; }
.nav-link {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.6rem 0.75rem; border-radius: 8px;
    color: var(--text); font-size: 0.88rem; font-weight: 500;
    text-decoration: none; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--navy-light); text-decoration: none; }
.nav-link.active { background: rgba(201,162,39,0.12); color: var(--gold-light); }
.nav-link .ico { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 0.68rem; padding: 1px 7px; border-radius: 10px; }

.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border-soft); }

.main {
    flex: 1; margin-left: 250px;
    padding: 1.75rem 2.25rem;
    max-width: 1400px;
}

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; }
.topbar h1 { color: var(--white); font-size: 1.55rem; font-weight: 700; }
.topbar .sub { color: var(--text-muted); font-size: 0.9rem; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 1.1rem; border-radius: 8px; border: none;
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: filter .15s, background .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: var(--navy-deepest); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--navy-light); color: var(--text); border: 1px solid var(--border-soft); }
.btn-ghost:hover { background: var(--navy-medium); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; }

/* ---------- Cards ---------- */
.card { background: var(--navy-deep); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 1.4rem; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ---------- Stat cards ---------- */
.stat { background: var(--navy-deep); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 1.2rem 1.3rem; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--white); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-accent { background: linear-gradient(135deg, var(--gold), var(--gold-light)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ---------- Project card ---------- */
.project-card {
    background: var(--navy-deep); border: 1px solid var(--border-soft);
    border-radius: var(--radius); overflow: hidden; cursor: pointer;
    transition: transform .15s, border-color .15s;
}
.project-card:hover { transform: translateY(-3px); border-color: var(--border); }
.project-card-img { height: 150px; background: var(--navy-light) center/cover; position: relative; }
.project-card-phase {
    position: absolute; top: 0.7rem; right: 0.7rem;
    background: rgba(10,14,23,0.85); backdrop-filter: blur(6px);
    color: var(--gold-light); font-size: 0.7rem; font-weight: 600;
    padding: 0.2rem 0.65rem; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.05em;
}
.project-card-body { padding: 1rem 1.15rem 1.2rem; }
.project-card-name { color: var(--white); font-weight: 700; font-size: 1.05rem; }
.project-card-addr { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.15rem; }
.progress-bar { height: 6px; background: var(--navy-light); border-radius: 3px; margin-top: 0.9rem; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-light)); border-radius: 3px; transition: width .4s; }
.progress-text { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.4rem; }

/* ---------- Trade / phase rows ---------- */
.trade-row {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.85rem 1rem; border-bottom: 1px solid var(--border-soft);
}
.trade-row:last-child { border-bottom: none; }
.trade-name { font-weight: 600; color: var(--white); font-size: 0.9rem; }
.trade-cat { font-size: 0.72rem; color: var(--text-muted); }
.status-pill { font-size: 0.72rem; font-weight: 600; padding: 0.25rem 0.7rem; border-radius: 20px; white-space: nowrap; }
.status-select { background: var(--navy-light); color: var(--text); border: 1px solid var(--border-soft); border-radius: 6px; padding: 0.35rem 0.5rem; font-size: 0.8rem; font-family: inherit; cursor: pointer; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.data th { text-align: left; padding: 0.7rem 0.85rem; color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
table.data td { padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border-soft); color: var(--text); }
table.data tr:hover td { background: var(--navy-deep); }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.35rem; font-weight: 500; }
.input, .textarea, .select {
    width: 100%; background: var(--navy-light); color: var(--white);
    border: 1px solid var(--border-soft); border-radius: 8px;
    padding: 0.6rem 0.8rem; font-size: 0.88rem; font-family: inherit;
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--gold); }
.textarea { resize: vertical; min-height: 90px; }
.row { display: flex; gap: 1rem; }
.row > * { flex: 1; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(5,8,14,0.75);
    backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--navy-deep); border: 1px solid var(--border);
    border-radius: 14px; width: 100%; max-width: 540px; max-height: 90vh;
    overflow-y: auto; padding: 1.6rem;
}
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.modal-head h2 { color: var(--white); font-size: 1.2rem; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.4rem; cursor: pointer; }

/* ---------- Photo grid ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; }
.photo-item { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 4/3; background: var(--navy-light); cursor: pointer; }
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-flags { position: absolute; top: 0.4rem; left: 0.4rem; display: flex; gap: 0.3rem; }
.photo-flag { font-size: 0.62rem; font-weight: 700; padding: 0.15rem 0.45rem; border-radius: 10px; background: rgba(10,14,23,0.8); color: var(--white); }
.photo-flag.approved { background: var(--green); }
.photo-flag.visible { background: var(--blue); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border-soft); margin-bottom: 1.5rem; overflow-x: auto; }
.tab { padding: 0.7rem 1.1rem; color: var(--text-muted); font-size: 0.86rem; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold-light); border-bottom-color: var(--gold); }

/* ---------- Messages ---------- */
.msg-thread { display: flex; flex-direction: column; gap: 0.8rem; max-height: 460px; overflow-y: auto; padding: 0.5rem; }
.msg { max-width: 75%; padding: 0.7rem 1rem; border-radius: 14px; font-size: 0.88rem; }
.msg-staff { align-self: flex-start; background: var(--navy-light); border-bottom-left-radius: 4px; }
.msg-client { align-self: flex-end; background: rgba(201,162,39,0.16); border-bottom-right-radius: 4px; }
.msg-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.3rem; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { background: var(--navy-deep); border: 1px solid var(--border); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 420px; }
.auth-logo { width: 56px; height: 56px; border-radius: 12px; background: linear-gradient(135deg, var(--gold), var(--gold-light)); display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--navy-deepest); font-size: 1.3rem; margin: 0 auto 1.2rem; }
.auth-card h1 { color: var(--white); text-align: center; font-size: 1.4rem; margin-bottom: 0.3rem; }
.auth-card p.sub { color: var(--text-muted); text-align: center; font-size: 0.88rem; margin-bottom: 1.8rem; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--navy-light); border: 1px solid var(--border); border-left: 3px solid var(--gold); color: var(--white); padding: 0.85rem 1.2rem; border-radius: 8px; font-size: 0.86rem; opacity: 0; transform: translateY(10px); transition: all .3s; z-index: 200; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty .ico { font-size: 2.5rem; margin-bottom: 0.8rem; opacity: 0.5; }

/* ---------- Misc ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap { gap: 1rem; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 1.5rem; } .mb { margin-bottom: 1rem; }
.muted { color: var(--text-muted); }
.section-title { color: var(--white); font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }

/* ---------- Notifications ---------- */
.notif-badge { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; font-size: 0.62rem; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.notif-dropdown { position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-height: 460px; overflow-y: auto; background: var(--navy-medium); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); z-index: 150; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border-soft); font-weight: 700; color: var(--white); font-size: 0.9rem; position: sticky; top: 0; background: var(--navy-medium); }
.notif-clear { background: none; border: none; color: var(--gold-light); font-size: 0.75rem; cursor: pointer; font-family: inherit; }
.notif-item { display: block; padding: 0.8rem 1rem; border-bottom: 1px solid var(--border-soft); text-decoration: none; transition: background .12s; }
.notif-item:hover { background: var(--navy-light); text-decoration: none; }
.notif-item.unread { background: rgba(201,162,39,0.06); border-left: 2px solid var(--gold); }
.notif-title { color: var(--white); font-size: 0.85rem; font-weight: 600; }
.notif-body { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.15rem; }
.notif-time { color: var(--text-muted); font-size: 0.7rem; margin-top: 0.25rem; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Mobile ---------- */
@media (max-width: 880px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s; z-index: 90; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; padding: 1.25rem; }
    .mobile-toggle { display: inline-flex !important; }
}
.mobile-toggle { display: none; background: var(--navy-light); border: 1px solid var(--border-soft); color: var(--white); width: 40px; height: 40px; border-radius: 8px; align-items: center; justify-content: center; cursor: pointer; }
