/* ===================================
   FlatKey Design System
   Real Estate Brokerage Platform
   =================================== */

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Primary Colors — FlatKey brand green (matches landing/search pages:
       ink #1a1a1a / ivory #faf9f6 / green #2c5545 / gold #c8a96e).
       Replaced the pre-brand navy (#1e3a5f) 2026-07-15. */
    --primary: #2c5545;
    --primary-light: #3a7a5c;
    --primary-dark: #1f3d31;
    --primary-50: #e9f0ec;
    --primary-100: #cfdfd6;

    /* Accent — FlatKey gold */
    --accent: #c8a96e;
    --accent-light: #d8c08e;
    --accent-dark: #a88a50;

    /* Status Colors */
    --success: #22c55e;
    --success-bg: #f0fdf4;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    --info-bg: #eff6ff;

    /* Neutrals */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-family);
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
}

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

a:hover {
    color: var(--primary-light);
}

img {
    max-width: 100%;
    display: block;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary-dark);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 0 12px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--border-radius);
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-link.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.nav-link .nav-icon {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}

.nav-link .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--border-radius);
}

.sidebar-user:hover {
    background: rgba(255,255,255,0.1);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary-dark);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    text-transform: capitalize;
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: var(--border-radius);
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    text-decoration: none;
}

.sidebar-logout:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.top-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--gray-600);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.breadcrumb a {
    color: var(--gray-500);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb .separator {
    color: var(--gray-300);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-search {
    position: relative;
}

.header-search input {
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    width: 240px;
    background: var(--gray-50);
    transition: all 0.2s;
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-50);
}

.header-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    width: 16px;
    height: 16px;
}

/* Notification Bell */
.notification-bell {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--gray-500);
    border-radius: var(--border-radius);
    transition: all 0.15s;
}

.notification-bell:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 360px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    max-height: 480px;
    overflow-y: auto;
}

.notification-dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-dropdown-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    gap: 12px;
    transition: background 0.15s;
    cursor: pointer;
}

.notification-item:hover {
    background: var(--gray-50);
}

.notification-item.unread {
    background: var(--info-bg);
}

.notification-item .notif-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.notification-item .notif-content {
    flex: 1;
    min-width: 0;
}

.notification-item .notif-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-800);
}

.notification-item .notif-message {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 2px;
}

.notification-item .notif-time {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-top: 4px;
}

/* Content Area */
.content-area {
    padding: 32px;
    flex: 1;
}

/* --- Cards --- */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* --- Metric Cards --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.metric-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.metric-icon.blue { background: var(--info-bg); color: var(--info); }
.metric-icon.green { background: var(--success-bg); color: var(--success); }
.metric-icon.amber { background: var(--warning-bg); color: var(--warning); }
.metric-icon.red { background: var(--danger-bg); color: var(--danger); }
.metric-icon.purple { background: #f3e8ff; color: #9333ea; }

.metric-content h3 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
    margin-top: 4px;
}

.metric-change {
    font-size: 0.75rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.metric-change.up { color: var(--success); }
.metric-change.down { color: var(--danger); }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    line-height: 1;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-50);
    color: var(--gray-700);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #16a34a;
    color: white;
}

.btn-accent {
    background: var(--accent);
    color: white;
}

.btn-accent:hover:not(:disabled) {
    background: #d4952e;
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--gray-100);
    color: var(--gray-600);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-family: var(--font-family);
    color: var(--gray-800);
    background: white;
    transition: all 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.form-control::placeholder {
    color: var(--gray-400);
}

.form-control.error {
    border-color: var(--danger);
}

.form-control.error:focus {
    box-shadow: 0 0 0 3px var(--danger-bg);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* --- Tables --- */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

table td {
    padding: 14px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

table tr:hover td {
    background: var(--gray-50);
}

table .cell-primary {
    font-weight: 600;
    color: var(--gray-900);
}

table .cell-mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

/* --- Badges / Tags --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-blue { background: var(--info-bg); color: #1d4ed8; }
.badge-green { background: var(--success-bg); color: #15803d; }
.badge-amber { background: var(--warning-bg); color: #b45309; }
.badge-red { background: var(--danger-bg); color: #b91c1c; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-purple { background: #f3e8ff; color: #7e22ce; }

/* --- Status Pipeline --- */
.status-pipeline {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 0;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--gray-100);
    color: var(--gray-500);
    position: relative;
}

.pipeline-step.active {
    background: var(--primary);
    color: white;
}

.pipeline-step.completed {
    background: var(--success-bg);
    color: var(--success);
}

.pipeline-connector {
    width: 24px;
    height: 2px;
    background: var(--gray-300);
    flex-shrink: 0;
}

.pipeline-connector.completed {
    background: var(--success);
}

/* --- Activity Feed --- */
.activity-feed {
    padding: 0;
    list-style: none;
}

.activity-item {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-100);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: 0.875rem;
    color: var(--gray-700);
}

.activity-text strong {
    color: var(--gray-900);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 4px;
}

/* --- Wizard / Steps --- */
.wizard-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 40px;
    padding: 0 20px;
}

.wizard-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--gray-400);
    font-weight: 500;
}

.wizard-step .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.wizard-step.active {
    color: var(--primary);
}

.wizard-step.active .step-number {
    background: var(--primary);
    color: white;
}

.wizard-step.completed {
    color: var(--success);
}

.wizard-step.completed .step-number {
    background: var(--success);
    color: white;
}

.wizard-connector {
    width: 48px;
    height: 2px;
    background: var(--gray-200);
    margin: 0 8px;
}

.wizard-connector.completed {
    background: var(--success);
}

/* --- Alerts --- */
.alert {
    padding: 14px 18px;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.alert-info { background: var(--info-bg); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.pagination a:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.pagination .active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto 20px;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab:hover {
    color: var(--gray-700);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* --- Modal --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-backdrop.show .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--gray-400);
    padding: 4px;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--border-radius);
    background: white;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 320px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- File Upload --- */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-50);
}

.upload-zone .upload-icon {
    font-size: 2rem;
    color: var(--gray-400);
    margin-bottom: 12px;
}

.upload-zone p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.upload-zone .upload-btn {
    color: var(--primary);
    font-weight: 600;
}

/* --- Grid Toggle (List/Grid views) --- */
.view-toggle {
    display: flex;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.view-toggle button {
    padding: 8px 12px;
    background: white;
    border: none;
    cursor: pointer;
    color: var(--gray-500);
}

.view-toggle button.active {
    background: var(--primary);
    color: white;
}

/* --- Listing Cards Grid --- */
.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.listing-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.listing-card:hover {
    box-shadow: var(--shadow-md);
}

.listing-card-img {
    height: 200px;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 2rem;
    position: relative;
}

.listing-card-img .listing-status-badge {
    position: absolute;
    top: 12px;
    left: 12px;
}

/* Heart / favourite button */
.heart-wrap { display: inline-flex; }
.heart-btn { background: none; border: none; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 4px; transition: background 0.15s; }
.heart-btn:hover { background: rgba(220,38,38,0.08); }
.listing-card-img .heart-wrap { background: rgba(255,255,255,0.85); border-radius: 6px; }
.listing-card-img .heart-wrap .heart-btn span { display: none; }

.listing-card-body {
    padding: 16px;
}

.listing-card-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.listing-card-address {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-top: 4px;
}

.listing-card-meta {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--gray-500);
}

/* --- Utilities --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mr-2 { margin-right: 8px; }
.ml-auto { margin-left: auto; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.hidden { display: none; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Auth Pages (Login/Register) --- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.auth-card {
    background: white;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-brand h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -1px;
}

.auth-brand p {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* --- HTMX loading --- */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

    .mobile-menu-btn {
        display: block;
    }

    .content-area {
        padding: 16px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .header-search {
        display: none;
    }

    .listings-grid {
        grid-template-columns: 1fr;
    }

    .wizard-steps {
        flex-wrap: wrap;
    }

    .wizard-step .step-label {
        display: none;
    }

    .status-pipeline {
        flex-wrap: wrap;
    }

    .proceeds-calculator {
        padding: 16px;
    }
}


/* ---------------------------------------------------------------------------
   Enrichment Card
   --------------------------------------------------------------------------- */

.enrichment-card {
    background: var(--gray-50);
    border: 2px solid var(--success);
    border-radius: var(--border-radius-lg, 12px);
    padding: 24px;
    margin-top: 16px;
}

.enrichment-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.enrichment-card h4 {
    margin: 0;
    color: var(--success);
    font-size: 1rem;
}

.enrichment-confirmed-address {
    margin: 4px 0 0 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.enrichment-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

.enrichment-map-wrapper {
    min-height: 200px;
}

.enrichment-data-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.enrichment-geocode-only {
    margin: 0;
    color: var(--gray-600);
    font-size: 0.9rem;
    line-height: 1.5;
}

.enrichment-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.enrichment-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.enrichment-field .field-label {
    color: var(--gray-500);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.enrichment-field .field-value {
    font-weight: 600;
    font-size: 0.95rem;
}

.enrichment-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Responsive: stack map above data on narrow screens */
@media (max-width: 640px) {
    .enrichment-body {
        grid-template-columns: 1fr;
    }
}

.enrichment-error {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--border-radius, 8px);
    padding: 16px;
    margin-top: 16px;
}


/* ---------------------------------------------------------------------------
   HTMX Loading Indicator + Spinner
   --------------------------------------------------------------------------- */

.htmx-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    color: var(--gray-500);
    font-size: 0.9rem;
    padding: 12px 0;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: flex;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ---------------------------------------------------------------------------
   Net Proceeds Calculator
   --------------------------------------------------------------------------- */

.proceeds-calculator {
    background: var(--gray-50);
    border-radius: var(--border-radius-lg, 12px);
    padding: 24px;
    margin-top: 16px;
}

.proceeds-line {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-200);
}

.proceeds-line:last-child {
    border-bottom: none;
}

.proceeds-line.total {
    font-weight: 700;
    font-size: 1.1rem;
    padding-top: 12px;
    border-top: 2px solid var(--gray-300);
    border-bottom: none;
}

.proceeds-line .label {
    color: var(--gray-600);
}

.proceeds-line .value {
    font-weight: 600;
}

.proceeds-line .value.positive {
    color: var(--success);
}

.proceeds-line .value.negative {
    color: var(--danger);
}

.savings-highlight {
    background: #ecfdf5;
    border: 2px solid var(--success);
    border-radius: var(--border-radius-lg, 12px);
    padding: 20px;
    margin-top: 16px;
    text-align: center;
}

.savings-highlight .savings-amount {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 4px;
}

.savings-highlight .savings-label {
    color: var(--gray-600);
    font-size: 0.9rem;
}


/* ---------------------------------------------------------------------------
   Coop Commission Toggle
   --------------------------------------------------------------------------- */

.coop-toggle-card {
    background: var(--gray-50);
    border: 1px solid var(--border);
    border-radius: var(--border-radius-lg, 12px);
    padding: 20px;
}

.coop-warning {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: var(--border-radius, 8px);
    padding: 12px 16px;
    margin-top: 4px;
}


/* ---------------------------------------------------------------------------
   Inclusions Checkbox Grid
   --------------------------------------------------------------------------- */

.inclusions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.inclusions-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: var(--border-radius, 8px);
    cursor: pointer;
    font-size: 0.9rem;
}

.inclusions-grid label:hover {
    background: var(--gray-100);
}


/* ---------------------------------------------------------------------------
   Auto-filled Badge
   --------------------------------------------------------------------------- */

.badge-auto-filled {
    display: inline-block;
    background: #dbeafe;
    color: #1e40af;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}


/* ---------------------------------------------------------------------------
   Condition Rating Buttons
   --------------------------------------------------------------------------- */

.condition-rating {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.condition-btn {
    padding: 8px 16px;
    border: 2px solid var(--gray-300);
    border-radius: var(--border-radius, 8px);
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.condition-btn:hover {
    border-color: var(--primary);
}

.condition-btn.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}


/* ---------------------------------------------------------------------------
   Paragon Sheet
   --------------------------------------------------------------------------- */

.paragon-field {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.paragon-field .paragon-label {
    width: 200px;
    color: var(--gray-500);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.paragon-field .paragon-value {
    flex: 1;
    font-weight: 500;
}

.paragon-field .copy-btn {
    margin-left: 8px;
    flex-shrink: 0;
}

/* ===================================
   Buyer Workflow Styles
   =================================== */

/* Engagement wizard progress */
.progress-step-wrapper {
    display: flex;
    align-items: center;
}

.progress-line {
    width: 40px;
    height: 2px;
    background: var(--border);
    margin: 0 4px;
}

.progress-line.active {
    background: var(--primary);
}

/* Draft comparison grid */
.draft-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin: 24px 0;
}

.draft-card {
    border: 2px solid var(--border);
    transition: border-color 0.2s;
}

.draft-card:hover {
    border-color: var(--primary-light);
}

.draft-terms {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.term-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.term-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.term-value {
    font-weight: 600;
}

.draft-cover-letter,
.draft-strategy {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Savings calculator */
.calculator-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 20px;
}

.calculator-container h1 {
    text-align: center;
    margin-bottom: 8px;
}

.calculator-container .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.savings-result {
    margin-top: 24px;
}

.savings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.savings-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
}

.savings-card.savings-highlight {
    background: var(--primary-50);
    border: 2px solid var(--primary);
}

.savings-card.savings-net {
    background: var(--success-bg, #ecfdf5);
}

.savings-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.savings-amount {
    font-size: 1.5rem;
    font-weight: 700;
}

.savings-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.savings-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-50);
    border-radius: var(--radius-lg);
    padding: 8px 16px;
}

.savings-preview {
    background: var(--primary-50);
    border-radius: var(--radius);
    padding: 16px;
    margin: 16px 0;
}

/* Risk badges */
.risk-badge {
    padding: 4px 12px;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
}

.risk-badge.risk-low { background: var(--success-bg, #ecfdf5); color: var(--success, #059669); }
.risk-badge.risk-medium { background: var(--warning-bg, #fffbeb); color: var(--warning, #d97706); }
.risk-badge.risk-high { background: var(--error-bg, #fef2f2); color: var(--error, #dc2626); }

.risk-flag-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.risk-flag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.risk-severity {
    padding: 2px 8px;
    border-radius: var(--radius);
    font-size: 0.7rem;
    font-weight: 700;
}

.risk-severity.risk-low { background: var(--success-bg, #ecfdf5); color: var(--success, #059669); }
.risk-severity.risk-medium { background: var(--warning-bg, #fffbeb); color: var(--warning, #d97706); }
.risk-severity.risk-high { background: var(--error-bg, #fef2f2); color: var(--error, #dc2626); }

/* Engagement / payment */
.disclosure-text,
.agreement-text {
    max-height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.7;
}

.simple-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.simple-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.payment-summary {
    text-align: center;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.payment-amount {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.payment-form-stub {
    padding: 16px;
    margin-bottom: 16px;
}

.confirmation-content {
    text-align: center;
    padding: 24px;
}

.confirmation-icon {
    font-size: 3rem;
    color: var(--success, #059669);
    margin-bottom: 16px;
}

.confirmation-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.confidence-badge {
    padding: 4px 12px;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-secondary);
}

/* Counter offer */
.terms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.term-item {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.unclear-items {
    margin-top: 20px;
    padding: 16px;
    background: var(--warning-bg, #fffbeb);
    border-radius: var(--radius);
}

/* Review page */
.review-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

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

.review-actions {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.variant-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.variant-summary.variant-active {
    background: var(--primary-50);
    border-radius: var(--radius);
}

.draft-json {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

/* Public pages (no sidebar) */
.public-page {
    min-height: 100vh;
    padding: 40px 20px;
}

/* Info grid for calculator */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.info-card {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.info-card h4 {
    margin-bottom: 8px;
    color: var(--primary);
}

.cta-section {
    text-align: center;
    margin-top: 40px;
}

/* Section divider */
.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* Checkbox grid for subjects */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.checkbox-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}

.checkbox-card:hover {
    background: var(--primary-50);
}

/* Drafting status */
.drafting-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-complete {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--success, #059669);
}

.status-pending {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.status-icon {
    font-size: 1.2rem;
}

/* Counter actions */
.counter-actions {
    margin-top: 24px;
}

.counter-offer-container {
    max-width: 800px;
}

/* --- Social Login Buttons --- */
.social-login-section {
    margin-bottom: 1.5rem;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--stone, #e8e5e0);
    border-radius: 8px;
    background: white;
    color: var(--ink, #1a1a1a);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    margin-bottom: 0.75rem;
}

.social-btn:hover {
    background-color: var(--ivory, #faf9f6);
    border-color: var(--warm-gray, #8a8580);
}

.social-btn-apple {
    background: #000;
    color: #fff;
    border-color: #000;
}

.social-btn-apple:hover {
    background: #1a1a1a;
}

.social-icon {
    flex-shrink: 0;
}

.social-divider {
    display: flex;
    align-items: center;
    margin: 1.25rem 0;
    color: var(--warm-gray, #8a8580);
    font-size: 0.85rem;
}

.social-divider::before,
.social-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--stone, #e8e5e0);
}

.social-divider span {
    padding: 0 1rem;
}

/* Alpine.js: hide x-cloak elements until Alpine initializes (prevents
   flash of hidden panels/forms on page load). */
[x-cloak] { display: none !important; }
