/* ==========================================================================
   Chez Papa & Maman — Styles
   ========================================================================== */

:root {
    --bg: #FFF8F0;
    --bg-card: #FFFFFF;
    --text: #3D3D3D;
    --text-light: #777;
    --border: #E8E0D8;
    --primary: #E07A5F;
    --primary-hover: #C96A52;
    --danger: #D64545;
    --success: #4CAF50;
    --radius: 10px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding-bottom: 80px;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}
.logo:hover { text-decoration: none; }
.user-badge {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

/* Content */
.content {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

/* Flash messages */
.flash-messages { margin-bottom: 16px; }
.flash {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 8px;
}
.flash-error { background: #FDECEA; color: var(--danger); }
.flash-success { background: #E8F5E9; color: #2E7D32; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-align: center;
    min-height: 44px;
    line-height: 24px;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #D8D0C8; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B93B3B; text-decoration: none; }
.btn-small { padding: 6px 14px; font-size: 0.85rem; min-height: 36px; }
.btn-full { width: 100%; }
.btn-add { margin-bottom: 16px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    background: var(--bg-card);
    min-height: 44px;
}
.form-group textarea { resize: vertical; }
.form-group small { color: var(--text-light); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* Toggle switch */
.toggle-group { margin-top: 8px; }
.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 10px 0;
}
.toggle-text { font-size: 1rem; }
.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 28px;
    transition: 0.2s;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 22px; width: 22px;
    left: 3px; bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 32px 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 380px;
}
.login-title {
    font-size: 1.5rem;
    text-align: center;
    color: var(--primary);
    margin-bottom: 4px;
}
.login-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* Page titles */
.page-title {
    font-size: 1.3rem;
    margin-bottom: 16px;
}

/* ==========================================================================
   Monthly Calendar
   ========================================================================== */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 12px;
}
.month-title { font-size: 1.2rem; }
.nav-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 1.2rem;
    color: var(--text);
}
.nav-arrow:hover { background: var(--border); text-decoration: none; }
.calendar-actions { text-align: center; margin-bottom: 12px; }

.month-grid {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.month-grid th {
    padding: 6px 2px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-light);
    text-align: center;
}
.day-cell {
    border: 1px solid var(--border);
    vertical-align: top;
    padding: 4px;
    min-height: 60px;
    height: auto;
    background: var(--bg-card);
}
.day-cell.empty { background: transparent; border-color: transparent; }
.day-cell.today { background: #FFF3E0; }
.day-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 2px;
}
.day-pills { display: flex; flex-wrap: wrap; gap: 2px; }
.pill {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    padding: 1px 4px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    cursor: default;
    line-height: 1.4;
}
.calendar-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 10px;
}

.day-cell[data-date] { cursor: pointer; }
.day-cell[data-date]:hover { background: #FFF3E0; }
.day-cell.selected-start,
.day-cell.selected-end { background: #FCD8C9; box-shadow: inset 0 0 0 2px var(--primary); }
.day-cell.selected-range { background: #FDE7DD; }

/* Booking modal */
body.modal-open { overflow: hidden; }
.booking-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.booking-modal[hidden] { display: none; }
.booking-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}
.booking-modal-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    max-height: 90vh;
    overflow-y: auto;
}
.booking-modal-card h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
}
.booking-modal-dates {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 14px;
}
@media (min-width: 600px) {
    .booking-modal { align-items: center; }
    .booking-modal-card { border-radius: var(--radius); }
}

/* ==========================================================================
   Year View
   ========================================================================== */
.year-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.mini-month {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 10px;
    box-shadow: var(--shadow);
}
.mini-month-title {
    font-size: 0.9rem;
    margin-bottom: 6px;
    text-align: center;
}
.mini-month-title a { color: var(--text); }
.mini-month-title a:hover { color: var(--primary); }
.mini-month-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.mini-month-table th {
    font-size: 0.6rem;
    color: var(--text-light);
    padding: 2px 0;
    text-align: center;
}
.mini-day {
    text-align: center;
    padding: 2px;
    font-size: 0.65rem;
    color: var(--text-light);
    height: 22px;
    vertical-align: middle;
}
.mini-day.empty { visibility: hidden; }
.mini-today { background: #FFF3E0; border-radius: 3px; }
.mini-day-num { display: inline-block; }
.mini-day-link { text-decoration: none; }
.mini-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
}

/* ==========================================================================
   List View
   ========================================================================== */
.month-heading {
    font-size: 1rem;
    color: var(--text-light);
    margin: 20px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.subgroup-heading {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin: 12px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   Gantt monthly list
   ========================================================================== */
.month-block { margin-bottom: 24px; }
.gantt-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    font-size: 0.7rem;
    color: var(--text-light);
    text-align: center;
    margin-bottom: 4px;
}
.gantt-weekdays .we { color: var(--primary); font-weight: 700; }
.gantt-week { margin-bottom: 6px; }
.gantt-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.gantt-day {
    background: var(--bg-card);
    text-align: center;
    font-size: 0.75rem;
    padding: 4px 0;
    border-radius: 4px;
    color: var(--text);
    min-height: 22px;
}
.gantt-day.weekend { background: #FFF3E0; }
.gantt-day.today { box-shadow: inset 0 0 0 2px var(--primary); font-weight: 700; }
.gantt-day.dim { opacity: 0.25; }
.gantt-bars {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-top: 2px;
}
.gantt-bar {
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 4px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
    min-height: 20px;
}
.visit-cards { display: flex; flex-direction: column; gap: 8px; }
.visit-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
}
.visit-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.household-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
}
.visit-card-dates {
    font-size: 0.9rem;
    font-weight: 500;
}
.visit-card-notes {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ==========================================================================
   My Visits
   ========================================================================== */
.my-visits-list { display: flex; flex-direction: column; gap: 8px; }
.my-visit-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.my-visit-dates { font-weight: 600; font-size: 0.95rem; }
.my-visit-meta { font-size: 0.85rem; color: var(--text-light); margin-top: 2px; }
.visit-notes-preview { font-style: italic; }
.my-visit-actions { display: flex; gap: 6px; flex-shrink: 0; }
.inline-form { display: inline; }

/* Visit form */
.visit-form {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-light);
    font-size: 1rem;
}

/* ==========================================================================
   Bottom Navigation
   ========================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 100;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 12px;
    min-width: 60px;
    min-height: 44px;
    color: var(--text-light);
    font-size: 0.7rem;
    border-radius: 8px;
}
.nav-item:hover { text-decoration: none; color: var(--text); }
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 1.2rem; line-height: 1; }
.nav-label { margin-top: 2px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (min-width: 768px) {
    .content { padding: 24px; }
    .day-cell { min-height: 80px; height: auto; padding: 6px; }
    .pill { font-size: 0.7rem; padding: 2px 6px; }
    .day-number { font-size: 0.85rem; }
    .year-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
    .year-grid { grid-template-columns: repeat(4, 1fr); }
}
