/* =====================================================================
   Google Maps Business Extractor — application styles
   Layered on top of Bootstrap 5. Mobile-first, responsive.
   ===================================================================== */

:root {
    --gme-sidebar-w: 260px;
    --gme-topbar-h: 62px;
    --gme-brand: #1a73e8;
    --gme-brand-dark: #1557b0;
    --gme-bg: #f4f6fa;
    --gme-surface: #ffffff;
    --gme-border: #e3e8ef;
    --gme-text-muted: #6b7280;
    --gme-radius: 12px;
    --gme-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --gme-shadow-lg: 0 12px 28px rgba(16, 24, 40, .12);
}

body {
    background-color: var(--gme-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: .935rem;
    color: #1f2937;
    -webkit-font-smoothing: antialiased;
}

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

.app-main {
    flex: 1 1 auto;
    min-width: 0;                 /* lets flex children shrink so tables can scroll */
    display: flex;
    flex-direction: column;
    margin-left: var(--gme-sidebar-w);
}

.app-content {
    flex: 1 0 auto;
    padding: 1.5rem;
}

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

/* ---------------------------------------------------------------------
   Sidebar
   --------------------------------------------------------------------- */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--gme-sidebar-w);
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1045;
    transition: transform .22s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    min-height: var(--gme-topbar-h);
}

.brand-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 9px;
    background: var(--gme-brand);
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    display: grid;
    place-items: center;
    letter-spacing: .5px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.brand-text strong { color: #fff; font-size: .95rem; }
.brand-text small  { color: #7c8ba1; font-size: .72rem; }

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: .75rem .6rem;
}

.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .75rem;
    margin-bottom: .15rem;
    border-radius: 9px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: .9rem;
    transition: background-color .15s ease, color .15s ease;
}

.nav-link-item:hover,
.nav-link-item:focus-visible {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

.nav-link-item.active {
    background: var(--gme-brand);
    color: #fff;
    font-weight: 500;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

.sidebar-footer {
    padding: .6rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.version-tag {
    padding: .4rem .75rem 0;
    font-size: .7rem;
    color: #64748b;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 1040;
}

/* ---------------------------------------------------------------------
   Topbar
   --------------------------------------------------------------------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: var(--gme-topbar-h);
    padding: .6rem 1.5rem;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--gme-border);
}

.topbar-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--gme-brand);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    display: grid;
    place-items: center;
}

.navbar-toggler-icon-lines {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    width: 16px;
}

.navbar-toggler-icon-lines span {
    height: 2px;
    background: #334155;
    border-radius: 2px;
}

/* ---------------------------------------------------------------------
   Cards & stats
   --------------------------------------------------------------------- */
.card {
    border: 1px solid var(--gme-border);
    border-radius: var(--gme-radius);
    box-shadow: var(--gme-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--gme-border);
    font-weight: 600;
    padding: .85rem 1.1rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1.1rem;
    height: 100%;
}

.stat-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
    color: #0f172a;
}

.stat-label {
    font-size: .78rem;
    color: var(--gme-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tint-blue   { background: #e8f0fe; color: #1a73e8; }
.tint-green  { background: #e6f4ea; color: #137333; }
.tint-amber  { background: #fef7e0; color: #b06000; }
.tint-purple { background: #f3e8fd; color: #7b1fa2; }
.tint-red    { background: #fce8e6; color: #c5221f; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    margin-bottom: 0;
    font-size: .875rem;
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: .65rem .75rem;
}

.table thead th {
    background: #f8fafc;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .045em;
    color: #475569;
    border-bottom: 1px solid var(--gme-border);
    white-space: nowrap;
}

.table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.table thead th.sortable:hover { color: var(--gme-brand); }

.table tbody tr:hover { background: #f9fbfd; }

.cell-name {
    font-weight: 600;
    color: #0f172a;
    max-width: 260px;
}

.cell-address {
    max-width: 300px;
    color: #475569;
    font-size: .82rem;
}

.cell-truncate {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table td .badge { font-weight: 500; }

/* Sticky checkbox column on wide result tables */
.table th.col-check,
.table td.col-check {
    width: 38px;
    text-align: center;
}

/* ---------------------------------------------------------------------
   Badges / status pills
   --------------------------------------------------------------------- */
.pill {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 999px;
    font-size: .715rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.pill-new      { background: #e6f4ea; color: #137333; }
.pill-existing { background: #e8eaed; color: #3c4043; }
.pill-updated  { background: #e8f0fe; color: #1967d2; }
.pill-stale    { background: #fef7e0; color: #b06000; }
.pill-closed   { background: #fce8e6; color: #c5221f; }

.rating-star { color: #f9ab00; }

/* ---------------------------------------------------------------------
   Search page
   --------------------------------------------------------------------- */
.search-panel {
    background: linear-gradient(135deg, #1a73e8 0%, #174ea6 100%);
    border-radius: var(--gme-radius);
    color: #fff;
    padding: 1.5rem;
    box-shadow: var(--gme-shadow-lg);
}

.search-panel .form-label {
    color: rgba(255, 255, 255, .9);
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .3rem;
}

.search-panel .form-control,
.search-panel .form-select {
    border: 1px solid rgba(255, 255, 255, .25);
    background: rgba(255, 255, 255, .96);
}

.search-panel .form-control:focus,
.search-panel .form-select:focus {
    box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .3);
    border-color: #fff;
}

.search-panel .form-text { color: rgba(255, 255, 255, .75); }

/* Progress / loading overlay */
.loading-panel {
    border: 1px solid var(--gme-border);
    border-radius: var(--gme-radius);
    background: var(--gme-surface);
    padding: 1.75rem;
    text-align: center;
}

.loading-steps {
    list-style: none;
    margin: 1rem auto 0;
    padding: 0;
    max-width: 340px;
    text-align: left;
    font-size: .85rem;
}

.loading-steps li {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem 0;
    color: var(--gme-text-muted);
}

.loading-steps li.done   { color: #137333; }
.loading-steps li.active { color: #1a73e8; font-weight: 600; }

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    flex: 0 0 8px;
}

.loading-steps li.done .step-dot   { background: #137333; }
.loading-steps li.active .step-dot { background: #1a73e8; animation: pulse 1.2s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .45; transform: scale(1.35); }
}

.summary-strip {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.summary-chip {
    flex: 1 1 130px;
    background: var(--gme-surface);
    border: 1px solid var(--gme-border);
    border-radius: 10px;
    padding: .65rem .8rem;
}

.summary-chip .value {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.1;
}

.summary-chip .label {
    font-size: .72rem;
    color: var(--gme-text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ---------------------------------------------------------------------
   Business details
   --------------------------------------------------------------------- */
.detail-grid {
    display: grid;
    grid-template-columns: minmax(130px, 32%) 1fr;
    gap: .1rem 1rem;
    font-size: .885rem;
}

.detail-grid dt {
    color: var(--gme-text-muted);
    font-weight: 500;
    padding: .45rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.detail-grid dd {
    margin: 0;
    padding: .45rem 0;
    border-bottom: 1px solid #f1f5f9;
    word-break: break-word;
}

.hours-table td { padding: .35rem .5rem; font-size: .86rem; }
.hours-table tr:nth-child(odd) { background: #f8fafc; }

.photo-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 9px;
    background: #f1f5f9;
}

.chart-bar-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .82rem;
    padding: .25rem 0;
}

.chart-bar-label {
    flex: 0 0 34%;
    color: #475569;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-bar-track {
    flex: 1 1 auto;
    height: 8px;
    background: #eef2f7;
    border-radius: 999px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: var(--gme-brand);
    border-radius: 999px;
}

.chart-bar-value {
    flex: 0 0 44px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
    font-weight: 600;
}

/* ---------------------------------------------------------------------
   Login
   --------------------------------------------------------------------- */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #1a73e8 0%, #0f172a 100%);
    padding: 1.25rem;
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--gme-surface);
    border-radius: 16px;
    box-shadow: var(--gme-shadow-lg);
    padding: 2rem;
}

.login-logo {
    width: 52px;
    height: 52px;
    border-radius: 13px;
    background: var(--gme-brand);
    color: #fff;
    font-weight: 700;
    display: grid;
    place-items: center;
    margin: 0 auto .9rem;
}

/* ---------------------------------------------------------------------
   Utilities
   --------------------------------------------------------------------- */
.empty-state {
    padding: 3rem 1.25rem;
    text-align: center;
    color: var(--gme-text-muted);
}

.empty-state svg {
    width: 44px;
    height: 44px;
    opacity: .35;
    margin-bottom: .75rem;
}

.text-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem;
}

.raw-json {
    background: #0f172a;
    color: #cbd5e1;
    border-radius: 9px;
    padding: 1rem;
    font-size: .76rem;
    max-height: 420px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.policy-note {
    font-size: .8rem;
    border-left: 3px solid #f9ab00;
    background: #fffdf5;
    padding: .65rem .85rem;
    border-radius: 0 8px 8px 0;
    color: #6b5200;
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--gme-shadow-lg);
    }

    .app-sidebar.open { transform: translateX(0); }

    .app-main { margin-left: 0; }

    .app-topbar { padding: .6rem 1rem; }

    .app-content { padding: 1rem; }
}

@media (max-width: 575.98px) {
    .stat-value { font-size: 1.35rem; }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .detail-grid dt {
        border-bottom: 0;
        padding-bottom: 0;
        font-size: .76rem;
        text-transform: uppercase;
        letter-spacing: .03em;
    }

    .cell-name, .cell-address { max-width: 190px; }

    .search-panel { padding: 1.15rem; }
}

@media print {
    .app-sidebar, .app-topbar, .app-footer, .btn, .toast-container { display: none !important; }
    .app-main { margin-left: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
