/* BAVI Home v3.0 - Dark Grey, Light Grey, Lilac */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3d3d3d;
    --text-bright: #ffffff;
    --text-primary: #e5e5e5;
    --text-secondary: #a0a0a0;
    --accent-primary: #b8a9c9;
    --accent-secondary: #9d8bb8;
    --border-color: #404040;
    --success: #6d9a7d;
    --error: #c97070;
    --shadow: rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { 
    height: 100%; 
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Splash Screen */
.splash-screen {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--bg-primary);
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.5s, visibility 0.5s;
}
.splash-screen img { max-width: 70%; max-height: 60%; object-fit: contain; }
.splash-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

/* App Container */
.app-container {
    display: flex; flex-direction: column; height: 100%;
    opacity: 0; transition: opacity 0.5s;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}
.app-container.visible { opacity: 1; }

/* Navigation */
.top-nav {
    display: flex; justify-content: space-around;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
}
.nav-tab {
    padding: 10px 20px; cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.nav-tab.active { color: var(--accent-primary); }
.nav-tab i { width: 24px; height: 24px; }

/* Content Area */
.content-area { flex: 1; overflow: hidden; position: relative; }
.panel {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.panel.active { opacity: 1; pointer-events: auto; }

/* Panel Header */
.panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}
.panel-header h2 {
    font-size: 20px; font-weight: 600;
    color: var(--text-bright);
    display: flex; align-items: center; gap: 12px;
}
.panel-header-actions { display: flex; align-items: center; gap: 12px; }
.panel-header-icon { cursor: pointer; color: var(--accent-primary); }
.panel-header-icon i { width: 22px; height: 22px; }

.back-btn { display: none; cursor: pointer; color: var(--text-secondary); }
.back-btn.visible { display: inline-flex; }

/* View Toggle */
.view-toggle { display: flex; background: var(--bg-tertiary); border-radius: 8px; padding: 2px; }
.view-toggle-btn {
    padding: 6px 12px; border: none; background: transparent;
    color: var(--text-secondary); font-size: 13px; cursor: pointer;
    border-radius: 6px; transition: all 0.2s; font-family: inherit;
}
.view-toggle-btn.active { background: var(--accent-primary); color: var(--bg-primary); }

/* Chat Panel */
.chat-scroll-area {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.msg {
    max-width: 85%; padding: 12px 16px;
    border-radius: 16px; font-size: 14px; line-height: 1.5;
    word-wrap: break-word;
}
.msg-user {
    align-self: flex-end;
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-bottom-right-radius: 4px;
}
.msg-ai {
    align-self: flex-start;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.msg-success {
    align-self: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-bottom-left-radius: 4px;
    padding: 12px;
}
.msg-success img { width: 100%; max-width: 200px; border-radius: 8px; margin-bottom: 10px; }
.msg-success strong { display: block; color: var(--text-bright); font-size: 15px; }
.msg-desc { color: var(--text-secondary); font-size: 13px; margin: 6px 0; }
.msg-meta { margin-top: 8px; }
.msg-meta .category {
    background: var(--accent-primary); color: var(--bg-primary);
    padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 500;
}
.msg .tag {
    display: inline-block; background: var(--bg-tertiary);
    padding: 2px 8px; border-radius: 4px; font-size: 11px;
    margin: 4px 4px 0 0; color: var(--text-secondary);
}

/* Message action buttons */
.msg-actions { display: flex; gap: 8px; margin-top: 10px; }
.edit-item-btn, .delete-item-btn {
    padding: 8px 16px; background: var(--bg-tertiary);
    border: 1px solid var(--border-color); border-radius: 8px;
    color: var(--text-primary); font-size: 13px; cursor: pointer;
    transition: all 0.2s; font-family: inherit;
}
.edit-item-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.delete-item-btn { border-color: var(--error); color: var(--error); }
.delete-item-btn:hover { background: var(--error); color: white; }

.saved-indicator {
    display: none; font-size: 12px; color: var(--success);
    margin-top: 8px; padding: 4px 8px;
    background: rgba(109, 154, 125, 0.15);
    border-radius: 6px; width: fit-content;
}
.saved-indicator.show { display: block; }

.msg.deleted { opacity: 0.6; background: var(--bg-tertiary); }
.msg-deleted { color: var(--text-secondary); font-style: italic; }

/* Chat Input */
.chat-input-container {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.staged-preview {
    display: none; gap: 8px; margin-bottom: 12px;
    padding: 8px; background: var(--bg-secondary);
    border-radius: 12px; overflow-x: auto;
}
.staged-preview.active { display: flex; }
.staged-item { position: relative; flex-shrink: 0; }
.staged-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; }
.staged-item-remove {
    position: absolute; top: -6px; right: -6px;
    width: 20px; height: 20px; background: var(--error);
    border-radius: 50%; color: white; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.clear-staged { display: flex; align-items: center; padding: 0 8px; cursor: pointer; color: var(--text-secondary); }
.chat-input-bar { display: flex; align-items: flex-end; gap: 8px; }
.input-actions { display: flex; gap: 4px; }
.circle-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--bg-secondary); border: none;
    color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.circle-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.circle-btn i { width: 20px; height: 20px; }
.send-btn { background: var(--accent-primary); color: var(--bg-primary); }
.send-btn:hover { background: var(--accent-secondary); }
.input-wrapper { flex: 1; }
.input-field {
    width: 100%; background: var(--bg-secondary);
    border: 1px solid var(--border-color); border-radius: 20px;
    padding: 10px 16px; color: var(--text-primary);
    font-size: 14px; resize: none; max-height: 120px;
    font-family: inherit;
}
.input-field::placeholder { color: var(--text-secondary); }
.input-field:focus { outline: none; border-color: var(--accent-primary); }

/* Inventory List */
.inv-list { flex: 1; overflow-y: auto; padding: 16px; }
.inv-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; background: var(--bg-secondary);
    border-radius: 12px; margin-bottom: 10px;
    cursor: pointer; transition: transform 0.1s;
    position: relative;
}
.inv-item:active { transform: scale(0.98); }
.inv-item.selected { background: var(--accent-primary); }
.inv-item.selected .inv-name { color: var(--bg-primary); }
.inv-item.selected .inv-cat, .inv-item.selected .inv-tag { color: var(--bg-secondary); }
.selection-check {
    display: none; width: 22px; height: 22px;
    border: 2px solid var(--text-secondary); border-radius: 6px;
    flex-shrink: 0;
}
.selection-mode .selection-check { display: block; }
.inv-item.selected .selection-check {
    background: var(--bg-primary); border-color: var(--bg-primary);
}
.inv-item.selected .selection-check::after {
    content: '✓'; display: flex; align-items: center;
    justify-content: center; color: var(--accent-primary);
    font-size: 14px; font-weight: bold;
}
.inv-thumb {
    width: 56px; height: 56px; border-radius: 8px;
    background-size: cover; background-position: center;
    background-color: var(--bg-tertiary); flex-shrink: 0;
}
.inv-info { flex: 1; min-width: 0; }
.inv-name {
    font-weight: 500; color: var(--text-bright);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inv-cat { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.inv-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.inv-tag {
    font-size: 10px; padding: 2px 6px;
    background: var(--bg-tertiary); border-radius: 4px;
    color: var(--text-secondary);
}

/* Photo Grid */
.photo-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 3px; padding: 3px;
}
.grid-cell {
    aspect-ratio: 1; position: relative;
    cursor: pointer; overflow: hidden;
    background: var(--bg-tertiary);
}
.grid-cell img { width: 100%; height: 100%; object-fit: cover; }
.grid-overlay {
    position: absolute; inset: 0;
    background: rgba(184, 169, 201, 0.5);
    display: none; align-items: center; justify-content: center;
    color: white;
}
.grid-cell.selected .grid-overlay { display: flex; }

/* Bulk Actions */
.bulk-actions {
    display: none; padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    align-items: center; gap: 10px;
}
.bulk-actions.active { display: flex; }
.bulk-btn {
    padding: 8px 14px; border: none;
    background: var(--bg-tertiary); color: var(--text-primary);
    border-radius: 8px; font-size: 13px; cursor: pointer;
    font-family: inherit;
}
.bulk-btn.danger { background: var(--error); color: white; }

/* Notes */
.notes-tabs {
    display: flex; padding: 0 16px; gap: 8px;
    border-bottom: 1px solid var(--border-color);
}
.notes-tab {
    padding: 12px 16px; border: none; background: none;
    color: var(--text-secondary); font-size: 14px; cursor: pointer;
    border-bottom: 2px solid transparent; font-family: inherit;
}
.notes-tab.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); }
#notesList { flex: 1; overflow-y: auto; padding: 16px; }
.note-card {
    background: var(--bg-secondary); border-radius: 12px;
    padding: 16px; margin-bottom: 12px; cursor: pointer;
}
.note-card h3 { color: var(--text-bright); font-size: 16px; margin-bottom: 8px; }
.note-card-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-secondary); }
.note-card.archived { opacity: 0.6; }

/* Note Editor */
.note-editor {
    position: fixed; inset: 0; z-index: 100;
    background: var(--bg-primary); padding: 16px;
    display: none; flex-direction: column;
    padding-top: calc(16px + env(safe-area-inset-top));
}
.note-editor.active { display: flex; }
.note-editor-header {
    display: flex; justify-content: space-between;
    margin-bottom: 20px;
}
.note-editor-header .cancel { color: var(--text-secondary); cursor: pointer; }
.note-editor-header .save { color: var(--accent-primary); cursor: pointer; font-weight: 600; }
.note-title-input {
    width: 100%; background: transparent; border: none;
    color: var(--text-bright); font-size: 24px; font-weight: 600;
    margin-bottom: 12px; font-family: inherit;
}
.note-title-input:focus { outline: none; }
.note-desc-input {
    width: 100%; background: transparent; border: none;
    color: var(--text-secondary); font-size: 14px;
    margin-bottom: 20px; font-family: inherit;
}
.note-desc-input:focus { outline: none; }
.note-checklist { flex: 1; overflow-y: auto; }
.checklist-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border-color);
}
.check-box {
    width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.check-box.checked {
    background: var(--accent-primary); border-color: var(--accent-primary);
}
.check-box.checked::after { content: '✓'; color: var(--bg-primary); font-size: 12px; }
.checklist-item-content { flex: 1; }
.checklist-input {
    width: 100%; background: transparent; border: none;
    color: var(--text-primary); font-size: 15px; font-family: inherit;
}
.checklist-input:focus { outline: none; }
.checklist-input.checked { text-decoration: line-through; color: var(--text-secondary); }
.add-checklist-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 0; color: var(--accent-primary); cursor: pointer;
}

/* Settings */
.settings-section {
    margin: 16px; background: var(--bg-secondary);
    border-radius: 12px; overflow: hidden;
}
.settings-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px; cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}
.settings-item:last-child { border-bottom: none; }
.settings-item-info { display: flex; align-items: center; gap: 12px; }
.settings-item-info i { width: 20px; height: 20px; color: var(--text-secondary); }
.settings-item-label { color: var(--text-primary); }
.settings-item-value { color: var(--text-secondary); display: flex; align-items: center; }
.settings-item-value i { width: 16px; height: 16px; }

/* Trash */
.trash-item {
    background: var(--bg-secondary); border-radius: 12px;
    padding: 16px; margin-bottom: 12px;
}
.trash-item-header {
    display: flex; justify-content: space-between;
    margin-bottom: 12px;
}
.trash-item-name { color: var(--text-bright); font-weight: 500; }
.trash-item-days { color: var(--error); font-size: 12px; }
.trash-item-actions { display: flex; gap: 8px; }
.trash-btn {
    padding: 8px 16px; border: none; border-radius: 8px;
    font-size: 13px; cursor: pointer; font-family: inherit;
}
.trash-btn-restore { background: var(--accent-primary); color: var(--bg-primary); }
.trash-btn-delete { background: var(--error); color: white; }

/* History */
.history-item {
    padding: 12px 16px; border-bottom: 1px solid var(--border-color);
}
.history-item-header { display: flex; justify-content: space-between; }
.history-action { color: var(--text-primary); }
.history-time { color: var(--text-secondary); font-size: 12px; }

/* Modals */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0, 0, 0, 0.8);
    display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: var(--bg-secondary); border-radius: 20px 20px 0 0;
    width: 100%; max-height: 90vh; overflow-y: auto;
    padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
}
.modal-close { cursor: pointer; color: var(--text-secondary); }
.modal-image { width: 100%; max-height: 300px; object-fit: contain; border-radius: 12px; margin-bottom: 16px; }
.modal-title { color: var(--text-bright); font-size: 22px; margin-bottom: 8px; }
.modal-desc { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }
.modal-section { margin-top: 16px; }
.modal-section-title { color: var(--text-secondary); font-size: 12px; margin-bottom: 6px; text-transform: uppercase; }
.modal-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.modal-tag {
    padding: 6px 12px; background: var(--bg-tertiary);
    border-radius: 6px; font-size: 13px; color: var(--text-primary);
}
.modal-tag.category { background: var(--accent-primary); color: var(--bg-primary); }
.modal-actions { display: flex; gap: 12px; margin-top: 24px; }
.modal-btn {
    flex: 1; padding: 14px; border: none; border-radius: 12px;
    font-size: 15px; font-weight: 500; cursor: pointer;
    font-family: inherit;
}
.modal-btn-primary { background: var(--accent-primary); color: var(--bg-primary); }
.modal-btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); }
.modal-btn-danger { background: var(--error); color: white; }

/* Edit Fields */
.edit-field { margin-bottom: 16px; }
.edit-label { display: block; color: var(--text-secondary); font-size: 12px; margin-bottom: 6px; text-transform: uppercase; }
.edit-input {
    width: 100%; padding: 12px; background: var(--bg-primary);
    border: 1px solid var(--border-color); border-radius: 8px;
    color: var(--text-primary); font-size: 15px; font-family: inherit;
}
.edit-input:focus { outline: none; border-color: var(--accent-primary); }
.edit-textarea { min-height: 80px; resize: vertical; }

/* Inline Edit */
.inline-edit-form { padding: 12px 0; }
.inline-edit-form .edit-field { margin-bottom: 12px; }
.inline-edit-form .edit-input { background: var(--bg-tertiary); font-size: 14px; }
.inline-edit-actions { display: flex; gap: 10px; margin-top: 16px; }
.inline-edit-cancel, .inline-edit-save {
    flex: 1; padding: 10px; border-radius: 8px; border: none;
    font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.inline-edit-cancel { background: var(--bg-tertiary); color: var(--text-secondary); }
.inline-edit-save { background: var(--accent-primary); color: var(--bg-primary); }

/* Autocomplete */
.autocomplete-wrapper { position: relative; }
.autocomplete-dropdown {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: 8px; max-height: 200px; overflow-y: auto;
    z-index: 100; margin-top: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.autocomplete-dropdown.active { display: block; }
.autocomplete-item {
    padding: 10px 12px; cursor: pointer;
    border-bottom: 1px solid var(--border-color); font-size: 14px;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg-tertiary); }
.autocomplete-hint { color: var(--text-secondary); font-style: italic; cursor: default; }
.autocomplete-hint:hover { background: transparent; }
