/* FamilyYumYum — Mobile-first styles */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f5f5f5;
    --card: #ffffff;
    --primary: #4a90d9;
    --primary-dark: #357abd;
    --danger: #d9534f;
    --text: #333;
    --text-muted: #888;
    --border: #e0e0e0;
    --success: #5cb85c;
    --at-home: #f0ad4e;
    --radius: 8px;
}

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

/* ── Nav ───────────────────────────────────────────────────────────── */
.nav {
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    text-decoration: none;
}
.nav-links { display: flex; gap: 0.5rem; }
.nav-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.nav-links a.active, .nav-links a:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* ── Main ──────────────────────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ── Login ─────────────────────────────────────────────────────────── */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 2rem;
}
.login-container h1 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--primary);
}
.login-container form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 300px;
}
.login-container input {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}
.error { color: var(--danger); margin-bottom: 0.5rem; }
.success { color: var(--success); margin-bottom: 0.5rem; }

/* ── Buttons ───────────────────────────────────────────────────────── */
button, .btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
}
button:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c9302c; }

/* ── Chat ──────────────────────────────────────────────────────────── */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 44px);
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.chat-msg {
    max-width: 85%;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.chat-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
    align-self: flex-start;
    background: var(--card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-msg.tool-status {
    align-self: center;
    background: #e8f4e8;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
}
.chat-input {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--card);
    border-top: 1px solid var(--border);
}
.chat-input input {
    flex: 1;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}
.chat-input button { flex-shrink: 0; }

/* ── Shopping List ─────────────────────────────────────────────────── */
.list-container { padding: 1rem; }
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.list-header h2 { font-size: 1.2rem; }
.list-actions { display: flex; gap: 0.5rem; align-items: center; }
.list-actions select {
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.category-header {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary);
    padding: 0.5rem 0 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-top: 0.5rem;
}
.item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
}
.item.bought .item-name { text-decoration: line-through; color: var(--text-muted); }
.item.at_home .item-name { color: var(--at-home); }
.item-name { flex: 1; }
.item-qty {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.item-recipe {
    font-size: 0.75rem;
    color: var(--primary);
    background: #e8f0fe;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}
.status-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    padding: 0.2rem;
    cursor: pointer;
    color: var(--text);
}
.status-btn:hover { background: none; color: var(--primary); }
.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}
.delete-btn:hover { background: none; color: var(--danger); }
.add-item-row {
    border-bottom: none;
    padding: 0.3rem 0;
}
.add-icon {
    color: var(--text-muted);
    font-size: 1.3rem;
    padding: 0.2rem 0.35rem;
    line-height: 1;
}
.add-item-input {
    flex: 1;
    border: none;
    border-bottom: 1px dashed var(--border);
    padding: 0.3rem 0.2rem;
    font-size: 0.95rem;
    background: transparent;
    outline: none;
    font-family: inherit;
}
.add-item-input:focus {
    border-bottom-color: var(--primary);
}
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem;
}

/* ── Notes ─────────────────────────────────────────────────────────── */
.notes-container { padding: 1rem; }
.notes-container h2 { margin-bottom: 0.5rem; }
.notes-hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.notes-container textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 0.75rem;
}
.notes-container button { width: 100%; }

/* ── Categories management ─────────────────────────────────────────── */
.categories-container { padding: 1rem; }
.categories-container h2 { margin-bottom: 1rem; }
.cat-list { list-style: none; }
.cat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    background: var(--card);
    cursor: grab;
}
.cat-item:active { cursor: grabbing; }
.cat-item.dragging { opacity: 0.4; }
.cat-drag-handle { color: var(--text-muted); cursor: grab; }
.cat-name { flex: 1; }
.cat-name input {
    width: 100%;
    border: 1px solid transparent;
    padding: 0.3rem;
    border-radius: 4px;
    font-size: 0.95rem;
}
.cat-name input:focus { border-color: var(--primary); outline: none; }
.cat-actions { display: flex; gap: 0.25rem; }
.add-cat-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}
.add-cat-form input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ── Upload ────────────────────────────────────────────────────────── */
.upload-container { padding: 1rem; }
.upload-container h2 { margin-bottom: 0.5rem; }
.upload-hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1rem;
    cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: #f0f6ff;
}
.upload-list { margin-top: 1rem; }
.upload-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
}
.upload-status { font-size: 0.85rem; color: var(--text-muted); }
.upload-status.done { color: var(--success); }
.upload-status.error { color: var(--danger); }

.profile-section { margin-top: 2rem; }
.profile-section h3 { margin-bottom: 0.25rem; }
.profile-text {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 0.5rem;
    white-space: pre-wrap;
    line-height: 1.5;
    font-size: 0.95rem;
}
