@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ================================================================
   RESET
================================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

/* ================================================================
   BASE — no layout here, just typography + colour
================================================================ */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f2f2f7;   /* iOS-style grey */
    color: #1c1c1e;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
    line-height: 1.5;
}

/* ================================================================
   LOGIN PAGE
================================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background: #f2f2f7;
}

.login-card {
    background: transparent;
    width: 100%;
    max-width: 360px;
    padding: 0;
}

.login-logo {
    display: block;
    width: 60px; height: 60px;
    object-fit: contain;
    margin: 0 auto 1.75rem;
}

.login-title {
    text-align: center;
    font-size: 1.625rem;
    font-weight: 700;
    color: #1c1c1e;
    letter-spacing: -.02em;
    margin-bottom: .3rem;
}

.login-sub {
    text-align: center;
    font-size: .875rem;
    color: #8e8e93;
    margin-bottom: 2.25rem;
}

.error-message {
    background: #fff1f0;
    color: #c0392b;
    padding: .75rem 1rem;
    border-radius: 12px;
    font-size: .85rem;
    margin-bottom: 1.25rem;
    border: 1px solid #ffc9c9;
}

/* ================================================================
   FORMS
================================================================ */
.form-group { margin-bottom: 1.1rem; }

/* Login-specific grouped fields — iOS Settings style */
.login-field-group {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e5e5ea;
    overflow: hidden;
}

.login-field { position: relative; }

.login-field + .login-field {
    border-top: 1px solid #e5e5ea;
}

.login-field .form-control {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: .9rem 1rem;
    font-size: 1rem;
}

.login-field .form-control:focus {
    background: #fafafa;
    border: none;
    box-shadow: none;
}

.login-forgot {
    display: block;
    text-align: center;
    margin-top: 1.1rem;
    font-size: .82rem;
    color: #aeaeb2;
    text-decoration: none;
    letter-spacing: -.01em;
}
.login-forgot:hover { color: #636366; }

/* Hide labels inside login grouped block */
.login-field label {
    display: none;
}

/* (legacy stubs removed) */

.form-group label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: #3a3a3c;
    margin-bottom: .35rem;
    letter-spacing: .01em;
}

.form-control {
    width: 100%;
    padding: .875rem 1rem;
    font-size: 1rem;
    color: #1c1c1e;
    background: #fff;
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    font-family: inherit;
    transition: border-color .15s, background .15s;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: #c7c7cc;
    background: #fff;
    box-shadow: none;
    z-index: 1;
    position: relative;
}

.form-control::placeholder { color: #c7c7cc; }
textarea.form-control { resize: vertical; min-height: 88px; }

/* ================================================================
   BUTTONS
================================================================ */
.btn, .btn-sm, .btn-save {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    font-size: .875rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity .15s, transform .1s;
    line-height: 1;
    letter-spacing: -.01em;
}

.btn:active, .btn-sm:active, .btn-save:active {
    transform: scale(.97);
    opacity: .85;
}

.btn:hover, .btn-sm:hover { opacity: .88; }

.btn-primary  { background: #007aff; color: #fff; }
.btn-success  { background: #34c759; color: #fff; }
.btn-danger   { background: #ff3b30; color: #fff; }
.btn-accent   { background: #007aff; color: #fff; }
.btn-muted    { background: #636366; color: #fff; }
.btn-warn     { background: #ff9500; color: #fff; }
.btn-ghost    { background: #f2f2f7; color: #3a3a3c; border: 1.5px solid #e5e5ea; }
.btn-indigo   { background: #5856d6; color: #fff; }

.btn-block {
    display: flex;
    width: 100%;
    padding: .9rem 1rem;
    font-size: .9375rem;
    border-radius: 14px;
    justify-content: center;
    letter-spacing: -.01em;
}

/* Login Sign In button — clean dark pill */
.login-card .btn-primary {
    background: #1c1c1e;
    color: #fff;
    border-radius: 14px;
    font-size: .9375rem;
    font-weight: 600;
    letter-spacing: -.01em;
    box-shadow: none;
}
.login-card .btn-primary:hover { opacity: .85; }
.login-card .btn-primary:active { opacity: .7; transform: scale(.98); }

/* ================================================================
   ALERTS
================================================================ */
.alert { padding: .875rem 1rem; border-radius: 12px; font-size: .875rem; margin-bottom: 1rem; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fff1f0; color: #c0392b; border: 1px solid #ffc9c9; }
.alert-warn    { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ================================================================
   PAGE SHELL  (all dashboard-type pages)
================================================================ */
.page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ================================================================
   APP BAR — iOS-style translucent sticky header
================================================================ */
.app-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    background: rgba(255,255,255,.92);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(0,0,0,.09);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: .75rem;
}

.app-bar img {
    width: 30px !important;
    height: 30px !important;
    object-fit: contain;
    flex-shrink: 0;
}

.app-bar-title {
    flex: 1;
    font-size: .9375rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1c1c1e;
}

.app-bar-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

/* ================================================================
   PAGE BODY
================================================================ */
.page-body {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

/* ================================================================
   CARDS
================================================================ */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.07), 0 0 0 .5px rgba(0,0,0,.06);
}

/* ================================================================
   BADGES
================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .65rem;
    border-radius: 100px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .01em;
}

.badge-green  { background: #d1fae5; color: #065f46; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f2f2f7; color: #636366; }

/* ================================================================
   SECTION LABEL
================================================================ */
.section-label {
    font-size: .72rem;
    font-weight: 700;
    color: #8e8e93;
    text-transform: uppercase;
    letter-spacing: .07em;
    margin: 1.25rem 0 .5rem .1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ================================================================
   SUMMARY WIDGETS
================================================================ */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    margin-bottom: 1rem;
}

@media (max-width: 380px) {
    .summary-grid { grid-template-columns: 1fr; }
}

.summary-widget {
    background: #fff;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.07), 0 0 0 .5px rgba(0,0,0,.06);
    min-width: 0;
}

.widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .75rem;
}

.widget-title { font-size: .82rem; font-weight: 700; color: #1c1c1e; }

.widget-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .3rem;
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background .12s;
}
.widget-item:hover, .widget-item:active { background: #f2f2f7; }
.widget-item-body { flex: 1; min-width: 0; }
.widget-item-name { font-size: .82rem; font-weight: 600; color: #1c1c1e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.widget-item-sum  { font-size: .72rem; color: #8e8e93; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.widget-item-time { font-size: .68rem; color: #aeaeb2; white-space: nowrap; flex-shrink: 0; }

/* ================================================================
   CHAT LIST
================================================================ */
.chat-list { display: flex; flex-direction: column; }

.chat-item {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .875rem 1rem;
    border-bottom: 1px solid #f2f2f7;
    text-decoration: none;
    color: inherit;
    transition: background .1s;
    cursor: pointer;
}
.chat-item:last-child { border-bottom: none; }
.chat-item:hover, .chat-item:active { background: #f9f9f9; }

.chat-avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: #1c1c1e;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0; overflow: hidden;
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }

.chat-info    { flex: 1; min-width: 0; }
.chat-name    { font-weight: 600; font-size: .9rem; color: #1c1c1e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-phone   { font-size: .72rem; color: #8e8e93; margin-top: 1px; }
.chat-preview { font-size: .78rem; color: #aeaeb2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-sub     { font-size: .7rem; color: #34c759; margin-top: 1px; }
.chat-time    { font-size: .7rem; color: #aeaeb2; white-space: nowrap; flex-shrink: 0; align-self: flex-start; padding-top: 3px; }

/* ================================================================
   CHAT BUBBLES
================================================================ */
.msg-row { display: flex; align-items: flex-end; gap: .5rem; margin-bottom: .15rem; }
.msg-row.outbound { flex-direction: row-reverse; }

.bubble {
    max-width: 74%;
    padding: .6rem .9rem;
    border-radius: 18px;
    font-size: .9rem;
    line-height: 1.5;
    word-break: break-word;
}
.bubble-in  { background: #fff; color: #1c1c1e; border-bottom-left-radius: 5px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.bubble-out { background: #007aff; color: #fff; border-bottom-right-radius: 5px; }
.bubble-out .bubble-time { color: rgba(255,255,255,.7); }
.bubble-time { font-size: .63rem; color: #aeaeb2; margin-top: 3px; text-align: right; }

.date-divider { text-align: center; margin: .9rem 0 .4rem; }
.date-divider span { background: rgba(0,0,0,.1); color: #fff; font-size: .7rem; padding: .2rem .8rem; border-radius: 100px; }

.ai-label { font-size: .63rem; color: #34c759; font-weight: 700; margin-bottom: 2px; text-align: right; }

/* ================================================================
   TABLES
================================================================ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .75rem .875rem; text-align: left; border-bottom: 1px solid #f2f2f7; }
th { font-weight: 600; color: #8e8e93; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; background: #fafafa; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ================================================================
   EMPTY STATE
================================================================ */
.empty-state { text-align: center; padding: 3rem 1rem; color: #aeaeb2; }
.empty-state-icon { font-size: 3rem; margin-bottom: .875rem; }
.empty-state p { font-size: .875rem; }

/* ================================================================
   MOBILE HEADER NAV LINKS (replaces bottom nav)
================================================================ */
.hdr-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 1.1rem;
    text-decoration: none;
    background: rgba(0,0,0,.05);
    color: #1c1c1e;
    transition: background .15s, opacity .15s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.hdr-nav-link:active { opacity: .6; }
.hdr-nav-link:hover  { background: rgba(0,0,0,.09); }
.hdr-nav-danger      { background: rgba(255,59,48,.1); color: #ff3b30; }
.hdr-nav-danger:hover { background: rgba(255,59,48,.18); }

/* ================================================================
   MOBILE BOTTOM TAB BAR  (kept for reference / other pages)
================================================================ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(255,255,255,.96);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid rgba(0,0,0,.1);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
    display: flex;
    height: 100%;
    align-items: stretch;
}
.bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: #8e8e93;
    font-size: .65rem;
    font-weight: 600;
    padding: 6px 0 4px;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
}
.bnav-item.active { color: #007aff; }
.bnav-item:active { opacity: .6; }
.bnav-icon {
    font-size: 1.45rem;
    line-height: 1;
    display: block;
}

/* ================================================================
   DETAIL PAGE (lead/complaint)
================================================================ */
.detail-header {
    background: rgba(255,255,255,.92);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    padding: .875rem 1.25rem;
    display: flex; align-items: center; gap: .875rem;
    border-bottom: 1px solid rgba(0,0,0,.09);
    position: sticky; top: 0; z-index: 10;
}
.back-btn { color: #007aff; text-decoration: none; font-size: .9375rem; font-weight: 600; flex-shrink: 0; }
.header-avatar {
    width: 40px; height: 40px; border-radius: 50%; overflow: hidden;
    background: #1c1c1e; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .95rem; flex-shrink: 0;
}
.header-info { flex: 1; min-width: 0; }
.header-name  { font-weight: 700; font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-phone { font-size: .72rem; color: #8e8e93; }
.status-badge { display: inline-block; padding: .2rem .65rem; border-radius: 100px; font-size: .72rem; font-weight: 700; flex-shrink: 0; }

/* Detail body */
.detail-body { padding: 1rem 1rem 3rem; max-width: 900px; margin: 0 auto; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.detail-card {
    background: #fff; border-radius: 16px; padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.07), 0 0 0 .5px rgba(0,0,0,.06);
}
.detail-card h3 { font-size: .875rem; font-weight: 700; margin-bottom: .875rem; color: #1c1c1e; }
.summary-text { font-size: .875rem; color: #3a3a3c; line-height: 1.6; margin-bottom: .875rem; }
.details-table { width: 100%; font-size: .82rem; border-collapse: collapse; }
.details-table td { padding: .3rem 0; vertical-align: top; }
.details-table td:first-child { color: #8e8e93; font-weight: 600; padding-right: .75rem; width: 40%; }

.section-heading { font-size: .72rem; font-weight: 700; color: #8e8e93; text-transform: uppercase; letter-spacing: .07em; margin: 1.25rem 0 .75rem; }

.messages-area {
    background: #e5ddd5;
    border-radius: 16px; padding: 1rem;
    display: flex; flex-direction: column; gap: .3rem;
    max-height: 500px; overflow-y: auto;
}

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 640px) {
    /* Grids → 1 col */
    .summary-grid { grid-template-columns: 1fr; }
    .two-col       { grid-template-columns: 1fr; }

    /* Show mobile bottom nav, hide desktop nav actions */
    .bottom-nav  { display: flex; }
    .desktop-only { display: none !important; }

    /* Bubbles can be wider on phone */
    .bubble { max-width: 85%; }

    /* Table font */
    th, td { padding: .6rem .6rem; font-size: .8rem; }
}

@media (min-width: 641px) {
    .mobile-only { display: none !important; }
}

/* ================================================================
   UTILITIES
================================================================ */
.text-muted { color: #8e8e93; }
.text-sm    { font-size: .82rem; }
.text-xs    { font-size: .72rem; }
.font-bold  { font-weight: 700; }
.truncate   { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-full     { width: 100%; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
