/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 2px;
}

/* Form sections */
.form-section {
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-left: 4px solid #667eea;
}

.form-section h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 500;
}

/* Form grid for company information */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input[type="file"] {
    padding: 8px;
    border: 2px dashed #667eea;
    border-radius: 5px;
    background: #f8f9ff;
}

.form-group small {
    color: #6c757d;
    font-size: 0.85rem;
    margin-top: 5px;
    display: block;
}

/* Costs container */
.costs-container {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.costs-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 80px;
    gap: 15px;
    margin-bottom: 15px;
    font-weight: 600;
    color: #555;
    padding-bottom: 10px;
    border-bottom: 2px solid #dee2e6;
}

.cost-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 80px;
    gap: 15px;
    margin-bottom: 10px;
    align-items: center;
}

.cost-row input {
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 0.9rem;
}

.cost-row input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.cost-row input[readonly] {
    background-color: #e9ecef;
    cursor: not-allowed;
}

.remove-row {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.remove-row:hover {
    background: #c82333;
}

/* Add row button */
.add-row-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    margin: 15px 0;
    transition: background-color 0.3s ease;
}

.add-row-btn:hover {
    background: #218838;
}

/* Section totals */
.section-total {
    text-align: right;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 5px;
    font-size: 1.1rem;
    color: #667eea;
}

/* Grand total */
.grand-total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.grand-total h2 {
    color: white;
    margin-bottom: 15px;
}

.total-breakdown {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
}

.total-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 5px;
    min-width: 250px;
    font-size: 1.1rem;
}

/* Generate button */
.generate-btn {
    width: 100%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .costs-header,
    .cost-row {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: left;
    }
    
    .costs-header {
        display: none; /* Hide header on mobile, rely on placeholders */
    }
    
    .cost-row {
        background: white;
        padding: 15px;
        border-radius: 8px;
        margin-bottom: 15px;
        border: 1px solid #dee2e6;
    }
    
    .cost-row input {
        margin-bottom: 10px;
    }
    
    .remove-row {
        justify-self: end;
        margin-top: 10px;
    }
    
    .total-breakdown {
        flex-direction: column;
        align-items: center;
    }
    
    .total-line {
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    .form-section {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .costs-container {
        padding: 15px;
    }
}

/* Loading state */
.generate-btn.loading {
    background: #6c757d;
    cursor: not-allowed;
    position: relative;
}

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

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