/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

a { color: #ec4899; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navbar === */
.navbar {
    background: #9d174d;
    color: white;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 1.3rem;
    font-weight: 700;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 0;
    align-items: center;
    flex-wrap: wrap;
    height: 100%;
}

.nav-links a {
    color: rgba(255,255,255,0.85);
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    border-radius: 0;
}

.nav-links a:hover, .nav-links a.active {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* === Burger Menu === */
.burger-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.burger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

.burger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-btn.open span:nth-child(2) { opacity: 0; }
.burger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* === User Dropdown === */
.nav-user-dropdown {
    position: relative;
    margin-left: 12px;
    border-left: 1px solid rgba(255,255,255,0.3);
    padding-left: 12px;
}

.nav-user-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background 0.2s;
}

.nav-user-btn:hover { background: rgba(255,255,255,0.2); color: white; }

.nav-user-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 6px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}

.nav-user-menu.open { display: block; }

.nav-user-menu a {
    display: block;
    padding: 10px 16px;
    color: #333;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.nav-user-menu a:hover { background: #f0f2f5; text-decoration: none; }

/* === Disabled Input === */
.input-disabled {
    background: #f0f2f5;
    color: #666;
    cursor: not-allowed;
}

/* === Container === */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* === Flash Messages === */
.flash-messages { margin-bottom: 20px; }

.flash {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.95rem;
    animation: fadeIn 0.3s ease;
}

.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* === Auth === */
.auth-container {
    max-width: 400px;
    margin: 80px auto;
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    text-align: center;
}

.auth-container h1 { font-size: 1.8rem; margin-bottom: 4px; }
.auth-container h2 { font-size: 1.2rem; color: #666; margin-bottom: 24px; font-weight: 400; }
.auth-link { margin-top: 16px; font-size: 0.9rem; color: #666; }

/* === Forms === */
.form-container, .list-container, .dashboard {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
}

h1 { font-size: 1.5rem; margin-bottom: 24px; color: #1e293b; }
h2 { font-size: 1.2rem; margin: 20px 0 12px; color: #334155; }

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
    font-size: 0.95rem;
}

input[type="text"], input[type="password"], input[type="date"],
input[type="email"], textarea, select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #ec4899;
    box-shadow: 0 0 0 3px rgba(236,72,153,0.1);
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-half { flex: 1; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
}

.btn-primary { background: #ec4899; color: white; }
.btn-primary:hover { background: #db2777; text-decoration: none; }

.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-full { width: 100%; display: block; padding: 12px; font-size: 1.05rem; }

.btn-large { padding: 16px 32px; font-size: 1.15rem; border-radius: 12px; }

.btn-small { padding: 6px 14px; font-size: 0.85rem; }

/* === Slider === */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, #22c55e, #eab308, #ef4444);
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    border: 3px solid #9d174d;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: white;
    border: 3px solid #9d174d;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

.intensity-display {
    font-size: 1.4rem;
    font-weight: 700;
}

/* === Toggle Buttons === */
.toggle-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.toggle-btn {
    cursor: pointer;
    display: inline-block;
}

.toggle-btn input { display: none; }

.toggle-btn span {
    display: inline-block;
    padding: 8px 16px;
    border: 2px solid #d1d5db;
    border-radius: 20px;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: white;
    color: #555;
    user-select: none;
}

.toggle-btn span:hover {
    border-color: #f9a8d4;
    background: #fdf2f8;
}

.toggle-btn input:checked + span {
    background: #ec4899;
    color: white;
    border-color: #ec4899;
}

.toggle-btn.disabled {
    cursor: not-allowed;
    opacity: 0.4;
    pointer-events: none;
}

.required-star {
    color: #dc2626;
    font-weight: bold;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.85rem;
}

.validation-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

/* === Sleep Quality Smileys === */
.sleep-smiley-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.sleep-smiley-btn {
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.sleep-smiley-btn input { display: none; }

.sleep-smiley-btn .smiley {
    font-size: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #d1d5db;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    transition: all 0.2s;
    background: white;
}

.sleep-smiley-btn .smiley-label {
    font-size: 0.75rem;
    color: #888;
    transition: color 0.2s;
}

@media (max-width: 480px) {
    .sleep-smiley-group {
        gap: 6px;
    }
    .sleep-smiley-btn .smiley {
        font-size: 1.5rem;
        width: 42px;
        height: 42px;
        border-width: 2px;
    }
    .sleep-smiley-btn .smiley-label {
        font-size: 0.65rem;
    }
}

.sleep-smiley-btn:hover .smiley {
    border-color: #f9a8d4;
    background: #fdf2f8;
}

.sleep-smiley-btn input:checked + .smiley {
    border-color: #ec4899;
    background: #fdf2f8;
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(236,72,153,0.3);
}

.sleep-smiley-btn input:checked ~ .smiley-label {
    color: #ec4899;
    font-weight: 600;
}

/* === Body Map === */
.body-map-container {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.body-map-wrapper {
    text-align: center;
    flex: 0 1 220px;
}

.body-map-wrapper h3 {
    font-size: 0.95rem;
    color: #555;
    margin-bottom: 8px;
}

.body-map {
    width: 100%;
    max-width: 200px;
    height: auto;
    background: #f0f2f5;
    border: none;
    border-radius: 12px;
    padding: 8px;
}

.body-zone {
    fill: #b0bec5;
    stroke: #90a4ae;
    stroke-width: 1;
    cursor: pointer;
    transition: fill 0.2s, stroke 0.2s;
}

.body-zone:hover {
    fill: #90a4ae;
    stroke: #ec4899;
    stroke-width: 2;
}

.body-zone.selected {
    fill: #f0c040;
    stroke: #d4a017;
    stroke-width: 2;
}

.selected-zones {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 32px;
}

.zone-tag {
    display: inline-block;
    background: #fee2e2;
    color: #991b1b;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}

.zone-tag:hover { background: #fecaca; }

.zone-hint {
    color: #9ca3af;
    font-size: 0.9rem;
    font-style: italic;
}

/* === Entry Body Maps (read-only in details) === */
.entry-body-maps {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 16px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
}

.entry-body-maps .body-map-wrapper { flex: 0 1 140px; }
.body-map-mini { max-width: 140px; pointer-events: none; }

/* === Entry Cards === */
.entry-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.entry-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.entry-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

a.entry-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.entry-date {
    font-weight: 600;
    color: #475569;
}

.intensity-badge {
    padding: 4px 12px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

/* Intensity colors 0-10 */
.intensity-0 { background: #22c55e; }
.intensity-1 { background: #4ade80; }
.intensity-2 { background: #86efac; color: #333; }
.intensity-3 { background: #bef264; color: #333; }
.intensity-4 { background: #d9f99d; color: #333; }
.intensity-5 { background: #fde047; color: #333; }
.intensity-6 { background: #fbbf24; color: #333; }
.intensity-7 { background: #f97316; }
.intensity-8 { background: #ef4444; }
.intensity-9 { background: #dc2626; }
.intensity-10 { background: #991b1b; }

.entry-details-short {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.detail-tag {
    background: #fce7f3;
    color: #9d174d;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    line-height: 1.4;
}

.location-tag {
    background: #fee2e2;
    color: #991b1b;
}

.entry-expanded {
    display: none;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.entry-card.expanded .entry-expanded { display: block; }

.entry-expanded p {
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.entry-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
}

/* === Filter Bar === */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn-filter {
    background: #f1f5f9;
    color: #475569;
    border: 2px solid #e2e8f0;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-filter:hover { border-color: #f9a8d4; background: #fdf2f8; }
.btn-filter.active { background: #ec4899; color: white; border-color: #ec4899; }

/* === Dashboard === */
.dashboard-actions {
    margin: 20px 0;
    text-align: center;
}

.info-box {
    background: #fdf2f8;
    border: 1px solid #fbcfe8;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
    color: #9d174d;
}

.empty-state {
    text-align: center;
    color: #9ca3af;
    padding: 40px 0;
    font-size: 1.05rem;
}

/* === Report === */
.report-container { max-width: 960px; margin: 0 auto; }

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.report-title h1 { margin-bottom: 4px; }
.report-period { color: #64748b; font-size: 0.95rem; }
.report-patient p { font-size: 0.9rem; color: #475569; margin-bottom: 2px; }

.report-grid {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
}

.report-grid-2 { grid-template-columns: 1.5fr 1fr; }

.report-card {
    background: white;
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    margin-bottom: 10px;
}

.report-card h2 { margin-top: 0; margin-bottom: 6px; font-size: 0.95rem; color: #9d174d; }

.big-number { text-align: center; padding: 8px 0; }
.big-value { font-size: 2.2rem; font-weight: 800; color: #9d174d; }
.big-unit { font-size: 1.2rem; color: #64748b; }

.report-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.report-table th, .report-table td { padding: 5px 10px; text-align: left; border-bottom: 1px solid #e2e8f0; }
.report-table th { background: #f1f5f9; font-weight: 600; color: #334155; }
.report-table-full { font-size: 0.82rem; }
.table-scroll { overflow-x: auto; }

.report-footer {
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
    padding: 20px 0;
    border-top: 1px solid #e2e8f0;
    margin-top: 20px;
}

/* === Print === */
@media print {
    .navbar, .no-print, .filter-bar { display: none !important; }
    body { background: white; font-size: 10px; }
    .container { max-width: 100%; padding: 0; margin: 0; }
    .report-container { max-width: 100%; }
    .report-header { box-shadow: none; border: 1px solid #ddd; padding: 8px 14px; margin-bottom: 6px; }
    .report-card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; padding: 8px 12px; margin-bottom: 6px; }
    .report-card h2 { font-size: 0.85rem; margin-bottom: 4px; }
    .report-grid { gap: 6px; margin-bottom: 6px; }
    .report-grid-2 { grid-template-columns: 1fr 1fr; }
    .big-value { font-size: 1.8rem; }
    .big-number { padding: 4px 0; }
    .report-title h1 { font-size: 1.2rem; margin-bottom: 2px; }
    .report-period { font-size: 0.8rem; }
    .report-patient p { font-size: 0.8rem; }
    .report-footer { font-size: 0.75rem; padding: 8px 0; margin-top: 8px; }
    .report-entries-page { page-break-before: always; }
    .report-table-full { font-size: 0.7rem; }
    .report-table th, .report-table td { padding: 3px 6px; }
    canvas { max-height: 140px !important; }
}

/* === Responsive === */
@media (max-width: 640px) {
    .burger-btn { display: flex; }
    .nav-links {
        display: none;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        height: auto;
        width: 100%;
        gap: 0;
        background: #9d174d;
        position: absolute;
        top: 56px;
        left: 0;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        padding: 8px 0;
    }
    .nav-links.open { display: flex; }
    .nav-links a {
        padding: 12px 20px;
        height: auto;
        border-radius: 0;
        font-size: 1rem;
        display: block;
    }
    .nav-links a:hover, .nav-links a.active {
        background: rgba(255,255,255,0.2);
    }
    .nav-user-dropdown {
        margin-left: 0;
        border-left: none;
        padding-left: 0;
        border-top: 1px solid rgba(255,255,255,0.2);
    }
    .nav-user-btn {
        width: 100%;
        text-align: left;
        padding: 12px 20px;
        font-size: 1rem;
    }
    .nav-user-menu {
        position: static;
        box-shadow: none;
        background: rgba(0,0,0,0.1);
        border-radius: 0;
        margin-top: 0;
    }
    .nav-user-menu a { padding: 10px 32px; color: rgba(255,255,255,0.85); }
    .nav-user-menu a:hover { background: rgba(255,255,255,0.1); }
    .form-row { flex-direction: column; gap: 0; }
    .form-container, .list-container, .dashboard { padding: 20px 16px; }
    .auth-container { margin: 40px 16px; padding: 28px 20px; }
    .body-map-container { flex-direction: column; align-items: center; }
    .report-grid-2 { grid-template-columns: 1fr; }
}
