/* Clop'Clock — Styles de base (architecture) */

:root {
    --color-bg: #0f0f1a;
    --color-surface: #1a1a2e;
    --color-primary: #e94560;
    --color-primary-hover: #ff6b81;
    --color-text: #eaeaea;
    --color-text-muted: #a0a0b0;
    --color-border: #2a2a3e;
    --radius: 16px;
    --spacing: 16px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="light"] {
    --color-bg: #f5f5f7;
    --color-surface: #ffffff;
    --color-text: #1a1a2e;
    --color-text-muted: #6b6b80;
    --color-border: #e0e0e8;
}

@media (prefers-color-scheme: light) {
    [data-theme="auto"] {
        --color-bg: #f5f5f7;
        --color-surface: #ffffff;
        --color-text: #1a1a2e;
        --color-text-muted: #6b6b80;
        --color-border: #e0e0e8;
    }
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100dvh;
    line-height: 1.5;
    opacity: 1;
}

/* Animation d'entrée uniquement quand JS est actif (layout principal) */
html.with-js body {
    opacity: 0;
    transition: opacity 0.3s ease;
}

html.with-js body.is-ready {
    opacity: 1;
}

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-header {
    padding: var(--spacing);
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.app-main {
    flex: 1;
    padding: var(--spacing);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.app-main--with-nav {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

.home {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing);
    padding-top: 1rem;
}

.home-header {
    display: flex;
    width: 100%;
    justify-content: space-between;
}

.home-date {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-transform: capitalize;
}

.home-counter {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 1rem 0;
}

.home-counter-value {
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
}

.home-counter-label {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    width: 100%;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:not(:disabled):hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.btn-clope {
    min-height: 64px;
    font-size: 1.125rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.35);
    aspect-ratio: 1;
    max-width: 300px;
    border-radius: 50%;
}

.btn-clope:not(:disabled):active {
    box-shadow: 0 2px 10px rgba(233, 69, 96, 0.25);
}

.btn:focus-visible,
.filter-tab:focus-visible,
.bottom-nav__item:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.home-greeting {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.home-goal {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
    width: 100%;
    align-items: center;
    justify-content: space-between;
}

.goal-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
}

.goal-badge--ok {
    background: rgba(46, 213, 115, 0.15);
    color: #2ed573;
}

.goal-badge--over {
    background: rgba(233, 69, 96, 0.15);
    color: var(--color-primary);
}

.goal-detail {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.counter-pulse {
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.btn--loading {
    opacity: 0.7;
    pointer-events: none;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

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

.home-logout {
    margin-top: 1rem;
}

/* Widgets dashboard */
.widgets {
    width: 100%;
    margin-top: 1.5rem;
}

.widgets-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.widget-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 88px;
}

.widget-card--wide {
    grid-column: 1 / -1;
}

.widget-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.3;
}

.widget-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.widget-value--sm {
    font-size: 1.25rem;
}

.widget-unit {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.btn-stats-link {
    margin-top: 1rem;
    max-width: 100%;
}

/* Bottom navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-around;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 100;
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    min-height: 44px;
    min-width: 64px;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 8px;
    transition: color 0.2s;
}

.bottom-nav__item--active {
    color: var(--color-primary);
}

.bottom-nav__icon {
    width: 22px;
    height: 22px;
}

/* Pages secondaires */
.page-heading {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    width: 100%;
    text-align: left;
}

.page-intro {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
    width: 100%;
    text-align: left;
    line-height: 1.5;
}

.stats-page,
.settings-page {
    width: 100%;
}

.stats-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
    text-align: center;
}

.settings-logout {
    width: 100%;
    margin-top: 2rem;
}

/* Mode paquet / roulées */
.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mode-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px;
    border: 2px solid var(--color-border);
    border-radius: 14px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    min-height: 72px;
}

.mode-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-card--active {
    border-color: var(--color-primary);
    background: rgba(233, 69, 96, 0.08);
}

.mode-card__title {
    font-weight: 600;
    font-size: 0.95rem;
}

.mode-card__desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.3;
}

.settings-panel[hidden] {
    display: none !important;
}

.input-with-suffix {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-suffix input {
    flex: 1;
}

.input-suffix {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.gram-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.gram-preset {
    padding: 6px 10px;
    min-height: 36px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
}

.gram-preset--active {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: rgba(233, 69, 96, 0.1);
}

.cost-preview {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 16px;
    margin: 0.5rem 0 1rem;
}

.cost-preview__title {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.cost-preview__total {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.cost-preview__parts {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.cost-preview__parts li {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.cost-preview__hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* Stats page */
.filter-tabs {
    display: flex;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

.filter-tab {
    flex-shrink: 0;
    padding: 0.5rem 0.875rem;
    min-height: 36px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.stats-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    margin-bottom: 1.5rem;
}

.chart-container {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 1rem;
}

.chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-text-muted);
}

.history-section {
    width: 100%;
    margin-top: 0.5rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    align-items: center;
    padding: 12px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    font-size: 0.875rem;
}

.history-date {
    color: var(--color-text);
    font-weight: 500;
}

.history-count {
    color: var(--color-text-muted);
}

.history-goal {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

.history-item--ok .history-goal {
    background: rgba(46, 213, 115, 0.15);
    color: #2ed573;
}

.history-item--over .history-goal {
    background: rgba(233, 69, 96, 0.15);
    color: var(--color-primary);
}

.history-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 2rem 1rem;
    font-size: 0.875rem;
}

/* Settings */
.settings-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.settings-group {
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-group legend {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
    min-height: 48px;
    width: 100%;
}

.alert-success {
    background: rgba(46, 213, 115, 0.15);
    color: #2ed573;
    border: 1px solid rgba(46, 213, 115, 0.3);
}

/* PWA install banner */
.pwa-install {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 448px;
    z-index: 90;
    animation: slideUp 0.4s ease;
}

.pwa-install__content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.pwa-install__text {
    flex: 1;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--color-text-muted);
}

.pwa-install__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install__dismiss {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1rem;
    cursor: pointer;
    min-width: 32px;
    min-height: 32px;
    border-radius: 8px;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(16px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.btn-sm {
    min-height: 36px;
    font-size: 0.875rem;
    max-width: 200px;
}

/* Auth */
.app-auth .app-main {
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem var(--spacing);
}

.auth-title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

.auth-heading {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.form-group input,
.form-group select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
    min-height: 48px;
    width: 100%;
}

.form-group input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: -1px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(233, 69, 96, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(233, 69, 96, 0.3);
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.auth-link a {
    color: var(--color-primary);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}
