/* Sophie Dashboard — Clean, minimal styles */

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --muted: #6c757d;
    --border: #dee2e6;
    --primary: #0d6efd;
    --success: #198754;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #0dcaf0;
    --sidebar-bg: #1a1a2e;
    --sidebar-text: #e2e8f0;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header { padding: 0 1.5rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h1 { font-size: 1.5rem; font-weight: 700; }
.sidebar-header .subtitle { font-size: 0.8rem; opacity: 0.6; margin-top: 0.25rem; }

.nav-links { list-style: none; padding: 1rem 0; flex: 1; }
.nav-links li a {
    display: block;
    padding: 0.6rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.15s;
}
.nav-links li a:hover { background: rgba(255,255,255,0.08); }
.nav-links li a.active { background: rgba(255,255,255,0.12); font-weight: 600; }

.sidebar-footer { padding: 1rem 1.5rem; font-size: 0.75rem; opacity: 0.5; }
.sidebar-footer a { color: var(--sidebar-text); }

/* Main content */
.content { margin-left: 220px; flex: 1; padding: 2rem; max-width: 1200px; }
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; font-weight: 600; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}
.stat-card.highlight { border-color: var(--success); background: #f0fdf4; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.data-table th { background: var(--bg); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.data-table th, .data-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table tr:hover { background: #f8f9fa; }
.data-table.compact td { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.data-table a { color: var(--primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg);
    color: var(--text);
}
.badge-agency_enquiry { background: #dbeafe; color: #1e40af; }
.badge-axopar { background: #fef3c7; color: #92400e; }
.badge-coral { background: #d1fae5; color: #065f46; }
.badge-membership { background: #ede9fe; color: #5b21b6; }
.badge-spam { background: #fee2e2; color: #991b1b; }
.badge-sub { background: #f0f9ff; color: #0369a1; }
.badge-high, .badge-critical { background: #fee2e2; color: #991b1b; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-low { background: #d1fae5; color: #065f46; }
.badge-tier-premium { background: #fef3c7; color: #92400e; }
.badge-tier-high { background: #dbeafe; color: #1e40af; }
.badge-tier-standard { background: var(--bg); color: var(--muted); }
.badge-tier-low { background: #f3f4f6; color: #6b7280; }

/* Status */
.status {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}
.status-new { background: #dbeafe; color: #1e40af; }
.status-acknowledged { background: #e0e7ff; color: #3730a3; }
.status-quoted { background: #fef3c7; color: #92400e; }
.status-following_up { background: #fed7aa; color: #9a3412; }
.status-booked { background: #d1fae5; color: #065f46; }
.status-lost { background: #fee2e2; color: #991b1b; }
.status-closed { background: #f3f4f6; color: #6b7280; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-approved { background: #d1fae5; color: #065f46; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-active { background: #dbeafe; color: #1e40af; }
.status-waiting_customer { background: #fed7aa; color: #9a3412; }

/* Section */
.section { margin-bottom: 2rem; }
.section h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn:hover { background: var(--bg); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-approve { background: var(--success); color: white; border-color: var(--success); }
.btn-approve:hover { background: #157347; }
.btn-reject { background: var(--danger); color: white; border-color: var(--danger); }
.btn-reject:hover { background: #bb2d3b; }
.btn-won { background: #1e40af; color: white; border-color: #1e40af; font-weight: 600; }
.btn-won:hover { background: #1e3a8a; color: white; }

/* Detail views */
.detail-card { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; border: 1px solid var(--border); }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.detail-body { margin-bottom: 1.5rem; }
.email-body { white-space: pre-wrap; font-family: inherit; font-size: 0.9rem; background: var(--bg); padding: 1rem; border-radius: var(--radius); line-height: 1.5; }

/* Conversation */
.conversation { margin: 1.5rem 0; }
.message { margin-bottom: 1rem; padding: 1rem; border-radius: var(--radius); }
.message-customer { background: #f0f9ff; border-left: 3px solid var(--primary); }
.message-sophie { background: #f0fdf4; border-left: 3px solid var(--success); }
.message-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.85rem; }
.message-body { font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; }

/* Filters */
.filters { margin-bottom: 1.5rem; display: flex; gap: 0.75rem; align-items: center; }
.filters select, .filters input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: var(--surface);
}

/* Boat grid */
.boat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.boat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.boat-image { height: 160px; background: var(--bg) center/cover no-repeat; }
.boat-image.placeholder { background-color: #e2e8f0; }
.boat-info { padding: 1rem; }
.boat-info h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.boat-meta { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.boat-details { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.boat-details p { margin-bottom: 0.15rem; }
.boat-features { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.75rem; }
.feature-tag { font-size: 0.7rem; padding: 0.1rem 0.4rem; background: var(--bg); border-radius: 4px; color: var(--muted); }

/* Reports */
.reports-list { display: flex; flex-direction: column; gap: 1rem; }
.report-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.report-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.report-stats { display: flex; gap: 2rem; }
.report-stat { text-align: center; }
.report-stat .stat-value { font-size: 1.25rem; font-weight: 700; display: block; }
.report-stat .stat-label { font-size: 0.75rem; color: var(--muted); }
.report-detail { margin-top: 1rem; }

/* Suggestions */
.suggestions-list { display: flex; flex-direction: column; gap: 1rem; }
.suggestion-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.suggestion-high, .suggestion-critical { border-left: 3px solid var(--danger); }
.suggestion-medium { border-left: 3px solid var(--warning); }
.suggestion-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.suggestion-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.suggestion-card p { font-size: 0.9rem; color: var(--muted); line-height: 1.5; }
.suggestion-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }
.draft-content { white-space: pre-wrap; font-size: 0.85rem; background: var(--bg); padding: 1rem; margin-top: 0.5rem; border-radius: var(--radius); }
.impact { margin-top: 0.5rem; font-size: 0.85rem; color: var(--success); font-style: italic; }

/* Questions */
.questions-list { display: flex; flex-direction: column; gap: 1rem; }
.question-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.question-card.question-high { border-left: 3px solid var(--danger); }
.question-card.question-normal { border-left: 3px solid var(--primary); }
.question-card.question-low { border-left: 3px solid var(--border); }
.question-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; }
.question-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.question-context { font-size: 0.85rem; color: var(--muted); line-height: 1.5; margin-bottom: 0.75rem; font-style: italic; }
.question-answer-form textarea { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; font-family: inherit; resize: vertical; }
.question-answer-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15); }
.question-actions { margin-top: 0.75rem; display: flex; justify-content: space-between; align-items: center; }
.question-buttons { display: flex; gap: 0.5rem; }
.checkbox-label { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.question-answer { margin-top: 0.75rem; padding: 0.75rem; background: var(--bg); border-radius: var(--radius); font-size: 0.9rem; line-height: 1.5; }
.question-answer p { margin: 0.25rem 0; }
.badge-qcat-pricing { background: #fef3c7; color: #92400e; }
.badge-qcat-availability { background: #dbeafe; color: #1e40af; }
.badge-qcat-policy { background: #fee2e2; color: #991b1b; }
.badge-qcat-boat_info { background: #d1fae5; color: #065f46; }
.badge-qcat-general { background: var(--bg); color: var(--muted); }
.badge-kb { background: #d1fae5; color: #065f46; font-size: 0.7rem; margin-left: 0.5rem; }
.status-dismissed { background: #f3f4f6; color: #6b7280; }

/* Utilities */
.muted { color: var(--muted); font-size: 0.85rem; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }
details summary { cursor: pointer; font-size: 0.85rem; color: var(--primary); margin-top: 0.5rem; }
.quotes-section { margin-top: 1.5rem; }
.quote-card { background: var(--bg); border-radius: var(--radius); padding: 1rem; margin-bottom: 0.75rem; }

/* Edit forms */
.edit-form { max-width: 900px; }
.form-grid { display: flex; flex-direction: column; gap: 1.5rem; }
.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.form-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.3rem; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.9rem; font-family: inherit; background: var(--surface);
}
.form-group textarea { resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}
.form-group small { display: block; margin-top: 0.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; }
.image-preview { max-width: 200px; max-height: 120px; margin-top: 0.5rem; border-radius: var(--radius); border: 1px solid var(--border); }
.boat-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

/* Knowledge base */
.knowledge-list { display: flex; flex-direction: column; gap: 0.5rem; }
.knowledge-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: border-color 0.15s;
}
.knowledge-card:hover { border-color: var(--primary); }
.knowledge-card-header { display: flex; justify-content: space-between; align-items: center; }
.knowledge-card h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.knowledge-card h3 a { color: var(--text); text-decoration: none; }
.knowledge-card h3 a:hover { color: var(--primary); }
.knowledge-inactive { opacity: 0.5; }
.badge-kb-quoting { background: #fef3c7; color: #92400e; }
.badge-kb-policies { background: #fee2e2; color: #991b1b; }
.badge-kb-locations { background: #d1fae5; color: #065f46; }
.badge-kb-operations { background: #dbeafe; color: #1e40af; }
.badge-kb-brand { background: #ede9fe; color: #5b21b6; }
.badge-kb-general { background: var(--bg); color: var(--muted); }

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.chat-msg {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    line-height: 1.5;
}
.chat-msg-user {
    align-self: flex-end;
    background: #dbeafe;
    border-bottom-right-radius: 2px;
}
.chat-msg-sophie {
    align-self: flex-start;
    background: #f0fdf4;
    border-bottom-left-radius: 2px;
}
.chat-msg-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.25rem;
}
.chat-msg-body {
    font-size: 0.9rem;
    word-wrap: break-word;
}
.chat-msg-body ul { margin: 0.25rem 0 0.25rem 1.25rem; }
.chat-msg-body li { margin-bottom: 0.15rem; }
.chat-msg-body code { background: rgba(0,0,0,0.06); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.85em; }
.chat-input-area {
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    background: var(--bg);
}
.chat-input-row {
    display: flex;
    gap: 0.75rem;
}
.chat-input-row input {
    flex: 1;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface);
}
.chat-input-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}
.btn-send {
    padding: 0.65rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-send:hover { background: #0b5ed7; }
.btn-send:disabled { background: var(--muted); cursor: not-allowed; }

/* Thinking dots */
.chat-thinking {
    display: flex;
    gap: 0.3rem;
    padding: 0.25rem 0;
}
.chat-thinking .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    animation: thinking 1.4s infinite ease-in-out both;
}
.chat-thinking .dot:nth-child(1) { animation-delay: -0.32s; }
.chat-thinking .dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes thinking {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Pricing page */
.pricing-page .form-section { max-width: 900px; }
.pricing-page textarea#rate-sheet-text {
    width: 100%; max-width: 900px; font-family: monospace; font-size: 13px;
    padding: 12px; border: 1px solid #ddd; border-radius: 6px; resize: vertical;
}
.season-block {
    background: #f8fafe; border-radius: 8px; padding: 12px 16px 4px; margin-bottom: 12px;
    border-left: 3px solid #1e40af;
}
.tier-row, .dynamic-row { align-items: center; gap: 8px; margin-bottom: 4px; }
.tier-row input, .dynamic-row input { font-size: 14px; padding: 6px 8px; }
.btn-remove {
    background: none; border: none; color: #e74c3c; font-size: 20px; cursor: pointer;
    padding: 2px 8px; border-radius: 4px; line-height: 1;
}
.btn-remove:hover { background: #fde8e8; }
.btn-small {
    font-size: 13px; padding: 4px 12px; background: #eee; border: 1px solid #ddd;
    border-radius: 4px; cursor: pointer; color: #333;
}
.btn-small:hover { background: #ddd; }
.advanced-section { border: 1px solid #e0e0e0; border-radius: 8px; padding: 0; }
.advanced-section summary {
    padding: 12px 16px; cursor: pointer; user-select: none;
    list-style: none; display: flex; align-items: center; gap: 8px;
}
.advanced-section summary::before { content: '▸'; font-size: 14px; color: #666; }
.advanced-section[open] summary::before { content: '▾'; }
.advanced-section summary h3 { margin: 0; font-size: 15px; }
.advanced-section > div, .advanced-section > :not(summary) { padding: 0 16px 16px; }
.tier-header { padding: 0; margin-top: 8px; }
.col-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.col-headers { margin-bottom: 2px; }
.month-selector { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.month-chip {
    display: inline-block; padding: 4px 12px; border-radius: 16px;
    font-size: 0.8rem; font-weight: 500; cursor: pointer; user-select: none;
    background: var(--bg); border: 1px solid var(--border); color: var(--muted);
    transition: all 0.15s;
}
.month-chip:hover { border-color: var(--primary); color: var(--primary); }
.month-chip.active { background: #dbeafe; border-color: #1e40af; color: #1e40af; }
.day-selector { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.day-chip {
    display: inline-block; padding: 3px 10px; border-radius: 14px;
    font-size: 0.78rem; font-weight: 500; cursor: pointer; user-select: none;
    background: var(--bg); border: 1px solid var(--border); color: var(--muted);
    transition: all 0.15s;
}
.day-chip:hover { border-color: var(--primary); color: var(--primary); }
.day-chip.active { background: #d1fae5; border-color: #059669; color: #065f46; }
.tier-row { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.tier-row-top { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.tier-field { display: flex; flex-direction: column; gap: 4px; }
.tier-field-narrow { min-width: 100px; max-width: 140px; }
.tier-field input { padding: 6px 8px; font-size: 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.tier-inline-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.inline-label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--muted); margin-bottom: 2px; }
.labelled-row { align-items: flex-end; }

/* Pricing summary on edit page */
.pricing-summary-block { margin-bottom: 12px; }
.pricing-mini-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 0.85rem; }
.pricing-mini-table th {
    text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em;
    color: var(--muted); padding: 4px 8px; border-bottom: 1px solid var(--border);
}
.pricing-mini-table td { padding: 4px 8px; border-bottom: 1px solid #f0f0f0; }
.pricing-summary-fees { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.pricing-fee-item { display: flex; gap: 8px; font-size: 0.88rem; align-items: baseline; }
.pricing-fee-label { font-weight: 600; min-width: 120px; flex-shrink: 0; font-size: 0.82rem; color: var(--muted); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: static; }
    .content { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .boat-grid { grid-template-columns: 1fr; }
}
