/* ============================================
   MAXWELL CRM — STYLES
   ============================================ */

:root {
    --navy-900: #3a2a00;
    --navy-800: #4d3800;
    --navy-700: #614a00;
    --gold-500: #c8a45e;
    --gold-400: #d4b76a;
    --gold-600: #b08d3e;
    --cream-50: #fdfcf9;
    --white: #ffffff;
    --gray-50: #faf9f6;
    --gray-100: #f5f3ef;
    --gray-200: #e8e4dc;
    --gray-300: #d1cdc5;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #1f1a0e;
    --green-500: #22c55e;
    --green-100: #dcfce7;
    --red-500: #ef4444;
    --red-100: #fee2e2;
    --blue-500: #3b82f6;
    --blue-100: #dbeafe;
    --yellow-500: #eab308;
    --yellow-100: #fef9c3;
    --purple-500: #8b5cf6;
    --purple-100: #ede9fe;

    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, sans-serif;
    --sidebar-width: 240px;
    --transition: all 0.2s ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--gray-50);
    color: var(--gray-900);
    display: flex;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--gold-500);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    border-radius: 4px;
}

.logo-label {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--gray-900);
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--gray-500);
    font-size: 14px;
    border-radius: 6px;
    text-decoration: none;
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--gray-900);
    background: var(--gray-100);
}

.nav-item.active {
    color: var(--navy-900);
    background: linear-gradient(135deg, #fef9c3, #fef3c7);
    font-weight: 600;
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
}

.sidebar-back {
    color: var(--gray-400);
    font-size: 13px;
    text-decoration: none;
    transition: var(--transition);
}

.sidebar-back:hover { color: var(--gold-500); }

/* ============================================
   MOBILE HEADER
   ============================================ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 90;
}

.mobile-toggle {
    background: none;
    border: none;
    color: var(--gray-900);
    font-size: 24px;
    cursor: pointer;
}

.mobile-title {
    font-family: var(--font-display);
    color: var(--gray-900);
    font-size: 16px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 12px;
}

.view-header h1 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
}

.view-date {
    font-size: 14px;
    color: var(--gray-400);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    gap: 6px;
}

.btn-primary {
    background: var(--gold-500);
    color: var(--navy-900);
}

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

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover { background: var(--gray-50); }

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

.btn-danger:hover { background: #dc2626; }

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

.btn-text {
    background: none;
    border: none;
    color: var(--gold-500);
    font-size: 13px;
    cursor: pointer;
    font-family: var(--font-body);
}

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

/* ============================================
   STATS ROW
   ============================================ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--gray-100);
    text-align: center;
}

.stat-value {
    display: block;
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 700;
    color: var(--gold-500);
    margin-bottom: 4px;
}

.stat-name {
    font-size: 13px;
    color: var(--gray-400);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--gray-100);
    margin-bottom: 20px;
}

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

.card-header h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

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

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--white);
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--gold-500);
    box-shadow: 0 0 0 3px rgba(200,164,94,0.1);
}

.toolbar select {
    padding: 10px 12px;
    font-family: var(--font-body);
    font-size: 13px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--white);
    cursor: pointer;
}

/* ============================================
   DATA TABLE
   ============================================ */
.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--gray-100);
}

.data-table th {
    background: var(--gray-50);
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    text-align: left;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.data-table th:hover { color: var(--gold-500); }

.data-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-top: 1px solid var(--gray-100);
    vertical-align: middle;
}

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

/* Stage Badges */
.stage-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stage-badge.lead { background: var(--blue-100); color: var(--blue-500); }
.stage-badge.contacted { background: var(--yellow-100); color: var(--yellow-500); }
.stage-badge.viewing { background: var(--purple-100); color: var(--purple-500); }
.stage-badge.negotiation { background: #fce7f3; color: #ec4899; }
.stage-badge.closed_won { background: var(--green-100); color: var(--green-500); }
.stage-badge.closed_lost { background: var(--red-100); color: var(--red-500); }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.active { background: var(--green-500); }
.status-dot.inactive { background: var(--gray-300); }

.action-btns {
    display: flex;
    gap: 6px;
}

/* ============================================
   PIPELINE BOARD
   ============================================ */
.pipeline-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    min-height: 400px;
}

.pipeline-col {
    background: var(--gray-50);
    border-radius: 8px;
    padding: 16px;
    min-height: 300px;
}

.pipeline-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--gray-200);
}

.pipeline-col-header h4 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pipeline-col-header .count {
    background: var(--gray-200);
    color: var(--gray-700);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.pipeline-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    transition: var(--transition);
    cursor: default;
}

.pipeline-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.pipeline-card-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.pipeline-card-value {
    font-size: 13px;
    color: var(--gold-500);
    font-weight: 600;
    margin-bottom: 8px;
}

.pipeline-card-actions {
    display: flex;
    gap: 4px;
}

.pipeline-card-actions button {
    flex: 1;
    padding: 4px;
    font-size: 11px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.pipeline-card-actions button:hover {
    background: var(--gold-500);
    color: var(--white);
    border-color: var(--gold-500);
}

.pipeline-total {
    font-size: 14px;
    color: var(--gray-400);
}

/* ============================================
   PROPERTY CARDS (CRM)
   ============================================ */
.property-crm-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.property-crm-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: 8px;
    overflow: hidden;
    transition: var(--transition);
}

.property-crm-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.property-crm-header {
    background: linear-gradient(135deg, #c8a45e, #d4b76a);
    padding: 20px;
    color: var(--white);
}

.property-crm-header h4 {
    font-family: var(--font-display);
    font-size: 16px;
    margin-bottom: 4px;
}

.property-crm-header span {
    font-size: 12px;
    opacity: 0.6;
    text-transform: uppercase;
}

.property-crm-body {
    padding: 16px 20px;
}

.property-crm-detail {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
}

.property-crm-detail:last-child { border: none; }

.property-crm-detail span:first-child { color: var(--gray-400); }
.property-crm-detail span:last-child { font-weight: 600; }

.property-crm-actions {
    padding: 12px 20px;
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--gray-100);
}

/* ============================================
   TIMELINE
   ============================================ */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-dot {
    position: absolute;
    left: -28px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gold-500);
    border: 2px solid var(--white);
    box-shadow: 0 0 0 2px var(--gold-500);
}

.timeline-content {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: 8px;
    padding: 16px;
}

.timeline-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--gray-400);
}

.timeline-type {
    background: linear-gradient(135deg, #c8a45e, #d4b76a);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
}

.timeline-desc {
    font-size: 14px;
    line-height: 1.6;
}

.timeline-contact {
    font-weight: 600;
    color: var(--gold-500);
}

/* ============================================
   ANALYTICS
   ============================================ */
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.chart-container {
    min-height: 200px;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    height: 180px;
    padding-top: 20px;
}

.bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    height: 100%;
    justify-content: flex-end;
}

.bar {
    width: 100%;
    max-width: 48px;
    background: var(--gold-500);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: all 0.5s ease;
    position: relative;
}

.bar:hover { background: var(--gold-400); }

.bar-value {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-700);
}

.bar-label {
    font-size: 11px;
    color: var(--gray-400);
    text-align: center;
    word-break: break-word;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

.metric-row:last-child { border: none; }
.metric-row span:last-child { font-weight: 700; color: var(--gold-500); }

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
}

.modal-overlay.open { display: block; }

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--white);
    border-radius: 12px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 201;
    padding: 24px;
}

.modal.open { display: block; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 20px;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--gray-100);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover { background: var(--gray-200); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    font-family: var(--font-body);
    font-size: 14px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--white);
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--gold-500);
    box-shadow: 0 0 0 3px rgba(200,164,94,0.1);
}

.form-group textarea { resize: vertical; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-100);
}

/* ============================================
   SETTINGS
   ============================================ */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.import-export-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stages-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stage-item {
    font-size: 14px;
    color: var(--gray-500);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    color: var(--gray-400);
    padding: 32px 16px;
    font-size: 14px;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--white);
    color: var(--gray-900);
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 300;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border: 1px solid var(--gray-200);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success { border-left: 4px solid var(--green-500); }
.toast.error { border-left: 4px solid var(--red-500); }

/* ============================================
   CALENDAR & SYNC
   ============================================ */
.calendar-sync-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-500);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-300);
}

.sync-dot.connected { background: var(--green-500); }

.sync-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-google {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-google:hover { background: var(--gray-50); border-color: #4285f4; }
.btn-google.connected { border-color: var(--green-500); color: var(--green-500); }

.btn-outlook {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-outlook:hover { background: var(--gray-50); border-color: #0078d4; }
.btn-outlook.connected { border-color: var(--green-500); color: var(--green-500); }

.calendar-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.calendar-mini {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: 8px;
    padding: 20px;
}

.calendar-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.calendar-nav-header h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.cal-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    padding: 8px 0;
}

.cal-day {
    padding: 8px 4px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.cal-day:hover { background: var(--gray-100); }
.cal-day.today { background: linear-gradient(135deg, #fef9c3, #fef3c7); font-weight: 700; }
.cal-day.selected { background: var(--gold-500); color: var(--white); font-weight: 600; }
.cal-day.other-month { color: var(--gray-300); }
.cal-day.has-appointments::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--gold-500);
}
.cal-day.selected.has-appointments::after { background: var(--white); }

.calendar-day-view {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: 8px;
    padding: 20px;
}

.calendar-day-view h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.appointment-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--gray-100);
    border-radius: 6px;
    margin-bottom: 8px;
    align-items: flex-start;
    transition: var(--transition);
}

.appointment-item:hover {
    border-color: var(--gold-500);
    box-shadow: 0 2px 8px rgba(200,164,94,0.1);
}

.appt-time {
    font-size: 13px;
    font-weight: 600;
    color: var(--gold-500);
    white-space: nowrap;
    min-width: 60px;
}

.appt-details {
    flex: 1;
}

.appt-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.appt-meta {
    font-size: 12px;
    color: var(--gray-400);
}

.appt-type-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
    text-transform: uppercase;
    background: var(--yellow-100);
    color: var(--gold-500);
}

.appt-actions {
    display: flex;
    gap: 4px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .pipeline-board {
        grid-template-columns: repeat(3, 1fr);
    }

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

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

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

    .mobile-header {
        display: flex;
    }

    .main-content {
        margin-left: 0;
        padding: 72px 16px 16px;
    }

    .pipeline-board {
        grid-template-columns: 1fr;
    }

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

    .dashboard-grid,
    .analytics-grid,
    .settings-grid,
    .calendar-layout {
        grid-template-columns: 1fr;
    }

    .property-crm-grid {
        grid-template-columns: 1fr;
    }

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