/* --- GOOGLE FONT --- */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');

/* --- BIẾN MÀU & RESET --- */
:root {
    --primary-color: #005A9E;
    --secondary-color: #4A90E2;
    --danger-color: #d73a49;
    --background-color: #f7f9fc;
    --panel-background: #ffffff;
    --border-color: #e1e4e8;
    --text-primary: #24292e;
    --text-secondary: #586069;
    --text-light: #ffffff;
    --result-text: #005A9E;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.07);
    --border-radius: 8px;
}
* { box-sizing: border-box; }

/* --- LAYOUT CHÍNH --- */
/* --- MAIN LAYOUT --- */
.steel-calculator-wrapper {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Responsive layout */
@media (max-width: 768px) {
    .steel-calculator-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 15px;
    }
    
    .result-value {
        font-size: 36px;
    }
    
    .calculator-form-panel,
    .calculator-result-panel {
        padding: 20px;
    }
    
    .result-info-item {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }
}

/* --- PANEL BÊN TRÁI: FORM --- */
.calculator-form-panel {
    background: var(--panel-background);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

/* --- PANEL BÊN PHẢI: RESULT --- */
.calculator-result-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.form-header h2 {
    font-size: 24px;
    color: var(--primary-color);
    margin: 0 0 5px 0;
}
.form-header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 25px 0;
}
.calculator-section {
    border: none;
    border-top: 1px solid var(--border-color);
    padding: 25px 0 0 0;
    margin: 25px 0 0 0;
}
.calculator-section legend {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    padding-right: 15px;
}
.form-group {
    margin-bottom: 12px;
}
.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}
.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    background-color: #fff;
    font-weight: 500;
}

.form-control:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.15);
    background-color: #fbfcff;
}

.form-control:hover:not(:focus) {
    border-color: #c6c9cc;
}
/* SỬA LỖI UI: Tăng chiều cao cho ô select */
select.form-control {
    height: 48px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23586069'%3E%3Cpath d='M6 9L.5 3h11L6 9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding: 0 40px 0 16px; /* Fix padding: loại bỏ top/bottom, chỉ giữ left/right */
}
/* Đánh dấu ô nhập bị lỗi */
.form-control.is-invalid {
    border-color: var(--danger-color);
    background-color: #fff5f5;
    animation: inputError 0.3s ease;
}

@keyframes inputError {
    0%, 100% { transform: translateX(0); }
    25%, 75% { transform: translateX(-2px); }
    50% { transform: translateX(2px); }
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 4px rgba(215, 58, 73, 0.15);
}

.form-control.has-value {
    border-color: #28a745;
    background-color: #f8fff9;
}

.form-control.has-value:focus {
    box-shadow: 0 0 0 4px rgba(40, 167, 69, 0.15);
}

/* --- THIẾT KẾ RADIO BUTTONS DẠNG VIÊN THUỐC --- */
.radio-group-pills { display: flex; border: 1px solid var(--border-color); border-radius: 6px; overflow: hidden; }
.radio-group-pills label { flex: 1; text-align: center; margin: 0; padding: 10px; background: #fff; color: var(--text-secondary); cursor: pointer; transition: background 0.2s, color 0.2s; }
.radio-group-pills label:not(:last-child) { border-right: 1px solid var(--border-color); }
.radio-group-pills input[type="radio"] { display: none; }
.radio-group-pills input[type="radio"]:checked + span { color: var(--text-light); }
.radio-group-pills label:has(input:checked) { background: var(--secondary-color); color: var(--text-light); }

/* --- PANEL BÊN PHẢI: KẾT QUẢ --- */
.calculator-result-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--panel-background);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.result-content {
    margin-bottom: 20px;
}

.result-info {
    background: rgba(248, 249, 250, 0.8);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-top: 15px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Result info panel */
.result-info {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 25px;
    margin-top: 25px;
    display: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.4s ease-out;
}

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

.result-info-title {
    font-size: 18px;
    font-weight: 700;
    color: #333333;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #dee2e6;
    display: flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-info-title::before {
    content: '📊';
    margin-right: 10px;
    font-size: 20px;
}

.result-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

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

.result-info-item:hover {
    background-color: #f8f9fa;
    padding-left: 10px;
    padding-right: 10px;
    border-radius: 8px;
    margin: 0 -10px;
}

.result-info-label {
    color: #455a64;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.3px;
}

.result-info-value {
    color: #000000;
    font-weight: 700;
    font-size: 15px;
    background: #f8f9fa;
    padding: 8px 16px;
    border: 1px solid #dee2e6;
    box-shadow: none;
    min-width: 90px;
    text-align: center;
    transition: all 0.3s ease;
}

/* Hover effects removed for simpler design */

/* --- RESULT DISPLAY --- */

.result-display-card { 
    width: 100%; 
    text-align: center; 
    background: #ffffff;
    padding: 30px; 
    border-radius: 16px; 
    border: 2px solid #e0e0e0; 
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.result-display-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    transition: left 0.5s ease;
}

.result-display-card.has-result::before {
    left: 0;
}

/* Hover effects removed for simpler design */

.result-label { 
    font-size: 16px; 
    color: #333333; 
    margin: 0 0 18px 0; 
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.result-value { 
    font-size: 52px; 
    font-weight: 900; 
    color: #000000; 
    line-height: 1; 
    transition: all 0.3s ease;
    text-shadow: none;
}

.result-unit { 
    font-size: 22px; 
    color: #666666; 
    margin-left: 10px; 
    font-weight: 700;
    transition: color 0.2s; 
}

/* CSS cho trạng thái lỗi của kết quả */
.result-display-card.has-error {
    border-color: var(--danger-color);
    background: linear-gradient(135deg, #fff5f5 0%, #fed7d7 100%);
}

.result-display-card.has-error .result-value {
    color: var(--danger-color);
    font-size: 32px;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 20%, 50%, 80%, 100% { transform: translateX(0); }
    10%, 30%, 70%, 90% { transform: translateX(-5px); }
    40%, 60% { transform: translateX(5px); }
}

.result-display-card.has-error .result-unit {
    font-size: 14px;
    color: var(--danger-color);
    margin-left: 0;
    display: block;
    margin-top: 8px;
}

/* Loading state */
.result-display-card.loading .result-value {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Number formatting improvements */
.result-value.large-number {
    font-size: 42px;
}

.result-value.small-number {
    font-size: 54px;
}

/* Highlight effect khi có kết quả mới */
.result-display-card.updated {
    animation: highlight 0.6s ease-out;
}

@keyframes highlight {
    0% { background: linear-gradient(135deg, #e6f3ff 0%, #cce7ff 100%); }
    100% { background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%); }
}
