/* Mateo Baby Tracker — Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,700&family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;1,9..144,400&display=swap');

:root {
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-display: 'Fraunces', Georgia, serif;
    --sage: #5B7A5E;
    --sage-light: #E8F0E8;
    --sage-dark: #3A5A3D;
    --sand: #F5F0E8;
    --sand-dark: #E8DFD0;
    --cream: #FDFBF7;
    --warm-gray: #6B6560;
    --warm-gray-light: #9B9590;
    --coral: #C85A44;
    --coral-light: #FAECE7;
    --blue: #4A7FB5;
    --blue-light: #E6F0FA;
    --amber: #B8860B;
    --amber-light: #FDF3DC;
    --purple: #7B68AE;
    --purple-light: #EEEDFE;
    --text: #2C2A26;
    --text-muted: #7A756E;
    --border: rgba(0,0,0,0.1);
    --border-strong: rgba(0,0,0,0.18);
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
}

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

body {
    font-family: var(--font-body);
    background: var(--sand);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--cream);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

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

.sidebar-header h1 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--sage-dark);
    letter-spacing: -0.02em;
}

.sidebar-header .age-badge {
    display: inline-block;
    font-size: 0.72rem;
    background: var(--sage-light);
    color: var(--sage-dark);
    padding: 2px 10px;
    border-radius: 20px;
    margin-top: 4px;
    font-weight: 500;
}

.sidebar-header .dob {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.nav-section {
    padding: 0.5rem 0;
}

.nav-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--warm-gray-light);
    padding: 0 1.25rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.5rem 1.25rem;
    font-size: 0.88rem;
    color: var(--warm-gray);
    text-decoration: none;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: var(--sage-light);
    color: var(--sage-dark);
}

.nav-link.active {
    background: var(--sage-light);
    color: var(--sage-dark);
    font-weight: 500;
    border-left-color: var(--sage);
}

.nav-link .icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.nav-link .badge-count {
    margin-left: auto;
    background: var(--coral);
    color: white;
    font-size: 0.65rem;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 700;
}

.main {
    flex: 1;
    margin-left: 240px;
    padding: 2rem 2.5rem;
    max-width: 960px;
}

/* Page header */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--sage-dark);
    letter-spacing: -0.02em;
}

.page-header p {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Cards */
.card {
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon { font-size: 1.1rem; }

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

.metric-card {
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    box-shadow: var(--shadow-sm);
}

.metric-card .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-card .value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--sage-dark);
    margin-top: 2px;
}

.metric-card .sub {
    font-size: 0.72rem;
    color: var(--warm-gray-light);
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--sand-dark);
    border-radius: 1px;
}

.tl-item {
    position: relative;
    padding-bottom: 1.25rem;
    margin-bottom: 0.25rem;
}

.tl-item:last-child { padding-bottom: 0; }

.tl-dot {
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--sage);
    background: var(--cream);
}

.tl-dot.done { background: var(--sage); }
.tl-dot.pending { border-color: var(--warm-gray-light); }
.tl-dot.urgent { border-color: var(--coral); background: var(--coral); }

.tl-date {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.tl-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin: 1px 0;
}

.tl-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Badges */
.badge {
    display: inline-block;
    font-size: 0.68rem;
    padding: 2px 9px;
    border-radius: 20px;
    font-weight: 600;
    vertical-align: middle;
    margin-left: 6px;
}

.badge-done { background: var(--sage-light); color: var(--sage-dark); }
.badge-pending { background: var(--sand-dark); color: var(--warm-gray); }
.badge-urgent { background: var(--coral-light); color: var(--coral); }
.badge-info { background: var(--blue-light); color: var(--blue); }
.badge-de { background: var(--amber-light); color: var(--amber); }
.badge-es { background: var(--coral-light); color: var(--coral); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.5rem 1.1rem;
    font-size: 0.85rem;
    font-family: var(--font-body);
    font-weight: 500;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--cream);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn:hover { background: var(--sand); border-color: var(--sage); }
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--sage);
    color: white;
    border-color: var(--sage);
}

.btn-primary:hover { background: var(--sage-dark); }

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.78rem;
}

.btn-danger {
    color: var(--coral);
    border-color: var(--coral);
}

.btn-danger:hover { background: var(--coral-light); }

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}

.form-group .hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    font-family: var(--font-body);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: white;
    color: var(--text);
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--sage);
    box-shadow: 0 0 0 3px rgba(91,122,94,0.12);
}

textarea { min-height: 80px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

/* Checkbox group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    font-weight: 400;
    cursor: pointer;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s;
}

.checkbox-group label:has(input:checked) {
    background: var(--sage-light);
    border-color: var(--sage);
    color: var(--sage-dark);
}

.checkbox-group input { display: none; }

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th {
    text-align: left;
    font-weight: 500;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--sand-dark);
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

tr:hover td { background: rgba(91,122,94,0.03); }

/* Photo grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.photo-card {
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
    background: var(--sand);
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-card .caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.6));
    color: white;
    padding: 1.5rem 0.5rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 500;
}

.photo-placeholder {
    aspect-ratio: 1;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    padding: 0.5rem;
}

.photo-placeholder:hover {
    border-color: var(--sage);
    color: var(--sage);
    background: var(--sage-light);
}

.photo-placeholder .plus {
    font-size: 1.5rem;
    line-height: 1;
}

/* Document list */
.doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.doc-item:last-child { border-bottom: none; }

.doc-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.doc-info { flex: 1; }
.doc-name { font-size: 0.88rem; font-weight: 500; }
.doc-detail { font-size: 0.75rem; color: var(--text-muted); }

/* Routine grid */
.routine-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.routine-day-header {
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 4px 0;
}

.routine-day {
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 70px;
    padding: 4px;
    background: var(--cream);
}

.routine-event {
    font-size: 0.68rem;
    padding: 3px 6px;
    border-radius: 5px;
    margin-bottom: 3px;
    font-weight: 500;
    line-height: 1.3;
}

/* Milestone grid */
.milestone-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ms-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    transition: all 0.15s;
}

.ms-item:hover { border-color: var(--sage); }
.ms-item.achieved { opacity: 0.7; }

.ms-cat {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.ms-name {
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 2px;
}

.ms-age {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Chart */
.chart-container {
    position: relative;
    height: 280px;
}

/* Alerts / Flash */
.flash {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.flash-success { background: var(--sage-light); color: var(--sage-dark); }
.flash-error { background: var(--coral-light); color: var(--coral); }
.flash-info { background: var(--blue-light); color: var(--blue); }

/* Upcoming reminders sidebar widget */
.reminder-widget {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.reminder-mini {
    padding: 6px 0;
    font-size: 0.78rem;
}

.reminder-mini .date {
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Login page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sand);
    padding: 2rem;
}

.login-card {
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-card h1 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--sage-dark);
    margin-bottom: 0.25rem;
}

.login-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.login-card .form-group { text-align: left; }

/* Food tracker */
.food-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.food-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.food-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.food-dot.ok { background: var(--sage); }
.food-dot.mild { background: var(--amber); }
.food-dot.allergic { background: var(--coral); }

/* Mobile header (hidden on desktop) */
.mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.mobile-header h1 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--sage-dark);
}

.mobile-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-nav-spacer { display: none; }

/* Mobile bottom navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--cream);
    border-top: 1px solid var(--border);
    z-index: 150;
    padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--warm-gray-light);
    font-size: 0.65rem;
    padding: 4px 12px;
    border-radius: 8px;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item.active {
    color: var(--sage);
}

.mobile-nav-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.mobile-nav-label {
    font-weight: 500;
}

/* Mobile drawer */
.mobile-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
}

.mobile-drawer-overlay.active { display: block; }

.mobile-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--cream);
    border-radius: 16px 16px 0 0;
    padding: 1rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.25s ease-out;
    z-index: 201;
    max-height: 70vh;
    overflow-y: auto;
}

.mobile-drawer.active { transform: translateY(0); }

.mobile-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.mobile-drawer-header button {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.mobile-drawer-link {
    display: block;
    padding: 0.7rem 0;
    font-size: 0.9rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: color 0.1s;
}

.mobile-drawer-link:active { color: var(--sage); }

.mobile-drawer-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main {
        margin-left: 0;
        padding: 1rem 1rem;
    }
    .layout { flex-direction: column; }
    .mobile-header { display: flex; }
    .mobile-bottom-nav { display: flex; }
    .mobile-nav-spacer { display: block; height: 72px; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .milestone-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header h2 { font-size: 1.3rem; }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
    .routine-week { gap: 3px; }
    .routine-day { min-height: 50px; padding: 3px; }
    .routine-event { font-size: 0.6rem; padding: 2px 3px; }
    .doc-item { flex-wrap: wrap; }
    .doc-item > div:last-child { width: 100%; margin-top: 6px; }
    .card { padding: 1rem; }
    .tl-item form { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 380px) {
    .metrics-grid { grid-template-columns: 1fr; }
    .mobile-nav-item { padding: 4px 8px; font-size: 0.6rem; }
    .mobile-nav-icon { font-size: 1rem; }
}

/* Food phases */
.food-phase {
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 8px;
}

.food-phase .month { font-weight: 500; font-size: 0.88rem; }
.food-phase .foods { font-size: 0.8rem; margin-top: 2px; opacity: 0.85; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 2rem; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.88rem; }

/* Modal for inline forms */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--cream);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--sage-dark);
}
