/* ============================================================
   Design system - epure, mobile-first
   Inspirations : Apple / Google Material / Notion / Linear
   ============================================================ */

:root {
    --color-bg:        #F5F5F7;
    --color-surface:    #FFFFFF;
    --color-border:     #E5E5EA;
    --color-text:       #1D1D1F;
    --color-text-muted: #6E6E73;

    --color-travail: #4F46E5;
    --color-famille: #DB2777;
    --color-sport:   #16A34A;
    --color-priere:  #CA8A04;
    --color-lecture: #0891B2;

    --radius: 16px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

.app {
    width: 100%;
    padding: var(--space-4) clamp(16px, 4vw, 56px) 96px;
}

/* ---- Tabs de periode ---- */

.period-tabs {
    display: flex;
    gap: var(--space-1);
    background: var(--color-surface);
    border-radius: 12px;
    padding: var(--space-1);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow);
}

.period-tabs button {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--space-2) var(--space-1);
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.period-tabs button.active {
    background: var(--color-text);
    color: #fff;
}

/* ---- Score du jour ---- */

.score-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: var(--space-6);
}

.score-ring {
    position: relative;
    width: 132px;
    height: 132px;
}

.score-ring svg {
    width: 100%;
    height: 100%;
}

.score-ring-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.score-label {
    color: var(--color-text-muted);
    font-size: 13px;
    margin-top: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ---- Cartes domaines ---- */

.domain-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.domain-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-4);
    border-left: 4px solid var(--domain-color, var(--color-text));
}

.domain-card .domain-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.domain-card .domain-time {
    font-size: 24px;
    font-weight: 700;
    margin-top: var(--space-1);
    font-variant-numeric: tabular-nums;
}

.domain-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.domain-goal-ring {
    position: relative;
    width: 56px;
    height: 56px;
    min-width: 56px;
    flex-shrink: 0;
}

.domain-goal-ring svg {
    width: 100%;
    height: 100%;
}

.domain-goal-ring-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.domain-goal-caption {
    margin-top: var(--space-2);
    font-size: 12px;
    color: var(--color-text-muted);
}

.domain-goal-caption-empty {
    opacity: 0.5;
    font-style: italic;
}

.domain-subtypes {
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

.domain-subtype-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--color-text-muted);
    padding: 2px 0;
    font-variant-numeric: tabular-nums;
}

/* ---- Divers ---- */

.section-title {
    font-size: 15px;
    font-weight: 600;
    margin: var(--space-6) 0 var(--space-3);
}

.empty-hint {
    color: var(--color-text-muted);
    font-size: 13px;
    text-align: center;
    padding: var(--space-4);
}

@media (min-width: 640px) {
    .domain-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Navigation basse ---- */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--space-2) env(safe-area-inset-right) calc(var(--space-2) + env(safe-area-inset-bottom)) env(safe-area-inset-left);
    z-index: 10;
}

.bottom-nav a {
    flex: 1;
    text-align: center;
    padding: var(--space-2) 2px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bottom-nav a.active {
    color: var(--color-text);
    background: var(--color-bg);
}

.bottom-nav a.nav-icon {
    font-size: 18px;
    padding: var(--space-2);
    line-height: 1;
}

/* ---- Graphiques (page Statistiques) ---- */

.chart-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-4);
    margin-bottom: var(--space-2);
    overflow-x: auto;
}

.chart-svg {
    width: 100%;
    height: auto;
    display: block;
}

.chart-label {
    font-size: 8px;
    fill: var(--color-text-muted);
}

.chart-guide {
    stroke: var(--color-border);
    stroke-width: 1;
}

.score-line {
    stroke: var(--color-text);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.score-dot {
    fill: var(--color-text);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    margin-top: var(--space-4);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 12px;
    color: var(--color-text-muted);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* ---- Reglages ---- */

.settings-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-4);
    margin-bottom: var(--space-2);
}

.hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--color-text-muted);
}

.btn-save {
    margin-top: var(--space-4);
    width: 100%;
    border: none;
    border-radius: 10px;
    background: var(--color-text);
    color: #fff;
    padding: var(--space-3);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.goals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.goals-table th {
    text-align: center;
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 12px;
    padding-bottom: var(--space-2);
}

.goals-table td {
    padding: var(--space-1) var(--space-1);
    text-align: center;
}

.goals-table td:first-child {
    text-align: left;
    font-weight: 500;
}

.goal-input,
.weight-input {
    width: 76px;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

.category-domain {
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.category-domain:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.category-domain-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.domain-color-input {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    border-radius: 8px;
    padding: 0;
    background: none;
}

.domain-name-input {
    flex: 1;
    min-width: 0;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
}

.category-visibility {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.btn-delete-domain,
.btn-delete-category {
    border: none;
    background: none;
    color: var(--color-text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    white-space: nowrap;
}

.btn-delete-domain.confirm,
.btn-delete-category.confirm {
    color: #DC2626;
    font-weight: 600;
}

.category-add-domain {
    padding-top: var(--space-2);
}

.category-add-domain #new-domain-color {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    border-radius: 8px;
    padding: 0;
    background: none;
}

.category-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) 0;
}

.category-name,
.category-new-name {
    flex: 1;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 13px;
}

.category-active {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.history-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
}

.history-row:last-child {
    border-bottom: none;
}

.history-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date-input {
    font-size: 12px;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 2px 4px;
    background: var(--color-surface);
    margin-top: 2px;
}

.history-note {
    font-size: 12px;
    color: var(--color-text-muted);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-duration {
    width: 88px;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

.history-unit {
    font-size: 12px;
    color: var(--color-text-muted);
}

.history-delete {
    border: none;
    background: none;
    color: var(--color-text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    white-space: nowrap;
}

.history-delete.confirm {
    color: #DC2626;
    font-weight: 600;
}

.btn-add-category {
    border: none;
    background: var(--color-bg);
    border-radius: 8px;
    padding: var(--space-2) var(--space-3);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

/* ---- Toast ---- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 90px;
    transform: translate(-50%, 8px);
    background: var(--color-text);
    color: #fff;
    padding: var(--space-3) var(--space-5);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 20;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---- Bouton flottant + saisie rapide ---- */

.fab {
    position: fixed;
    right: var(--space-5);
    bottom: 76px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--color-text);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    z-index: 15;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    align-items: flex-end;
    justify-content: center;
    z-index: 30;
}

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

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--color-surface);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: var(--space-5);
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
    .modal-overlay { align-items: center; }
    .modal { border-radius: var(--radius); }
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: var(--space-4);
}

.modal-row {
    width: 100%;
    margin-top: var(--space-3);
}

#qa-type,
#qa-duration,
#qa-custom-date,
#qa-note {
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-size: 15px;
    background: var(--color-surface);
}

#qa-note {
    resize: vertical;
    font-family: inherit;
}

.qa-date-buttons {
    display: flex;
    gap: var(--space-2);
}

.qa-date-btn {
    flex: 1;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 10px;
    padding: var(--space-2);
    font-size: 13px;
    cursor: pointer;
}

.qa-date-btn.active {
    background: var(--color-text);
    color: #fff;
    border-color: var(--color-text);
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.modal-actions .btn-save {
    margin-top: 0;
}

.btn-cancel {
    flex: 1;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 10px;
    padding: var(--space-3);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
