/* StopClope Main Stylesheet */
/* Charte graphique Alre Web */

:root {
    /* Mode sombre (defaut) */
    --bg-primary: #24303E;
    --bg-secondary: #354252;
    --bg-card: #354252;
    --accent: #E8C9A0; /* Ajusté pour WCAG AA (4.5:1) - était #D5B18A (3.8:1) */
    --accent-light: #F5DDB8;
    --accent-dark: #C9A87A;
    --success: #28a745;
    --warning: #D5B18A;
    --error: #dc3545;
    --text-primary: #F6F1EA;
    --text-secondary: #c0c0c0; /* WCAG AA compliant ~5.3:1 */
    --bg-light: #F6F1EA;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.15);

    /* Font size scale */
    --font-scale: 1;
}

/* Font size options */
[data-font-size="small"] {
    --font-scale: 0.85;
}

[data-font-size="large"] {
    --font-scale: 1.15;
}

[data-font-size="xlarge"] {
    --font-scale: 1.3;
}

/* Mode clair */
[data-theme="light"] {
    --bg-primary: #F6F1EA;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --text-primary: #24303E;
    --text-secondary: #5a5a6a;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Respecter la preference systeme si pas de choix explicite */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-primary: #F6F1EA;
        --bg-secondary: #FFFFFF;
        --bg-card: #FFFFFF;
        --text-primary: #24303E;
        --text-secondary: #5a5a6a;
        --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
        --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: calc(16px * var(--font-scale));
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 80px;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
}

/* Prevent horizontal scroll on mobile */
html, body {
    overflow-x: hidden;
    width: 100%;
}

.header {
    text-align: center;
    padding: 20px 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    -webkit-tap-highlight-color: transparent;
}

/* Cards with links should have touch feedback */
.card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s;
}

.card-link:active {
    transform: scale(0.98);
}

/* Responsive adjustments for small screens */
@media (max-width: 380px) {
    .container {
        padding: 12px;
    }

    .card {
        padding: 15px;
    }

    .big-button {
        padding: 20px;
        font-size: 1.1rem;
    }

    .stats-grid {
        gap: 8px;
    }

    .stat-item {
        padding: 12px;
    }
}

.score-display {
    text-align: center;
    padding: 30px 20px;
}

.score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--success);
}

.score-value.negative {
    color: var(--error);
}

.score-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.rank-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 10px;
}

.progress-bar {
    background: var(--bg-secondary);
    border-radius: 10px;
    height: 8px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, var(--success), #00ff88);
    height: 100%;
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Sticky action buttons */
.sticky-actions {
    position: fixed;
    bottom: 70px; /* Au-dessus de la nav */
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: linear-gradient(to top, var(--bg-primary) 80%, transparent);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sticky-spacer {
    height: 140px; /* Espace pour les boutons sticky */
}

.big-button {
    width: 100%;
    padding: 20px 15px;
    font-size: 1.2rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-md);
}

.big-button:active {
    transform: scale(0.98);
}

/* Enhanced touch feedback */
.big-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

@media (hover: none) {
    .big-button:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }
}

.big-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondary-button {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--accent);
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 12px;
    transition: transform 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.secondary-button:active {
    transform: scale(0.97);
    background: var(--bg-primary);
}

.secondary-button:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-item {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Stats compactes (home) */
.stats-compact {
    padding: 16px 20px;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.stat-main .stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.stat-main .stat-label {
    font-size: 1rem;
    margin-top: 0;
}

.stat-comparison {
    text-align: right;
}

.stat-diff {
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--bg-secondary);
}

.stat-diff.positive {
    color: var(--success);
    background: rgba(0, 217, 165, 0.15);
}

.stat-diff.negative {
    color: var(--accent);
    background: rgba(213, 177, 138, 0.15);
}

.cig-list {
    list-style: none;
}

.cig-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg-secondary);
}

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

.cig-time {
    font-size: 1.1rem;
    font-weight: 500;
}

.cig-badge {
    font-size: 0.7rem;
    background: var(--warning);
    color: #000;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 12px 16px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background: rgba(233, 69, 96, 0.1);
    border-radius: 8px;
}

/* Navigation */
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    display: flex;
    justify-content: stretch;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--bg-card);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    transition: all 0.2s;
    padding: 12px 0;
    min-height: 60px;
}

.nav-item:active {
    background: var(--bg-card);
}

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

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

/* Score breakdown */
.score-breakdown {
    margin-top: 15px;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--bg-secondary);
    font-size: 0.9rem;
}

.breakdown-score {
    font-weight: 600;
}

.breakdown-score.positive {
    color: var(--success);
}

.breakdown-score.negative {
    color: #E9B98A; /* Lighter accent for better contrast */
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
}

.modal-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #c8c8c8; /* ~5.8:1 contrast ratio */
}

.input-group input {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-size: 1rem;
    cursor: pointer;
}

.btn-cancel {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-confirm {
    background: var(--accent);
    color: var(--bg-primary);
    font-weight: 500;
}

.btn-confirm.btn-danger {
    background: var(--error);
    color: white;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    padding: 15px 25px;
    border-radius: 12px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 90%;
}

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

.toast.toast-success {
    border-left: 4px solid var(--success);
}

.toast.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast.toast-error {
    border-left: 4px solid var(--error);
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toast-message {
    font-weight: 500;
}

.toast-points {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.toast-points.positive {
    color: var(--success);
    font-weight: 600;
}

.toast-points.negative {
    color: var(--error);
    font-weight: 600;
}

.toast-action {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: inherit;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 12px;
    transition: background 0.2s;
}

.toast-action:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Badge notification */
.badge-notification-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.badge-notification-overlay.active {
    opacity: 1;
}

.badge-notification {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
    border: 2px solid var(--success);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    max-width: 320px;
    width: 90%;
    transform: scale(0.8);
    transition: transform 0.3s ease;
    box-shadow: 0 0 40px rgba(0, 217, 165, 0.3);
}

.badge-notification-overlay.active .badge-notification {
    transform: scale(1);
    animation: badge-pop 0.5s ease;
}

@keyframes badge-pop {
    0% { transform: scale(0.5); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.badge-notification-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: badge-bounce 0.8s ease infinite;
}

@keyframes badge-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.badge-notification-title {
    font-size: 0.9rem;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.badge-notification-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.badge-notification-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Welcome notification (first log) */
.welcome-notification {
    border-color: #00d4aa;
    box-shadow: 0 0 40px rgba(0, 212, 170, 0.4);
    background: linear-gradient(135deg, #1a3a35, #0f2622);
}

.welcome-notification .badge-notification-title {
    color: #00d4aa;
    font-size: 1.1rem;
}

.welcome-notification .badge-notification-icon {
    animation: welcome-rocket 1.5s ease infinite;
}

@keyframes welcome-rocket {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-15px) rotate(-5deg); }
    50% { transform: translateY(-5px) rotate(5deg); }
    75% { transform: translateY(-10px) rotate(-3deg); }
}

/* Button feedback animations */
@keyframes pulse-success {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

@keyframes pulse-warning {
    0% { box-shadow: 0 0 0 0 rgba(213, 177, 138, 0.7); }
    70% { box-shadow: 0 0 0 20px rgba(213, 177, 138, 0); }
    100% { box-shadow: 0 0 0 0 rgba(213, 177, 138, 0); }
}

.big-button.feedback-success {
    animation: pulse-success 0.6s ease-out;
}

.big-button.feedback-warning {
    animation: pulse-warning 0.6s ease-out;
}

/* Tier celebration */
.tier-celebration {
    position: relative;
    animation: tier-celebrate 1s ease-out;
    overflow: hidden;
}

@keyframes tier-celebrate {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.tier-celebration::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #ffd700, #ff6b6b, #ffd700, #00ff88, #ffd700);
    background-size: 400% 400%;
    border-radius: inherit;
    z-index: -1;
    animation: gradient-border 3s ease infinite;
}

@keyframes gradient-border {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* First day celebration */
.first-day-celebration {
    position: relative;
    animation: first-day-celebrate 1.2s ease-out;
    overflow: hidden;
}

@keyframes first-day-celebrate {
    0% {
        transform: scale(0.8) rotate(-5deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.08) rotate(2deg);
    }
    75% {
        transform: scale(0.98) rotate(-1deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

.first-day-celebration::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #00d4aa, #00ff88, #00d4aa, #ffd700, #00d4aa);
    background-size: 400% 400%;
    border-radius: inherit;
    z-index: -1;
    animation: gradient-border 3s ease infinite;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

/* Accessibility */
*:focus-visible {
    outline: 3px solid var(--success);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
select:focus-visible {
    outline: 3px solid var(--success);
    outline-offset: 2px;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    z-index: 100;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    top: 0;
}

/* Improved text contrast (WCAG 1.4.3 AA) */
.score-label,
.stat-label,
.nav-item {
    color: #c0c0c0; /* ~5.3:1 contrast ratio on #24303E */
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Accordéon */
.accordion {
    border: none;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 5px 0;
    list-style: none;
}

.accordion-header::-webkit-details-marker {
    display: none;
}

.accordion-icon {
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
}

details[open] .accordion-icon {
    transform: rotate(180deg);
}

/* Skip link amélioré */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--accent);
    color: var(--bg-primary);
    font-weight: 600;
    border-radius: var(--radius-md);
    z-index: 10000;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 10px;
    outline: 3px solid var(--text-primary);
    outline-offset: 2px;
}

/* Boutons rapides dans modal rétroactif */
.btn-quick {
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: calc(0.85rem * var(--font-scale));
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.btn-quick:hover {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-quick:active {
    transform: scale(0.95);
}
