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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-light);
    font-size: 14px;
}

.container {
    max-width: 640px;
    margin: 40px auto;
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

/* Header */
header {
    padding: 32px 32px 24px;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.025em;
}

header p {
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 400;
}

/* Form */
.calculator-form {
    padding: 32px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

/* File Upload */
.file-upload {
    position: relative;
}

input[type="file"] {
    width: 100%;
    padding: 16px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--text-secondary);
}

input[type="file"]:hover {
    border-color: var(--primary-color);
    background: #fafbff;
}

input[type="file"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* Select */
select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-white);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

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

/* Form Row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

/* File Management */
.file-item-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.remove-file-btn {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.remove-file-btn:hover {
    background: #b91c1c;
}

.remove-file-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgb(220 38 38 / 0.2);
}

/* Quantity Inputs */
.quantity-input {
    margin-bottom: 12px;
    padding: 16px;
    background: var(--bg-light);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.quantity-input:last-child {
    margin-bottom: 0;
}

.quantity-input label {
    flex: 1;
    margin: 0;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.file-item-wrapper input[type="number"] {
    width: 64px;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    background: var(--bg-white);
    flex-shrink: 0;
}

.file-item-wrapper input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgb(37 99 235 / 0.1);
}



/* Button */
.calculate-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}

.calculate-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.calculate-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.2);
}

.calculate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

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

/* Results */
.results {
    margin-top: 32px;
    padding: 24px 32px 32px;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
}

.results h2 {
    color: var(--success-color);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
}

.result-item {
    background: var(--bg-white);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-item h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.result-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 15px;
}

/* Total Price */
.total-price {
    background: var(--primary-color);
    color: white;
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
    margin-top: 20px;
}

.total-price .price {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
}

.total-price .details {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 500;
}

/* Messages */
.success {
    background: #f0fdf4;
    color: var(--success-color);
    padding: 12px 16px;
    border-radius: var(--radius);
    border-left: 4px solid var(--success-color);
    margin: 16px 0;
    font-weight: 500;
    font-size: 14px;
}

.warning {
    background: #fffbeb;
    color: var(--warning-color);
    padding: 12px 16px;
    border-radius: var(--radius);
    border-left: 4px solid var(--warning-color);
    margin: 16px 0;
    font-weight: 500;
    font-size: 14px;
}

.error {
    background: #fef2f2;
    color: var(--error-color);
    padding: 12px 16px;
    border-radius: var(--radius);
    border-left: 4px solid var(--error-color);
    margin-top: 16px;
    font-weight: 500;
    font-size: 14px;
}

/* Info Badge */
.info-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-light);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* iOS zoom fix */
    }
    
    .container {
        margin: 20px 16px;
        border-radius: var(--radius);
    }
    
    header {
        padding: 24px 20px 20px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    .calculator-form, .results {
        padding: 24px 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .result-details {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .detail-item {
        padding: 12px 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .detail-item:last-child {
        border-bottom: none;
    }
    
    .quantity-input {
        padding: 12px;
    }
    
    .file-item-wrapper input[type="number"] {
        width: 60px;
    }
    
    .file-item-wrapper {
        gap: 8px;
    }
    
    .quantity-input label {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .container {
        margin: 16px 12px;
    }
    
    header {
        padding: 20px 16px 16px;
    }
    
    header h1 {
        font-size: 18px;
    }
    
    .calculator-form, .results {
        padding: 20px 16px;
    }
    
    .total-price .price {
        font-size: 20px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #3b82f6;
        --primary-hover: #2563eb;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-muted: #9ca3af;
        --border-color: #374151;
        --bg-light: #111827;
        --bg-white: #1f2937;
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    }
    
    body {
        background: #0f172a;
    }
    
    input[type="file"]:hover {
        background: #1f2937;
    }
    
    .success {
        background: #064e3b;
        color: #a7f3d0;
    }
    
    .warning {
        background: #92400e;
        color: #fde68a;
    }
    
    .error {
        background: #991b1b;
        color: #fecaca;
    }
} 