:root {
    --primary-color: #00B2B2;
    --secondary-color: #007A7A;
    --background-color: #f5f7fa;
    --text-color: #2d3748;
    --card-background: #ffffff;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --primary-color: #00D1D1;
    --secondary-color: #00B2B2;
    --background-color: #1a202c;
    --text-color: #e2e8f0;
    --card-background: #2d3748;
    --border-color: #4a5568;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    padding-top: 4rem;
}

.top-controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3rem;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    background: var(--background-color);
    border-bottom: 1px solid var(--border-color);
}

.calculator-card {
    background: var(--card-background);
    border-radius: 15px;
    padding: 1.2rem;
    box-shadow: 0 4px 6px var(--shadow-color);
    margin-top: 1rem;
    width: 100%;
}

.logo {
    text-align: center;
    margin: 1rem 0 2rem 0;
    padding-top: 0.5rem;
}

.logo img {
    max-width: 140px;
    height: auto;
    display: block;
    margin: 0 auto;
}

h1, h2 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.form-group {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    position: relative;
    margin-bottom: 0.5rem;
}

.input-group:not(.tva-switch-label) input {
    padding: 0.8rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: var(--card-background);
    color: var(--text-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button {
    opacity: 1;
    margin-right: 10px;
    height: 38px;
    position: relative;
    top: 1px;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 178, 178, 0.1);
}

.input-group:not(:last-child)::after {
    content: "€";
    position: absolute;
    right: 2.5rem;
    bottom: 0.8rem;
    color: var(--text-color);
    opacity: 0.5;
}

.input-group:nth-child(2)::after {
    content: "%";
}

.input-group:last-child::after {
    content: none;
}

.calculate-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1.2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 6px rgba(0, 178, 178, 0.2);
}

.calculate-btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 178, 178, 0.3);
}

.calculate-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 178, 178, 0.2);
}

.calculate-btn i {
    font-size: 1.2rem;
}

.results {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
}

.results.visible {
    display: flex;
}

.results-row {
    display: grid;
    gap: 0.8rem;
    grid-template-columns: 1fr;
}

.top-row {
    grid-template-columns: repeat(3, 1fr);
}

.bottom-row {
    grid-template-columns: 1fr;
}

.result-card {
    background: var(--card-background);
    padding: 1rem;
    border-radius: 15px;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.result-card:hover {
    transform: translateY(-2px);
}

.result-card h3 {
    color: var(--text-color);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.result-card p {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.highlight, .result-card:last-child {
    background: var(--primary-color);
    border: none;
    box-shadow: 0 4px 6px rgba(0, 178, 178, 0.2);
}

.highlight:hover, .result-card:last-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 178, 178, 0.3);
}

.highlight h3, .result-card:last-child h3,
.highlight p, .result-card:last-child p {
    color: white;
}

.highlight h3, .result-card:last-child h3 {
    opacity: 0.9;
}

.full-width {
    grid-column: 1 / -1;
    padding: 1.5rem;
}

/* Top Controls */
.theme-switch {
    position: relative;
    width: 60px;
    height: 30px;
    cursor: pointer;
}

.theme-switch .slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f0f0f0;
    border-radius: 30px;
    cursor: pointer;
    transition: 0.4s;
}

.theme-switch .slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.4s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.theme-switch .fa-sun {
    position: absolute;
    left: 8px;
    top: 6px;
    color: #f1c40f;
    z-index: 1;
    font-size: 14px;
}

.theme-switch .fa-moon {
    position: absolute;
    right: 8px;
    top: 6px;
    color: #f1c40f;
    z-index: 1;
    font-size: 14px;
}

[data-theme="dark"] .theme-switch .slider {
    background: #2c3e50;
}

[data-theme="dark"] .theme-switch .slider:before {
    transform: translateX(30px);
}

/* History Toggle Button */
.history-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.history-toggle:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.history-toggle i {
    font-size: 1.2rem;
}

/* TVA Switch Styles */
.tva-switch-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.fancy-switch {
    position: relative;
    width: 46px;
    height: 24px;
}

.fancy-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.fancy-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #edf2f7;
    transition: .4s;
    border-radius: 24px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.fancy-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#tvaSwitch:checked + .fancy-slider {
    background-color: var(--primary-color);
}

#tvaSwitch:checked + .fancy-slider:before {
    transform: translateX(22px);
}

#tvaSwitch:focus + .fancy-slider {
    box-shadow: 0 0 1px var(--primary-color);
}

/* History Panel Styles */
.history-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100vh;
    background: var(--background-color);
    padding: 1rem;
    transition: right 0.3s ease;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    z-index: 1000;
}

.history-panel.visible {
    right: 0;
}

.history-panel h2 {
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 3rem;
}

.history-item {
    background: var(--card-background);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.history-item:hover {
    transform: translateY(-2px);
    transition: transform 0.2s ease;
    background-color: #f5f5f5;
}

[data-theme='dark'] .history-item:hover {
    background-color: rgba(255, 107, 0, 0.2);
}

.history-date {
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

.history-content p {
    margin: 0.3rem 0;
}

.history-content p strong {
    color: var(--primary-color);
    font-weight: 500;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-history {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.close-history:hover {
    opacity: 1;
    transform: scale(1.1);
}

.close-history:active {
    transform: scale(0.95);
}

/* Tablette (768px et plus) */
@media (min-width: 768px) {
    .container {
        padding: 1.5rem;
    }

    .calculator-card {
        padding: 1.5rem;
    }

    .logo img {
        max-width: 160px;
    }

    .history-panel {
        width: 280px;
        right: -280px;
    }

    .top-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .result-card {
        padding: 1.2rem;
    }
}

/* Desktop (1024px et plus) */
@media (min-width: 1024px) {
    .container {
        padding: 2rem;
    }

    .calculator-card {
        padding: 2rem;
    }

    .logo img {
        max-width: 180px;
    }

    .history-panel {
        width: 300px;
        right: -300px;
    }

    .result-card {
        padding: 1.5rem;
    }
}

/* Ajustements pour le mode sombre sur mobile */
@media (max-width: 767px) {
    [data-theme="dark"] .top-controls {
        background: var(--background-color);
        border-bottom: 1px solid var(--border-color);
    }

    [data-theme="dark"] .history-panel {
        background: var(--background-color);
    }

    [data-theme="dark"] .history-item {
        background: var(--card-background);
        border: 1px solid var(--border-color);
    }
}
