:root {
    --primary: #1a1a2e;
    --primary-light: #16213e;
    --secondary: #0f3460;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --success: #00d9a5;
    --success-hover: #00b894;
    --warning: #ffc107;
    --danger: #ff4757;
    --danger-hover: #ff6b81;
    --light: #f8f9fa;
    --lighter: #ffffff;
    --dark: #2d3436;
    --gray: #636e72;
    --gray-light: #b2bec3;
    --border: #e1e8ed;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 20px 60px rgba(0, 0, 0, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    max-width: 960px;
    margin: 0 auto;
    padding: 30px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    background: var(--lighter);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 40px 30px;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.product-visual-container {
    margin-bottom: 30px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    position: relative;
    height: 300px;
    background: #f0f0f0;
    transition: var(--transition);
}

.product-visual-container:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.product-visual-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.product-visual-container:hover img {
    transform: scale(1.03);
}

.product-visual-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: white;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--transition);
}

.product-visual-container:hover .product-visual-overlay {
    opacity: 1;
    transform: translateY(0);
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.logo {
    width: min(200px, 60vw);
    height: auto;
    display: block;
    margin: 0 auto 20px;
    object-fit: contain;
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
    transition: var(--transition);
    /* Inverser les couleurs pour transformer le logo blanc en noir */
    filter: invert(1);
}

.logo:hover {
    transform: scale(1.05);
    background: white;
}

h1 {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
}

.header p {
    margin: 0 0 20px;
    opacity: 0.9;
    font-weight: 300;
    position: relative;
    z-index: 1;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    backdrop-filter: blur(5px);
    margin: 5px;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.calculator-form {
    padding: 30px;
}

.form-group {
    margin-bottom: 24px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group.half {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}

select,
input[type="number"],
input[type="text"],
input[type="email"],
input[type="tel"] {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--lighter);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23636e72' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 45px;
}


/* Premium Form Focus */
select:focus,
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(233, 69, 96, 0.15);
    background: white;
}

/* Card Elevation */
.data-card,
.stat-card {
    transition: var(--transition);
}

.data-card:hover,
.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.checkbox-container {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    cursor: pointer;
    padding: 12px 16px;
    background: var(--light);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.checkbox-container:hover {
    background: #eef1f5;
}

.checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: var(--accent);
}

.checkbox-container label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
}

.result {
    margin-top: 30px;
    border-radius: var(--radius);
    overflow: hidden;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    animation: slideUp 0.4s ease-out;
}

.result-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 18px 24px;
}

.result-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.result-body {
    padding: 24px;
    background: var(--light);
}

.price-display {
    font-size: 36px;
    font-weight: 700;
    color: var(--success);
    text-align: center;
    margin: 0 0 20px;
    padding: 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 15px rgba(0, 217, 165, 0.15);
}

.price-details {
    background: white;
    padding: 20px;
    border-radius: var(--radius-sm);
}

.price-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.price-row:last-child {
    border-bottom: none;
}

.price-row.total {
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    margin-top: 12px;
    padding-top: 16px;
    border-top: 2px solid var(--accent);
    border-bottom: none;
}

.btn-add-to-cart,
.btn-pdf,
.btn-clear-cart,
.cart-item-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-add-to-cart {
    background: linear-gradient(135deg, var(--success) 0%, #00b894 100%);
    color: white;
    padding: 14px 28px;
    font-size: 15px;
    margin-top: 20px;
    width: 100%;
    box-shadow: 0 4px 15px rgba(0, 217, 165, 0.3);
}

.btn-add-to-cart:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 217, 165, 0.4);
}

.btn-add-to-cart:disabled {
    background: var(--gray-light);
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.pdf-button-container {
    text-align: center;
    margin: 25px 0 10px;
    padding-top: 25px;
    border-top: 2px dashed var(--border);
}

.btn-pdf {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 14px 28px;
    font-size: 15px;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 4px 15px rgba(26, 26, 46, 0.3);
}

.btn-pdf:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(26, 26, 46, 0.4);
}

.btn-pdf:disabled {
    background: var(--gray-light);
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.7;
}

.cart-container {
    margin: 30px 0;
    padding: 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--accent);
}

.cart-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.cart-count {
    background: linear-gradient(135deg, var(--accent) 0%, #ff6b6b 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.cart-items {
    margin-bottom: 20px;
}

.cart-item {
    background: white;
    padding: 18px;
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.cart-item:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transform: translateX(5px);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
}

.cart-item-details {
    font-size: 13px;
    color: var(--gray);
}

.cart-item-price {
    font-weight: 700;
    color: var(--success);
    margin-right: 15px;
    font-size: 16px;
}

.cart-item-remove {
    background: transparent;
    color: var(--danger);
    border: 2px solid var(--danger) !important;
    padding: 6px 12px;
    font-size: 12px;
}

.cart-item-remove:hover {
    background: var(--danger);
    color: white;
}

.cart-empty {
    text-align: center;
    color: var(--gray);
    padding: 40px 20px;
    font-style: italic;
    background: white;
    border-radius: var(--radius-sm);
    border: 2px dashed var(--border);
}

.cart-total {
    background: white;
    padding: 18px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.btn-clear-cart {
    background: linear-gradient(135deg, var(--danger) 0%, #ff6b81 100%);
    color: white;
    padding: 8px 16px;
    font-size: 12px;
    margin-left: 15px;
}

.btn-clear-cart:hover {
    transform: translateY(-2px);
}

.history-container {
    margin: 30px 0;
    padding: 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #3498db;
}

.history-title {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
}

.history-count {
    background: #3498db;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
}

.history-items {
    margin-bottom: 20px;
}

.history-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item-info {
    flex: 1;
}

.history-item-number {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.history-item-details {
    font-size: 14px;
    color: #666;
}

.history-item-amount {
    font-weight: bold;
    color: #27ae60;
    margin-right: 15px;
}

.history-empty {
    text-align: center;
    color: #666;
    padding: 20px;
    font-style: italic;
}


/* Styles pour les messages d'erreur */
.error-message {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 5px;
    display: none;
    align-items: center;
    gap: 5px;
}

.error-message.show {
    display: flex;
}

.error-icon {
    font-size: 14px;
}

.input-error {
    border-color: #e74c3c !important;
    background-color: #fdf2f2 !important;
}

/* Color selector styles */
.color-selector-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-selector-row select {
    flex: 1;
}

.color-preview {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: #f0f0f0;
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

#color-options {
    background: var(--light);
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

#color-options .form-row {
    margin-bottom: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group.half {
        width: 100%;
    }

    /* Premium Modal Styles */
    .modal {
        display: none;
        position: fixed;
        z-index: 1000;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        overflow: auto;
        background-color: rgba(26, 26, 46, 0.6);
        backdrop-filter: blur(5px);
        animation: fadeIn 0.3s;
    }

    .modal-content {
        background-color: #fefefe;
        margin: 5% auto;
        padding: 0;
        border: 1px solid #888;
        width: 90%;
        max-width: 500px;
        border-radius: var(--radius);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        overflow: hidden;
        animation: slideUpModal 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .modal-header {
        padding: 20px 24px;
        background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
        color: white;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .modal-header h2 {
        margin: 0;
        font-size: 1.25rem;
        font-weight: 600;
    }

    .close-modal {
        color: rgba(255, 255, 255, 0.8);
        font-size: 28px;
        font-weight: bold;
        cursor: pointer;
        line-height: 1;
        transition: var(--transition);
    }

    .close-modal:hover {
        color: white;
        transform: rotate(90deg);
    }

    .modal-body {
        padding: 24px;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {}
    }

    @keyframes slideUpModal {
        from {
            transform: translateY(50px);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* App Top Bar */
    .app-top-bar {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
        padding: 12px 24px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 20px;
        border-radius: var(--radius);
        margin-top: 20px;
        /* Slight offset if not full width */
    }


    @media (max-width: 600px) {
        .app-top-bar {
            flex-direction: column;
            gap: 15px;
            text-align: center;
        }
    }

    /* RTL Support for Hebrew */
    html[dir="rtl"] .cart-item-price {
        margin-right: 0;
        margin-left: 15px;
    }

    html[dir="rtl"] select {
        background-position: left 12px center;
        padding-right: 18px;
        padding-left: 45px;
    }

    html[dir="rtl"] .checkbox-container input[type="checkbox"] {
        margin-right: 0;
        margin-left: 12px;
    }

    html[dir="rtl"] .btn-clear-cart {
        margin-left: 0;
        margin-right: 15px;
    }

    html[dir="rtl"] .header {
        text-align: center; 
    }

    .user-welcome {
        color: white;
        font-size: 0.95rem;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .app-actions {
        display: flex;
        gap: 12px;
    }

    .action-btn {
        padding: 8px 18px;
        border-radius: 30px;
        cursor: pointer;
        font-size: 0.85rem;
        font-weight: 500;
        transition: var(--transition);
        display: inline-flex;
        align-items: center;
        gap: 8px;
        border: none;
        font-family: inherit;
    }

    .action-btn.outline {
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.3);
        color: white;
    }

    .action-btn.outline:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: translateY(-2px);
    }

    .action-btn.primary {
        background: var(--accent);
        color: white;
        box-shadow: 0 4px 10px rgba(233, 69, 96, 0.3);
    }

    .action-btn.primary:hover {
        background: var(--accent-hover);
        transform: translateY(-2px);
        box-shadow: 0 6px 15px rgba(233, 69, 96, 0.4);
    }

    /* Toast Notification */
    .toast-container {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 10000;
    }

    .toast {
        background: white;
        color: var(--dark);
        padding: 16px 24px;
        border-radius: var(--radius-sm);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
        margin-bottom: 12px;
        display: flex;
        align-items: center;
        gap: 15px;
        animation: slideInToast 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        border-left: 5px solid var(--accent);
        min-width: 320px;
        max-width: 450px;
        font-weight: 500;
        backdrop-filter: blur(10px);
    }

    .toast.success {
        border-left-color: var(--success);
    }

    .toast.error {
        border-left-color: var(--danger);
    }

    .toast i {
        font-size: 1.2rem;
    }

    @keyframes slideInToast {
        from {
            transform: translateX(100%);
            opacity: 0;
        }

        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    @keyframes fadeOutToast {
        to {
            transform: translateX(100%);
            opacity: 0;
        }
    }
}