/* Variables CSS - Inspiré de la charte graphique */
:root {
    /* Couleurs principales */
    --color-primary: #A47864;
    --color-primary-light: #C19B87;
    --color-primary-dark: #7A5A4B;
    --color-secondary: #93E9BE;
    --color-secondary-light: #B8F2D4;
    --color-secondary-dark: #5BC18A;
    
    /* Texte */
    --color-text: #1A1D20;
    --color-text-secondary: #4A5057;
    --color-text-muted: #6C757D;
    --color-text-inverse: #F8F9FA;
    
    /* Surfaces */
    --color-bg: #F5F5F5;
    --color-surface: #FFFFFF;
    --color-surface-elevated: #FFFFFF;
    --color-border: #E5E7EB;
    --color-input-bg: #F9FAFB;
    --color-input-readonly: #F3F4F6;
    
    /* Accents */
    --color-action: #0066CC;
    --color-success: #10B981;
    --color-warning: #F5D547;
    --color-error: #E63946;
    
    /* Espacements */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Typographie */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* Autres */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}


/* Reset et base */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-primary);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout principal */
.calculator-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 640px;
    margin: 0 auto;
    padding: var(--space-md);
}

/* Header */
.app-header {
    text-align: center;
    padding: var(--space-lg) 0;
    margin-bottom: var(--space-xl);
}

.app-header h1 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

/* Cards */
.card {
    background: var(--color-surface-elevated);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: var(--transition);
}

/* Formulaires */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: var(--space-md);
    color: var(--color-text-muted);
    font-weight: 500;
}

input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: var(--space-md);
    font-size: var(--font-size-base);
    font-family: inherit;
    background: var(--color-input-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: var(--transition);
}

.input-wrapper {
    position: relative;
}

.input-wrapper input[type="number"],
.input-wrapper input[type="text"] {
    padding-left: calc(var(--space-xl) + var(--space-sm));
}

.currency-symbol {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    font-weight: 500;
    pointer-events: none;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(164, 120, 100, 0.1);
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-xl);
    font-size: var(--font-size-base);
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: var(--color-bg);
}

/* Nouvelle interface calculatrice */
.main-calculator {
    max-width: 600px;
    margin: 0 auto;
}

.province-select {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-input-bg);
    font-size: var(--font-size-base);
    color: var(--color-text);
    transition: var(--transition);
}

.province-select:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
}

.calculator-grid {
    display: grid;
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.tax-display-group {
    display: grid;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--color-input-readonly);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.amount-input {
    font-size: var(--font-size-lg);
    font-weight: 500;
}

.total-amount {
    background: var(--color-secondary-light);
}

.readonly-input {
    background: var(--color-surface) !important;
    color: var(--color-text-secondary);
    cursor: not-allowed;
    border: 1px solid var(--color-border) !important;
    padding: var(--space-md) !important;
    padding-left: 3rem !important;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    width: 100% !important;
}

/* UNIFORMISATION DU PADDING - TOUS LES INPUTS DANS input-wrapper */
.input-wrapper input,
.input-wrapper .readonly-input {
    padding-left: calc(var(--space-xl) + var(--space-sm)) !important;
    width: 100%;
}

/* Corrections pour le chevauchement du symbole $ */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: var(--space-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-secondary);
    font-weight: 500;
    pointer-events: none;
    z-index: 2;
}

/* États des champs */
.field-active {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(164, 120, 100, 0.1) !important;
}

.field-error {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1) !important;
}

.field-valid {
    border-color: var(--color-success) !important;
}

.field-invalid {
    border-color: var(--color-error) !important;
}

.field-highlighted {
    animation: fieldHighlight 1s ease-out;
}

@keyframes fieldHighlight {
    0% { background-color: var(--color-secondary-light); }
    100% { background-color: transparent; }
}

/* Messages d'erreur des champs */
.field-message {
    display: none;
    font-size: var(--font-size-sm);
    margin-top: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.field-message-error {
    background-color: rgba(230, 57, 70, 0.1);
    color: var(--color-error);
    border: 1px solid rgba(230, 57, 70, 0.2);
}

/* Animation de mise à jour des valeurs */
.value-updating {
    animation: valueUpdate 0.2s ease-out;
}

@keyframes valueUpdate {
    0% { background-color: var(--color-secondary-light); }
    100% { background-color: transparent; }
}

/* Animation de calcul mis à jour */
.calculation-updated {
    animation: calculationPulse 0.4s ease-out;
}

@keyframes calculationPulse {
    0% { 
        transform: scale(1);
        background-color: transparent;
    }
    50% { 
        transform: scale(1.02);
        background-color: rgba(147, 233, 190, 0.1);
    }
    100% { 
        transform: scale(1);
        background-color: transparent;
    }
}

/* Messages de la calculatrice */
.calculator-message {
    font-family: var(--font-primary);
    font-size: var(--font-size-sm);
    line-height: 1.4;
}

/* Section résultats */
.tax-breakdown {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
}

.tax-details .result-row {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
}

.total-row {
    border-top: 2px solid var(--color-border);
    padding-top: var(--space-md);
    margin-top: var(--space-sm);
    font-weight: 600;
    font-size: var(--font-size-lg);
}

/* Pourboires */
.tip-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.tip-button {
    padding: var(--space-md);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tip-button:hover {
    border-color: var(--color-primary);
    background: var(--color-bg);
}

.tip-button.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Range slider */
.range-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-md);
}

.range-value {
    min-width: 2ch;
    text-align: center;
    font-weight: 600;
}

/* Per person result */
.per-person {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    background: var(--color-secondary-light);
    border-radius: var(--radius-md);
    font-size: var(--font-size-lg);
    font-weight: 600;
}

/* Actions */
.actions-section {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-xl);
}

.actions-section .btn {
    flex: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-md);
}

.modal-content {
    background: var(--color-surface-elevated);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 480px;
    width: 100%;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: none;
    border: none;
    font-size: var(--font-size-2xl);
    color: var(--color-text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--color-surface);
}

.modal h3 {
    margin: 0 0 var(--space-xl) 0;
    font-size: var(--font-size-xl);
}

.share-link-wrapper {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.share-link-wrapper input {
    flex: 1;
}

.share-success {
    color: var(--color-success);
    font-size: var(--font-size-sm);
    text-align: center;
    margin-top: var(--space-md);
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Footer */
.app-footer {
    margin-top: auto;
    padding: var(--space-xl) 0;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.app-footer a {
    color: var(--color-primary);
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* Améliorations visuelles pour la nouvelle interface */
.main-calculator .form-group:first-child {
    margin-bottom: var(--space-2xl);
}

.calculator-grid .form-group:first-child .input-wrapper,
.calculator-grid .form-group:last-child .input-wrapper {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.calculator-grid .form-group:last-child {
    margin-top: var(--space-lg);
}

.total-amount {
    border-color: var(--color-secondary);
}

.total-amount:focus {
    border-color: var(--color-secondary-dark);
    box-shadow: 0 0 0 3px rgba(147, 233, 190, 0.2);
}

/* Responsive */
@media (max-width: 640px) {
    .calculator-app {
        padding: var(--space-sm);
    }
    
    .card {
        padding: var(--space-lg);
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Responsive */
@media (max-width: 640px) {
    .calculator-app {
        padding: var(--space-sm);
    }
    
    .card {
        padding: var(--space-lg);
    }
    
    .app-header h1 {
        font-size: var(--font-size-xl);
    }
    
    .actions-section {
        flex-direction: column;
    }
    
    .actions-section .btn {
        width: 100%;
    }
}

/* Accessibilité */
:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 3px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles - Optimisé pour impression de la calculatrice */
@media print {
    /* Masquer les éléments non nécessaires */
    .theme-toggle,
    .actions-section,
    .app-footer,
    .app-header h1::after,
    #print-btn,
    #reset-btn,
    .tip-presets,
    .range-wrapper input[type="range"],
    .range-value::before {
        display: none !important;
    }
    
    /* Reset général pour l'impression */
    * {
        background: transparent !important;
        color: black !important;
    }
    
    body {
        margin: 0;
        padding: 0;
        font-size: 12pt;
        line-height: 1.5;
        background: white !important;
    }
    
    /* Container principal */
    .calculator-app {
        max-width: 100%;
        margin: 0;
        padding: 20px;
    }
    
    /* Header simplifié */
    .app-header {
        background: none !important;
        border-bottom: 2px solid #333;
        padding: 10px 0;
        margin-bottom: 20px;
    }
    
    .app-header h1 {
        font-size: 18pt;
        color: black !important;
        text-align: center;
        margin: 0;
    }
    
    /* Cards et sections */
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 20px;
        padding: 15px;
    }
    
    .card h2 {
        font-size: 14pt;
        margin-bottom: 10px;
        border-bottom: 1px solid #ccc;
        padding-bottom: 5px;
    }
    
    /* Formulaires */
    .form-group {
        margin-bottom: 10px;
    }
    
    .form-group label {
        font-weight: bold;
        color: black !important;
    }
    
    input, select {
        border: 1px solid #999 !important;
        background: white !important;
        padding: 5px;
        color: black !important;
    }
    
    input[readonly] {
        background: #f0f0f0 !important;
        font-weight: bold;
    }
    
    /* Montants et résultats */
    .currency-symbol {
        color: black !important;
    }
    
    .total-amount {
        font-size: 14pt;
        font-weight: bold;
        border: 2px solid #333 !important;
    }
    
    /* Résultats de calcul */
    .tip-result,
    .split-result {
        background: #f9f9f9 !important;
        border: 1px solid #999;
        padding: 10px;
        margin-top: 10px;
    }
    
    .result-row {
        display: flex;
        justify-content: space-between;
        padding: 5px 0;
        border-bottom: 1px solid #ddd;
    }
    
    .result-row:last-child {
        border-bottom: none;
    }
    
    .total-row {
        font-weight: bold;
        font-size: 12pt;
        border-top: 2px solid #333;
        margin-top: 5px;
        padding-top: 10px;
    }
    
    /* Pour le nombre de personnes */
    .range-value {
        font-size: 16pt;
        font-weight: bold;
        margin-left: 10px;
    }
    
    /* Optimisation de l'espace */
    .calculator-grid {
        display: block;
    }
    
    .tax-display-group {
        margin: 10px 0;
        padding: 10px;
        background: #f5f5f5 !important;
        border: 1px solid #ddd;
    }
    
    /* Forcer les sauts de page appropriés */
    .main-calculator {
        page-break-after: auto;
    }
    
    .tip-section,
    .split-section {
        page-break-before: auto;
    }
    
    /* Date d'impression */
    .app-header::after {
        content: "Imprimé le " attr(data-date);
        display: block;
        font-size: 10pt;
        text-align: right;
        color: #666 !important;
        margin-top: 5px;
    }
}