/* Reset et variables CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    text-align: center;
    padding: 3rem 0 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Sections */
.input-section,
.options-section,
.results-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.input-section h2,
.options-section h2,
.results-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Dimensions Grid */
.dimensions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.input-group input,
.input-group select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: all 0.2s ease;
    background: var(--surface-color);
    width: 100%;
    box-sizing: border-box;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* Surface Info */
.surface-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.surface-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius-sm);
    text-align: center;
}

.surface-card h3 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.surface-card p {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Calculate Button */
.calculate-section {
    text-align: center;
    margin: 2rem 0;
}

.calculate-btn {
    background: linear-gradient(135deg, var(--accent-color), #d97706);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 48px;
    touch-action: manipulation;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.calculate-btn:active {
    transform: translateY(0);
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    transition: all 0.2s ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Amélioration pour les écrans tactiles */
@media (hover: none) and (pointer: coarse) {
    .result-card:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }
    
    .calculate-btn:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }
    
    .calculate-btn:active {
        transform: scale(0.98);
        box-shadow: var(--shadow-sm);
    }
}

.result-card.primary {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
}

.card-header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.result-card.primary .card-header {
    background: var(--primary-dark);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-content {
    padding: 1.5rem;
}

.card-content p {
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-content p:last-child {
    margin-bottom: 0;
}

/* Summary Section */
.summary-section {
    margin-top: 2rem;
}

.summary-card {
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
}

.summary-card h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

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

.cost-item.total {
    font-size: 1.2rem;
    padding-top: 1rem;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 3rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        max-width: 95%;
        padding: 0 15px;
    }
    
    .results-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1rem;
    }
    
    .dimensions-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    
    .options-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header {
        padding: 2rem 0 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .header h1 {
        font-size: 2rem;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }
    
    .header p {
        font-size: 1rem;
        padding: 0 10px;
    }
    
    .input-section,
    .options-section,
    .results-section {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .input-section h2,
    .options-section h2,
    .results-section h2 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    
    .dimensions-grid,
    .options-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .surface-info {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .surface-card {
        padding: 1rem;
    }
    
    .surface-card h3 {
        font-size: 0.8rem;
    }
    
    .surface-card p {
        font-size: 1.3rem;
    }
    
    .card-content {
        padding: 1rem;
    }
    
    .card-content p {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .summary-card {
        padding: 1.5rem;
    }
    
    .summary-card h3 {
        font-size: 1.3rem;
    }
    
    .cost-item {
        font-size: 0.9rem;
        padding: 0.5rem 0;
    }
    
    .cost-item.total {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .header {
        padding: 1.5rem 0 1rem;
        border-radius: 0 0 8px 8px;
    }
    
    .header h1 {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 0.5rem;
        line-height: 1.2;
    }
    
    .header p {
        font-size: 0.9rem;
        padding: 0 5px;
    }
    
    .input-section,
    .options-section,
    .results-section {
        padding: 1rem;
        border-radius: 8px;
    }
    
    .input-section h2,
    .options-section h2,
    .results-section h2 {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
    }
    
    .input-group input,
    .input-group select {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }
    
    .input-group label {
        font-size: 0.8rem;
    }
    
    .calculate-btn {
        width: 100%;
        justify-content: center;
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
    }
    
    .card-header h3 {
        font-size: 1rem;
    }
    
    .card-content {
        padding: 0.75rem;
    }
    
    .card-content p {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }
    
    .summary-card {
        padding: 1rem;
    }
    
    .summary-card h3 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .cost-item {
        font-size: 0.8rem;
        padding: 0.4rem 0;
    }
    
    .cost-item.total {
        font-size: 1rem;
        padding-top: 0.75rem;
    }
    
    .footer {
        padding: 1.5rem 0;
        font-size: 0.8rem;
    }
}

@media (max-width: 360px) {
    .header h1 {
        font-size: 1.3rem;
    }
    
    .header p {
        font-size: 0.8rem;
    }
    
    .input-section,
    .options-section,
    .results-section {
        padding: 0.75rem;
    }
    
    .card-content p {
        font-size: 0.75rem;
    }
    
    .calculate-btn {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
    }
}

/* Orientation paysage sur mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 1rem 0;
    }
    
    .header h1 {
        font-size: 1.5rem;
        flex-direction: row;
    }
    
    .main-content {
        gap: 1rem;
    }
    
    .input-section,
    .options-section,
    .results-section {
        padding: 1rem;
    }
    
    .dimensions-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .options-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Amélioration pour les écrans haute densité */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .result-card {
        border-width: 0.5px;
    }
    
    .input-group input,
    .input-group select {
        border-width: 1px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.results-section {
    animation: fadeIn 0.5s ease-out;
}

.result-card {
    animation: slideIn 0.3s ease-out;
}

.result-card:nth-child(1) { animation-delay: 0.1s; }
.result-card:nth-child(2) { animation-delay: 0.2s; }
.result-card:nth-child(3) { animation-delay: 0.3s; }
.result-card:nth-child(4) { animation-delay: 0.4s; }
.result-card:nth-child(5) { animation-delay: 0.5s; }
.result-card:nth-child(6) { animation-delay: 0.6s; }

/* Loading state */
.calculate-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.calculate-btn.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility classes */
.text-center {
    text-align: center;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mt-2 {
    margin-top: 1rem;
}

.hidden {
    display: none;
}

.visible {
    display: block;
}
