/* SD Construction Estimator - ERROR FREE VERSION CSS */

/* Container */
.sd-estimator-container {
    max-width: 100%;
    margin: 20px auto;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

/* Header */
.sd-header {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    padding: 25px;
    text-align: center;
}

.sd-header h2 {
    margin: 0 0 8px 0;
    font-size: 26px;
    font-weight: 700;
}

.sd-header p {
    margin: 5px 0;
    font-size: 14px;
    opacity: 0.9;
}

/* ERROR FREE Notice */
.sd-error-free-notice {
    margin-bottom: 25px;
}

.error-free-alert {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    border: 2px solid #27ae60;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.error-free-alert h4 {
    margin: 0 0 10px 0;
    color: #27ae60;
    font-size: 18px;
    font-weight: 700;
}

.error-free-alert p {
    margin: 5px 0;
    font-size: 14px;
    color: #155724;
}

/* TABS - BOTH GUARANTEED VISIBLE */
.sd-tabs {
    display: flex;
    background: #ecf0f1;
    border-bottom: 3px solid #bdc3c7;
}

.sd-tab {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    color: #7f8c8d;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.sd-tab:hover {
    background: #d5dbdb;
    color: #2c3e50;
}

.sd-tab.active {
    background: white;
    color: #27ae60;
    border-bottom-color: #27ae60;
}

.sd-tab-content {
    display: none;
    padding: 25px;
}

.sd-tab-content.active {
    display: block;
}

/* BUTTONS */
.sd-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.sd-btn-primary {
    background: #3498db;
    color: white;
}

.sd-btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.sd-btn-success {
    background: #27ae60;
    color: white;
}

.sd-btn-success:hover {
    background: #229954;
    transform: translateY(-1px);
}

.sd-btn-warning {
    background: #f39c12;
    color: white;
}

.sd-btn-warning:hover {
    background: #e67e22;
    transform: translateY(-1px);
}

.sd-btn-secondary {
    background: #95a5a6;
    color: white;
}

.sd-btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-1px);
}

/* INPUTS */
.sd-input, .form-input, .steel-input {
    padding: 10px 12px;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    font-size: 14px;
    margin: 2px;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
}

.sd-input:focus, .form-input:focus, .steel-input:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* TOOLBAR */
.sd-toolbar {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.toolbar-left .sd-input {
    width: 250px;
    margin: 0;
}

/* TABLE */
.sd-table-wrapper {
    overflow-x: auto;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    margin-bottom: 20px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.sd-table {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
    background: white;
}

.sd-table th,
.sd-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #ecf0f1;
    text-align: left;
    vertical-align: middle;
}

.sd-table th {
    background: #27ae60;
    color: white;
    font-weight: 700;
    text-align: center;
    font-size: 13px;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 10;
}

.sd-table th small {
    display: block;
    font-size: 11px;
    opacity: 0.9;
    margin-top: 2px;
    font-weight: normal;
}

.sd-table tr:hover {
    background: #f7f9fa;
}

.sd-table tr:nth-child(even) {
    background: #fcfdfd;
}

.sd-table tr:nth-child(even):hover {
    background: #f1f3f4;
}

.steel-delete {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.steel-delete:hover {
    background: #c0392b;
}

/* SUMMARY */
.sd-summary {
    display: flex;
    justify-content: flex-end;
    gap: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    border-radius: 8px;
    margin-bottom: 25px;
    border: 2px solid #27ae60;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.summary-item label {
    color: #155724;
}

.summary-item span {
    color: #27ae60;
    font-size: 18px;
    font-weight: 700;
}

/* FORMULA DISPLAY */
.sd-formula-display {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 50%, #fff3cd 100%);
    border: 2px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.sd-formula-display h4 {
    margin: 0 0 15px 0;
    color: #856404;
    font-size: 18px;
    font-weight: 700;
}

.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
    font-size: 14px;
}

.formula-grid div {
    background: rgba(255, 255, 255, 0.7);
    padding: 8px 12px;
    border-radius: 4px;
    color: #856404;
}

.formula-note-corrected {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    padding: 15px;
    border-radius: 6px;
    font-size: 14px;
    color: #155724;
    border: 2px solid #27ae60;
    text-align: center;
    font-weight: 600;
}

/* CALCULATORS NOTICE */
.sd-calculators-notice {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    border: 2px solid #27ae60;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: center;
}

.sd-calculators-notice h3 {
    margin: 0 0 10px 0;
    color: #27ae60;
    font-size: 20px;
}

.sd-calculators-notice p {
    margin: 0;
    color: #155724;
    font-size: 14px;
}

/* CALCULATORS GRID - ALL 7 VISIBLE */
.sd-calculators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.sd-calculator-card {
    background: white;
    border: 2px solid #ecf0f1;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.sd-calculator-card:hover {
    border-color: #3498db;
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.sd-calculator-card.steel-card {
    border-color: #27ae60;
    background: linear-gradient(135deg, #ffffff 0%, #f8fff8 100%);
}

.sd-calculator-card.steel-card:hover {
    border-color: #229954;
    box-shadow: 0 10px 30px rgba(39, 174, 96, 0.2);
}

.calc-status {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #27ae60;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.calc-icon {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

.sd-calculator-card h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 700;
}

.sd-calculator-card p {
    margin: 0 0 20px 0;
    color: #7f8c8d;
    font-size: 14px;
}

/* EXPORT SECTION */
.sd-export-section {
    border-top: 2px solid #dee2e6;
    padding-top: 25px;
}

.sd-export-section h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 20px;
}

.export-working-notice {
    background: #e8f5e8;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 15px;
}

.export-working-notice p {
    margin: 0;
    color: #155724;
    font-size: 14px;
}

.export-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.sd-export-btn {
    padding: 12px 25px;
    border: 2px solid #27ae60;
    border-radius: 6px;
    background: #27ae60;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sd-export-btn:hover {
    background: #229954;
    border-color: #229954;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
}

/* MODAL */
.sd-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.sd-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.sd-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #ecf0f1;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.sd-modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 20px;
}

.sd-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #7f8c8d;
    cursor: pointer;
    transition: color 0.3s ease;
}

.sd-modal-close:hover {
    color: #2c3e50;
}

.sd-modal-body {
    padding: 25px;
}

.sd-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 2px solid #ecf0f1;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

/* FORM ELEMENTS */
.calc-form {
    display: grid;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.form-group label {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
}

/* CALCULATION RESULTS */
.calc-results {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    border-left: 4px solid #27ae60;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.calc-results h4 {
    margin: 0 0 15px 0;
    color: #27ae60;
    font-size: 18px;
}

.results-grid {
    display: grid;
    gap: 10px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    border-bottom: 1px solid rgba(39, 174, 96, 0.2);
}

.result-row.pans-result {
    background: rgba(255, 193, 7, 0.1);
    border-left: 3px solid #ffc107;
}

.result-row.weight-result {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid #3498db;
}

.result-row.volume-result {
    background: rgba(155, 89, 182, 0.1);
    border-left: 3px solid #9b59b6;
}

.result-label {
    color: #2c3e50;
    font-weight: 500;
}

.result-value {
    color: #27ae60;
    font-weight: 700;
}

.formula-note {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px;
    border-radius: 4px;
    margin-top: 15px;
    font-size: 14px;
    color: #155724;
    border-left: 3px solid #27ae60;
}

.calculation-note {
    background: rgba(255, 255, 255, 0.7);
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    font-style: italic;
    color: #666;
    font-size: 13px;
}

/* MESSAGES */
.sd-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #27ae60;
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 400px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sd-message.error {
    background: #e74c3c;
}

.sd-message.warning {
    background: #f39c12;
}

.sd-message.info {
    background: #3498db;
}

.sd-message.success {
    background: #27ae60;
}

.sd-message-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.sd-message-close:hover {
    opacity: 0.7;
}

/* LOADING */
.sd-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 10002;
    display: flex;
    align-items: center;
    gap: 15px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .sd-estimator-container {
        margin: 10px;
        border-radius: 0;
    }

    .sd-header {
        padding: 20px 15px;
        border-radius: 0;
    }

    .sd-tab-content {
        padding: 15px;
    }

    .sd-calculators-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .sd-summary {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .toolbar-left {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left .sd-input {
        width: 100%;
    }

    .export-buttons {
        justify-content: center;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .formula-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ACCESSIBILITY */
.sd-tab:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.sd-btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.form-input:focus, .steel-input:focus, .sd-input:focus {
    outline: 2px solid #3498db;
    outline-offset: 1px;
}
