/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1a56db;
    --primary-dark: #1340a8;
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #3b82f6;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
}

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

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

/* ===== Public Header ===== */
.public-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.public-header .logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.public-header .logo:hover { text-decoration: none; }

.public-nav a {
    margin-left: 1.5rem;
    color: var(--text-light);
    font-size: 0.95rem;
}

.public-nav a:hover { color: var(--primary); text-decoration: none; }
.public-nav a.active { color: var(--primary); font-weight: 600; }

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--text);
}

/* ===== Public Main ===== */
.public-main {
    max-width: 960px;
    margin: 0 auto;
    padding: 3rem 2rem;
    min-height: 60vh;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero__intro {
    font-size: 1.15rem;
    color: var(--text-light);
    max-width: 640px;
    margin: 0 auto;
}

.hero__intro p { margin-bottom: 0.5rem; }

/* ===== Page Header ===== */
.page-header {
    padding: 2rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.page-header__intro {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 640px;
}

.page-header__intro p { margin-bottom: 0.5rem; }

/* ===== StreamField Blocks ===== */
.text-section {
    padding: 2rem 0;
}

.text-section + .text-section {
    border-top: 1px solid var(--border);
}

.text-section h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.text-section__body p {
    margin-bottom: 1rem;
}

.text-section__body ul,
.text-section__body ol {
    margin: 0 0 1rem 1.5rem;
}

.text-section__body li {
    margin-bottom: 0.35rem;
}

/* CTA */
.cta-wrapper {
    padding: 1.5rem 0;
    text-align: center;
}

.btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
}

.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--bg-white);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover { background: var(--primary); color: #fff; }

/* Contact Info */
.contact-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0;
}

.contact-info__item {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.contact-info__item strong {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.contact-info__item a { font-size: 1.05rem; }
.contact-info__item p { margin: 0; }

/* Contact Form Placeholder */
.contact-form-placeholder {
    background: var(--bg-white);
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 3rem;
    text-align: center;
    margin-top: 2rem;
    color: var(--text-light);
}

.contact-form-placeholder h2 {
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* ===== Footer ===== */
.public-footer {
    border-top: 1px solid var(--border);
    background: var(--bg-white);
    padding: 3rem 2rem 2rem;
    margin-top: 2rem;
}

.footer-inner {
    max-width: 960px;
    margin: 0 auto;
    text-align: center;
}

.footer-brand {
    margin-bottom: 1rem;
}

.footer-brand strong {
    font-size: 1.1rem;
    color: var(--text);
}

.footer-brand p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.footer-links {
    margin-bottom: 1.5rem;
}

.footer-links a {
    color: var(--text-light);
    margin: 0 0.75rem;
    font-size: 0.9rem;
}

.footer-links a:hover { color: var(--primary); text-decoration: none; }

.footer-copy {
    color: var(--text-light);
    font-size: 0.8rem;
}

/* ===== Admin Layout ===== */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1.5rem 0;
    flex-shrink: 0;
}

.admin-sidebar .sidebar-logo {
    padding: 0 1.25rem 1.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

.admin-sidebar nav a {
    display: block;
    padding: 0.6rem 1.25rem;
    color: var(--sidebar-text);
    font-size: 0.9rem;
    transition: background 0.15s;
}

.admin-sidebar nav a:hover {
    background: rgba(255,255,255,0.08);
    text-decoration: none;
    color: #fff;
}

.admin-sidebar nav a.active {
    background: var(--sidebar-active);
    color: #fff;
}

.sidebar-section {
    margin-top: 1.25rem;
    padding: 0 1.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
    margin-bottom: 0.4rem;
}

.admin-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.admin-topbar h1 { font-size: 1.5rem; font-weight: 600; }
.admin-topbar .user-info { color: var(--text-light); font-size: 0.875rem; }

/* ===== Cards ===== */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.card h3 {
    font-size: 0.875rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.card .number { font-size: 2rem; font-weight: 700; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.dash-card { text-decoration: none !important; color: inherit; transition: box-shadow 0.15s; }
.dash-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.dash-sub { font-size: 0.85rem; color: var(--text-light); margin-top: 0.25rem; }
.dash-card-warn .number { color: var(--warning); }

.dashboard-activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.activity-list { list-style: none; }
.activity-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}
.activity-list li:last-child { border-bottom: none; }

/* ===== Placeholder ===== */
.placeholder-content {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.placeholder-content h2 { margin-bottom: 0.5rem; color: var(--text); }

/* ===== Login ===== */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
}

.login-container h1 { margin-bottom: 1.5rem; text-align: center; }

.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

.error-list {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    color: var(--danger);
    list-style: none;
}

/* ===== Filters ===== */
.filters-bar { margin-bottom: 1rem; }

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.filter-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}

.filters-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

/* ===== Data Table ===== */
.leads-count {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.table-wrapper {
    overflow-x: auto;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    background: var(--bg);
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table tbody tr:hover { background: #f1f5f9; }

.data-table .nowrap { white-space: nowrap; }

.data-table .empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new { background: #dcfce7; color: #166534; }
.badge-uncategorized { background: #f1f5f9; color: var(--text-light); }
.badge-letter_sent { background: #e0e7ff; color: #3730a3; }
.badge-follow_up { background: #fef3c7; color: #92400e; }
.badge-contacted { background: #dbeafe; color: #1e40af; }
.badge-converted { background: #dcfce7; color: #166534; }
.badge-not_interested { background: #fee2e2; color: #991b1b; }
.badge-closed { background: #f1f5f9; color: var(--text-light); }

/* Category color badges */
.badge-cat-red { background: #fee2e2; color: #991b1b; font-weight: 700; }
.badge-cat-yellow { background: #fef3c7; color: #92400e; font-weight: 700; }
.badge-cat-blue { background: #dbeafe; color: #1e40af; font-weight: 700; }
.badge-cat-uncategorized { background: #f1f5f9; color: var(--text-light); }

/* Category dot indicator */
.category-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.35rem;
    vertical-align: middle;
}
.category-dot--red { background: #ef4444; }
.category-dot--yellow { background: #f59e0b; }
.category-dot--blue { background: #3b82f6; }
.category-dot--uncategorized { background: #94a3b8; }

/* Row tinting */
.lead-row--red { border-left: 4px solid #ef4444; }
.lead-row--yellow { border-left: 4px solid #f59e0b; }
.lead-row--blue { border-left: 4px solid #3b82f6; }

/* Score reasons */
.score-reasons { font-size: 0.8rem; color: var(--text-light); max-width: 220px; }

/* Manual override tag */
.manual-tag { display: block; font-size: 0.7rem; color: var(--text-light); font-style: italic; }

/* Actions cell */
.actions-cell { display: flex; align-items: center; gap: 0.35rem; }
.inline-form { display: inline; }
.category-select {
    padding: 0.2rem 0.3rem;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}
.btn-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-light);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* Leads toolbar */
.leads-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem 0;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ===== Batch / Letters ===== */
.batch-form { margin-top: 0.75rem; }

.form-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    font-style: italic;
}

.section-heading {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #b91c1c; }

.messages { margin-bottom: 1rem; }
.message {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.message-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.message-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--success); }

/* ===== Batch detail ===== */
.batch-header { margin-bottom: 1rem; }
.back-link {
    font-size: 0.9rem;
    color: var(--text-light);
}
.back-link:hover { color: var(--primary); }

.batch-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.batch-bulk-action {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.mark-sent-form {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.mark-sent-form label {
    font-size: 0.85rem;
    color: var(--text-light);
    white-space: nowrap;
}

.days-input {
    width: 52px;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #15803d; }

.badge-sent { background: #dcfce7; color: #166534; }
.badge-draft { background: #f1f5f9; color: var(--text-light); }
.badge-partial { background: #fef3c7; color: #92400e; }

.batch-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.batch-footer-actions {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

/* ===== Follow-up ===== */
.overdue { color: var(--danger); font-weight: 600; }
.text-muted { color: var(--text-light); }
.notes-cell { font-size: 0.8rem; color: var(--text-light); max-width: 180px; }

/* ===== Lead Detail ===== */
.lead-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
}

.lead-detail-header h2 { font-size: 1.3rem; }
.lead-detail-meta { display: flex; gap: 0.5rem; }

.lead-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-list { font-size: 0.9rem; }
.detail-list dt {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}
.detail-list dd { margin: 0; }

.lead-notes { font-size: 0.9rem; color: var(--text); }

/* Call form */
.call-form-grid {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.call-notes-input {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
}

/* Call history */
.call-history { display: flex; flex-direction: column; gap: 0.75rem; }

.call-entry {
    border-left: 3px solid var(--border);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.call-entry-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.call-entry-date { font-size: 0.8rem; color: var(--text-light); }
.call-entry-user { font-size: 0.8rem; color: var(--text-light); }
.call-entry-callback { font-size: 0.8rem; color: var(--warning); margin-bottom: 0.25rem; }
.call-entry-notes { font-size: 0.85rem; color: var(--text); }

/* Outcome badges */
.badge-outcome-sale { background: #dcfce7; color: #166534; }
.badge-outcome-no_answer { background: #fef3c7; color: #92400e; }
.badge-outcome-call_back_later { background: #e0e7ff; color: #3730a3; }
.badge-outcome-not_interested { background: #fee2e2; color: #991b1b; }
.badge-outcome-invalid { background: #f1f5f9; color: var(--text-light); }

/* ===== Customer ===== */
.convert-form h3 { margin-top: 1rem; }
.convert-form h3:first-child { margin-top: 0; }

.convert-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.form-group--wide { grid-column: 1 / -1; }

/* Customer status badges */
.badge-cstatus-active { background: #dcfce7; color: #166534; }
.badge-cstatus-paused { background: #fef3c7; color: #92400e; }
.badge-cstatus-cancelled { background: #f1f5f9; color: var(--text-light); }

/* Billing badges */
.badge-billing-monthly { background: #e0e7ff; color: #3730a3; }
.badge-billing-semiannual { background: #dbeafe; color: #1e40af; }
.badge-billing-annual { background: #dcfce7; color: #166534; }

/* Build mode badges */
.badge-build-done_for_you { background: #dcfce7; color: #166534; }
.badge-build-client_builds { background: #fef3c7; color: #92400e; }

/* Site status badges */
.badge-site-not_started { background: #f1f5f9; color: var(--text-light); }
.badge-site-provisioning { background: #fef3c7; color: #92400e; }
.badge-site-ready { background: #dbeafe; color: #1e40af; }
.badge-site-live { background: #dcfce7; color: #166534; }
.badge-site-paused { background: #fef3c7; color: #92400e; }
.badge-site-cancelled { background: #fee2e2; color: #991b1b; }

/* Hosting status badges */
.badge-hosting-not_configured { background: #f1f5f9; color: var(--text-light); }
.badge-hosting-active { background: #dcfce7; color: #166534; }
.badge-hosting-paused { background: #fef3c7; color: #92400e; }
.badge-hosting-cancelled { background: #fee2e2; color: #991b1b; }

.lead-detail-meta { align-items: center; }

/* Service badges */
.badge-svc-active { background: #dcfce7; color: #166534; }
.badge-svc-inactive { background: #f1f5f9; color: var(--text-light); text-decoration: line-through; }

/* Document type badges */
.badge-doctype-contract { background: #dbeafe; color: #1e40af; }
.badge-doctype-plan { background: #fef3c7; color: #92400e; }
.badge-doctype-onboarding { background: #dcfce7; color: #166534; }
.badge-doctype-other { background: #f1f5f9; color: var(--text-light); }

/* Cancellation badges */
.badge-cancel-pending { background: #fef3c7; color: #92400e; }
.badge-cancel-completed { background: #fee2e2; color: #991b1b; }

/* CMS badge */
.badge-cms-wordpress { background: #dbeafe; color: #1e40af; }

/* Service add form */
.service-add-form { border-top: 1px solid var(--border); padding-top: 0.75rem; }
.service-add-grid {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.service-add-grid input {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Form select styling in cards */
.card .form-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-toggle { display: block; }

    .public-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-white);
        border-bottom: 1px solid var(--border);
        padding: 1rem 0;
        flex-direction: column;
    }

    .public-nav.open { display: flex; }

    .public-nav a {
        margin: 0;
        padding: 0.75rem 2rem;
        display: block;
        border-bottom: 1px solid var(--border);
    }

    .public-header { position: relative; }

    .hero h1 { font-size: 1.75rem; }
    .page-header h1 { font-size: 1.5rem; }

    .public-main { padding: 2rem 1rem; }

    .contact-info { grid-template-columns: 1fr; }
}
