/* ---- RESET & TOKENS ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-deep: #0c0f1a;
    --bg-card: #141829;
    --bg-hover: #1a1f36;
    --bg-surface: #10132a;
    --amber: #f0a830;
    --amber-soft: #f0a83033;
    --amber-glow: #f0a83018;
    --green: #34d399;
    --green-soft: #34d39920;
    --red: #f87171;
    --red-soft: #f8717120;
    --text-primary: #f0ece4;
    --text-secondary: #8b8fa3;
    --text-muted: #5a5e72;
    --border: #1e2340;
    --border-focus: #f0a83066;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
}

/* ---- APP SHELL ---- */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
}

.sidebar-header {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    text-decoration: none;
}

.logo span { color: var(--amber); }

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--amber-soft);
    color: var(--amber);
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--green);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--green);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---- MAIN CONTENT ---- */
.main-content {
    overflow-y: auto;
    padding: 2rem 2.5rem;
}

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

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.view-header h1 {
    font-size: 1.8rem;
    letter-spacing: -0.5px;
}

.view-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* ---- STATS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: border-color var(--transition);
}

.stat-card:hover {
    border-color: var(--amber-soft);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--amber);
    letter-spacing: -1px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* ---- SECTION HEADER ---- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.2rem;
    letter-spacing: -0.3px;
}

/* ---- CONVERSATIONS LIST ---- */
.conversations-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.conversation-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all var(--transition);
}

.conversation-card:hover {
    border-color: var(--amber-soft);
    background: var(--bg-hover);
}

.conv-avatar {
    width: 40px;
    height: 40px;
    background: var(--amber-soft);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--amber);
    font-size: 0.9rem;
    flex-shrink: 0;
}

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

.conv-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.conv-preview {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

.conv-meta {
    text-align: right;
    flex-shrink: 0;
}

.conv-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.conv-property-tag {
    font-size: 0.7rem;
    color: var(--amber);
    background: var(--amber-soft);
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    margin-top: 0.25rem;
    display: inline-block;
}

.conv-status {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 100px;
    margin-top: 0.25rem;
}

.conv-status.active { color: var(--green); background: var(--green-soft); }
.conv-status.resolved { color: var(--text-muted); background: var(--bg-hover); }

/* ---- CONVERSATIONS SPLIT VIEW ---- */
.conversations-container {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 0;
    height: calc(100vh - 140px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.conversations-sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.filter-bar {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conv-list-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
}

.conv-list-item:hover { background: var(--bg-hover); }
.conv-list-item.active { background: var(--amber-glow); border-left: 3px solid var(--amber); }

.conv-list-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.conv-list-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-list-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.4rem;
}

/* ---- CHAT PANEL ---- */
.chat-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-deep);
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 0.75rem;
}

.chat-empty-icon { font-size: 3rem; opacity: 0.3; }

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info h3 {
    font-size: 1rem;
    letter-spacing: -0.3px;
}

.chat-header-info span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 75%;
    padding: 0.875rem 1.1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.6;
    position: relative;
}

.message.guest {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message.ai {
    align-self: flex-end;
    background: var(--amber-soft);
    border: 1px solid var(--amber-glow);
    border-bottom-right-radius: 4px;
}

.message.host {
    align-self: flex-end;
    background: #1a3a5c;
    border: 1px solid #1a4a7c;
    border-bottom-right-radius: 4px;
}

.message-role {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.message.ai .message-role { color: var(--amber); }
.message.host .message-role { color: #60a5fa; }

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.chat-input-bar {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    gap: 0.75rem;
}

.chat-input {
    flex: 1;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition);
    resize: none;
    min-height: 42px;
    max-height: 120px;
}

.chat-input:focus { border-color: var(--border-focus); }

.chat-input::placeholder { color: var(--text-muted); }

/* ---- PROPERTIES GRID ---- */
.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.property-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all var(--transition);
    cursor: pointer;
}

.property-card:hover {
    border-color: var(--amber-soft);
    transform: translateY(-2px);
}

.property-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.property-card h3 {
    font-size: 1.1rem;
    letter-spacing: -0.3px;
}

.property-card-badge {
    font-size: 0.7rem;
    color: var(--amber);
    background: var(--amber-soft);
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
}

.property-card-detail {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.property-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ---- BUTTONS ---- */
.btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary {
    background: var(--amber);
    color: var(--bg-deep);
}

.btn-primary:hover { background: #e09820; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.btn-danger {
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red-soft);
}

.btn-danger:hover { background: var(--red-soft); }

.btn-send {
    background: var(--amber);
    color: var(--bg-deep);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition);
}

.btn-send:hover { background: #e09820; }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- FORMS ---- */
.form-input, .select-input {
    width: 100%;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition);
}

.form-input:focus, .select-input:focus {
    border-color: var(--border-focus);
}

.form-input::placeholder { color: var(--text-muted); }

textarea.form-input { resize: vertical; min-height: 60px; }

.select-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a5e72' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
    cursor: pointer;
}

select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

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

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.form-section h4 {
    font-size: 0.9rem;
    color: var(--amber);
    margin-bottom: 1rem;
    letter-spacing: -0.2px;
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ---- MODAL ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.75rem;
}

.modal-wide {
    max-width: 640px;
}

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

.modal-header h3 {
    font-size: 1.15rem;
    letter-spacing: -0.3px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---- LOADING ---- */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ---- TOAST ---- */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    z-index: 2000;
    animation: slideUp 0.3s ease, fadeOut 0.3s ease 2.7s;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast.error { border-color: var(--red); }
.toast.success { border-color: var(--green); }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        padding: 1.5rem;
    }

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

    .conversations-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .conversations-sidebar {
        max-height: 300px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

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