/* =====================================================================
   Real Estate Lead Management CRM — Core Theme
   Palette:  Primary #1668b3 (blue) | Secondary #0e2c52 (navy) — Seshas Groups theme
             Background #F8F8F8 | Cards #FFFFFF
   Type:     Poppins (headings/brand) + Inter (body/data)
   ===================================================================== */

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

:root {
    /* Seshas Groups theme — white + blue, matching the company logo.
       The accent variables keep their original names (--gold*) so every
       existing rule that references them re-themes at once; the VALUES
       are now blues. */
    --gold: #1668b3;        /* primary blue accent (buttons, links, active nav) */
    --gold-dark: #0f4e8a;   /* darker blue for hovers */
    --gold-tint: #e8f1fb;   /* very light blue tint for highlights */
    --charcoal: #0e2c52;    /* deep navy sidebar */
    --charcoal-soft: #17436f;
    --bg: #F5F7FA;
    --card-bg: #ffffff;
    --text-main: #1f2733;
    --text-muted: #6b7280;
    --border: #e4e8ef;

    --blue: #1668b3;
    --teal: #2fa792;
    --purple: #8a63d2;
    --orange: #d9822b;
    --green: #2ea043;
    --red: #d64545;

    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 2px 10px rgba(14, 44, 82, 0.06);
    --shadow-md: 0 6px 24px rgba(14, 44, 82, 0.10);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    font-size: 14.5px;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .brand-font {
    font-family: 'Poppins', sans-serif;
}

a { text-decoration: none; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn-gold {
    background: var(--gold);
    border: 1px solid var(--gold);
    color: #fff;
    font-weight: 600;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn-gold:hover { background: var(--gold-dark); color: #fff; }
.btn-gold:active { transform: translateY(1px); }

/* ---------------------------------------------------------------------
   Auth pages (login / forgot / reset password)
   --------------------------------------------------------------------- */
.auth-body {
    background: linear-gradient(160deg, var(--charcoal) 0%, #17436f 55%, var(--gold-dark) 130%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.auth-wrapper { width: 100%; max-width: 440px; }
.auth-card {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 2.25rem 2rem;
    box-shadow: var(--shadow-md);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand i { font-size: 2.2rem; color: var(--gold); }
.auth-brand h1 { font-size: 1.35rem; font-weight: 700; margin: 0.4rem 0 0.2rem; color: var(--charcoal); }
.auth-brand p { color: var(--text-muted); font-size: 0.88rem; margin: 0; }
.link-forgot { color: var(--gold-dark); font-size: 0.85rem; font-weight: 500; }
.auth-demo-note {
    margin-top: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--gold-tint);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: #6b5828;
}

/* ---------------------------------------------------------------------
   App shell: sidebar + topbar + content
   --------------------------------------------------------------------- */
.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--charcoal);
    color: #d9d9de;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: transform 0.2s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.35rem 1.25rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1.02rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand i { color: var(--gold); font-size: 1.4rem; }

.sidebar-nav { padding: 0.75rem 0.6rem; overflow-y: auto; }
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #c6c6cd;
    padding: 0.62rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.89rem;
    font-weight: 500;
    margin-bottom: 0.15rem;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-badge {
    margin-left: auto;
    background: #dc3545;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.25rem 0.45rem;
    border-radius: 10px;
    min-width: 1.2rem;
    text-align: center;
}
.sidebar-nav .nav-link.active {
    background: rgba(200, 161, 77, 0.14);
    color: var(--gold);
    border-left-color: var(--gold);
}

.main-content {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - 240px);
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    margin-left: 240px;
}
.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    width: 38px; height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { background: var(--bg); }

/* Follow-up reminders bell in the topbar */
.topbar-bell { margin-left: auto; }
.notif-badge {
    position: absolute;
    top: 2px; right: 2px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--danger, #d64545);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
}
.notif-dropdown {
    width: 320px;
    max-width: 90vw;
    padding: 0;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.notif-header {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.notif-empty { padding: 1.1rem 0.9rem; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item {
    display: block;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-main);
}
.notif-item:hover { background: var(--bg); color: var(--text-main); }
.notif-name { font-weight: 600; font-size: 0.9rem; }
.notif-tag { font-size: 0.62rem; }
.notif-meta { font-size: 0.78rem; margin-top: 0.15rem; }
.notif-footer {
    display: block;
    padding: 0.6rem 0.9rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold, #1668b3);
    text-decoration: none;
    background: var(--bg);
}
.notif-footer:hover { color: var(--gold, #1668b3); text-decoration: underline; }

.global-search {
    flex: 1;
    max-width: 460px;
    position: relative;
    display: flex;
    align-items: center;
}
.global-search i { position: absolute; left: 14px; color: var(--text-muted); }
.global-search input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 999px;
    padding: 0.5rem 1rem 0.5rem 2.4rem;
    font-size: 0.86rem;
}
.global-search input:focus {
    outline: none;
    border-color: var(--gold);
    background: #fff;
}
.page-content { padding: 1.5rem; flex: 1; }
.page-heading { font-weight: 700; color: var(--charcoal); }

.app-footer {
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------------
   Cards / panels / stat tiles
   --------------------------------------------------------------------- */
.card-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}
.panel-title { font-weight: 600; color: var(--charcoal); margin-bottom: 0.9rem; font-size: 0.95rem; }

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.1rem 1.15rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    height: 100%;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: inherit;
}
.stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    color: #fff;
}
.stat-value { font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 1.4rem; line-height: 1.1; color: var(--charcoal); }
.stat-label { color: var(--text-muted); font-size: 0.78rem; margin-top: 0.15rem; }

.stat-gold .stat-icon   { background: var(--gold); }
.stat-blue .stat-icon   { background: var(--blue); }
.stat-teal .stat-icon   { background: var(--teal); }
.stat-purple .stat-icon { background: var(--purple); }
.stat-orange .stat-icon { background: var(--orange); }
.stat-green .stat-icon  { background: var(--green); }
.stat-red .stat-icon    { background: var(--red); }

/* Extra badge colors not in stock Bootstrap */
.bg-purple { background: var(--purple) !important; }
.bg-teal   { background: var(--teal) !important; }
.bg-orange { background: var(--orange) !important; }
.bg-gold   { background: var(--gold) !important; color: #fff !important; }

/* My Work home page — list of actionable items with call/WhatsApp buttons */
.mywork-list { display: flex; flex-direction: column; }
.mywork-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.mywork-item:last-child { border-bottom: none; }
.mywork-main { min-width: 0; }
.mywork-name { font-weight: 600; text-decoration: none; color: var(--text-main); display: block; }
.mywork-name:hover { color: var(--gold); }
.mywork-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.8rem; margin-top: 0.1rem; }
.mywork-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

.badge { font-weight: 500; font-size: 0.72rem; padding: 0.4em 0.65em; }

/* ---------------------------------------------------------------------
   Activity feed / mini tables (used on dashboard, later stage)
   --------------------------------------------------------------------- */
.activity-feed { list-style: none; margin: 0; padding: 0; }
.activity-feed li { display: flex; gap: 0.7rem; padding: 0.55rem 0; border-bottom: 1px dashed var(--border); font-size: 0.85rem; }
.activity-feed li:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-top: 6px; flex-shrink: 0; }

.mini-table { margin-bottom: 0; }
.mini-table td { border-color: var(--border); vertical-align: middle; font-size: 0.85rem; }
.small-link { font-size: 0.8rem; color: var(--gold-dark); font-weight: 500; }

/* Bulk actions bar (Leads list) — appears once 1+ checkboxes are
   checked (see initBulkActions() in app.js). */
.bulk-action-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    background: var(--gold-tint);
    border: 1px solid var(--gold);
    border-radius: var(--radius-sm);
}
.bulk-action-bar select { width: auto; max-width: 180px; }
.select-cell { width: 36px; }

/* ---------------------------------------------------------------------
   Generic form / table polish used across every future module
   --------------------------------------------------------------------- */
.form-label { font-weight: 500; font-size: 0.85rem; color: var(--text-main); }
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 0.88rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 0.2rem rgba(200, 161, 77, 0.18);
}

.table thead th {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom-width: 1px;
    background: var(--bg);
}

.card { border: 1px solid var(--border); border-radius: var(--radius); }

/* Multi-select status filter dropdown */
.status-multi .form-select { cursor: pointer; }
.status-multi-menu { max-height: 320px; overflow-y: auto; min-width: 240px; }
.status-multi-menu .dropdown-item { cursor: pointer; border-radius: 6px; }
.status-multi-menu .dropdown-item:hover { background: var(--bg); }

/* Follow-ups / Site Visits: greyed "closed" rows (negative outcomes)
   stay visible but clearly de-emphasized so active ones stand out. */
tr.followup-closed { opacity: 0.55; background: var(--bg); }
tr.followup-closed:hover { opacity: 0.8; }
tr.followup-closed td { color: var(--text-muted); }

/* Active / All / Closed tab bar */
.followup-view-tabs .nav-link { color: var(--text-muted); padding: 0.35rem 0.9rem; cursor: pointer; }
.followup-view-tabs .nav-link.active { background: var(--gold); color: #fff; }

.login-logo {
    width: 90px;
    height: 90px;
    object-fit: contain;
    margin-bottom: 15px;
}
.sidebar-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

/* Form section headings (e.g. Customer Information / Project Information
   on the Add & Edit Lead forms) — a subtle labelled divider. */
.form-section-heading {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gold);
    margin: 0.25rem 0 0.1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--gold-tint);
}

/* ===================== Calendar ===================== */
.cal-legend { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 0.75rem; color: var(--text-muted); }
.cal-legend::before { content: ""; width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.cal-legend.cal-followup::before { background: var(--gold); }
.cal-legend.cal-visit::before { background: #14a44d; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-weight: 600; font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; padding-bottom: 2px; }
.cal-cell { min-height: 96px; border: 1px solid var(--border); border-radius: 8px; padding: 4px 5px; background: var(--card-bg); overflow: hidden; }
.cal-cell.cal-empty { background: transparent; border: none; }
.cal-cell.cal-today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.cal-daynum { font-size: 0.78rem; font-weight: 600; color: var(--charcoal); margin-bottom: 3px; }
.cal-events { display: flex; flex-direction: column; gap: 3px; }
.cal-chip { display: block; font-size: 0.68rem; line-height: 1.2; padding: 2px 5px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; color: #fff; }
.cal-chip.cal-followup { background: var(--gold); }
.cal-chip.cal-visit { background: #14a44d; }
.cal-chip:hover { opacity: 0.9; color: #fff; }

.cal-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cal-dot.cal-followup { background: var(--gold); }
.cal-dot.cal-visit { background: #14a44d; }

/* Agenda list */
.agenda-day { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.agenda-day:last-child { border-bottom: none; }
.agenda-date { font-weight: 600; color: var(--charcoal); font-size: 0.85rem; margin-bottom: 0.35rem; }
.agenda-items { display: flex; flex-direction: column; gap: 0.3rem; }
.agenda-item { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: inherit; padding: 0.35rem 0.5rem; border-radius: 6px; }
.agenda-item:hover { background: var(--gold-tint); color: inherit; }
.agenda-name { font-weight: 600; font-size: 0.85rem; }
.agenda-sub { color: var(--text-muted); font-size: 0.78rem; }

@media (max-width: 767.98px) {
    /* The month grid is too cramped on phones — hide the whole grid card
       and rely on the day-by-day Agenda list below, which is built for
       mobile. The month nav (Prev/Today/Next) stays in the page header. */
    .cal-grid-card { display: none; }
}

/* ===================== Saved filters bar ===================== */
.saved-filter-bar .saved-filter-pill {
    display: inline-flex;
    align-items: center;
    background: var(--gold-tint, #f6efdd);
    border: 1px solid var(--gold, #B8860B);
    border-radius: 999px;
    padding: 1px 4px 1px 10px;
    font-size: 0.8rem;
    line-height: 1.6;
}
.saved-filter-bar .saved-filter-pill a {
    color: var(--charcoal, #333);
    text-decoration: none;
    font-weight: 600;
}
.saved-filter-bar .saved-filter-pill a:hover { text-decoration: underline; }
.saved-filter-bar .saved-filter-x {
    border: none;
    background: transparent;
    color: var(--text-muted, #777);
    font-size: 1rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    margin-left: 4px;
}
.saved-filter-bar .saved-filter-x:hover { color: #c0392b; }

/* ===================== AI Help Assistant (movable chat) ===================== */
#aiHelpLauncher {
    position: fixed;
    right: 18px;
    bottom: 84px;
    z-index: 1050;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gold, #B8860B);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 14px rgba(0,0,0,.25);
    cursor: grab;
    user-select: none;
    touch-action: none;
}
#aiHelpLauncher:active { cursor: grabbing; }

#aiHelpPanel {
    position: fixed;
    right: 18px;
    bottom: 146px;
    z-index: 1051;
    width: 330px;
    max-width: calc(100vw - 24px);
    height: 440px;
    max-height: calc(100vh - 170px);
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#aiHelpHeader {
    background: var(--navy, #1F3A5F);
    color: #fff;
    padding: 10px 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
#aiHelpHeader button {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}
#aiHelpMessages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #f7f8fa;
}
.aihelp-msg {
    max-width: 85%;
    padding: 8px 11px;
    border-radius: 12px;
    margin-bottom: 8px;
    font-size: 0.86rem;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.aihelp-bot { background: #fff; border: 1px solid #e3e6ea; border-bottom-left-radius: 3px; }
.aihelp-user { background: var(--gold-tint, #f6efdd); margin-left: auto; border-bottom-right-radius: 3px; }
#aiHelpInputRow {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid #e3e6ea;
    background: #fff;
}
#aiHelpInput {
    flex: 1;
    border: 1px solid #ced4da;
    border-radius: 20px;
    padding: 7px 12px;
    font-size: 0.86rem;
    outline: none;
}
#aiHelpInput:focus { border-color: var(--gold, #B8860B); }
#aiHelpSend {
    border: none;
    background: var(--gold, #B8860B);
    color: #fff;
    width: 38px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
}
@media (max-width: 576px) {
    #aiHelpPanel { right: 12px; left: 12px; width: auto; bottom: 150px; }
    #aiHelpLauncher { bottom: 78px; right: 14px; }
}
