/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

/* Header */
header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 2rem;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1rem;
    opacity: 0.9;
}

/* Main Content */
main {
    padding: 1.5rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.card h2 {
    color: #2c3e50;
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.card h3 {
    color: #34495e;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Tributary Loading */
.section-description {
    color: #7f8c8d;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.tributary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.tributary-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.25rem;
    border-left: 4px solid #3498db;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tributary-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.1);
}

.load-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.load-header strong {
    color: #2c3e50;
    font-size: 1rem;
}

.load-value {
    background: #3498db;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.calculated-load {
    margin-top: 0.75rem;
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    color: #27ae60;
    border: 1px solid #e9ecef;
}

.total-load-summary {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.total-load-item {
    font-size: 1.2rem;
}

.total-load-item strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.total-load-item span {
    font-size: 1.8rem;
    font-weight: 700;
}

/* Material Selection Tabs */
.material-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e9ecef;
}

.material-tab {
    background: #f8f9fa;
    border: none;
    padding: 1.25rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-right: 1px solid #e9ecef;
}

.material-tab:last-child {
    border-right: none;
}

.material-tab strong {
    color: #2c3e50;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    display: block;
}

.material-tab small {
    color: #7f8c8d;
    font-size: 0.8rem;
}

.material-tab.active {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.material-tab.active strong,
.material-tab.active small {
    color: white;
}

.material-tab:hover:not(.active) {
    background: #e9ecef;
}

/* Point Loading */
.point-loading-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    max-width: 100%;
    overflow: hidden;
}

/* Only use two columns on very large screens */
@media (min-width: 1400px) {
    .point-loading-options {
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
        gap: 2rem;
    }
}

.point-load-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1.25rem;
    border-left: 4px solid #e67e22;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.point-load-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(230, 126, 34, 0.1);
}

.point-load-item .load-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.point-load-item .load-header strong {
    color: #2c3e50;
    font-size: 1rem;
}

.load-type {
    background: #e67e22;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.input-grid-inline {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
}

/* Only show side-by-side on larger screens with plenty of space */
@media (min-width: 1200px) {
    .input-grid-inline {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
}

.point-load-summary {
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.point-load-effects {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 100%;
}

.effect-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.effect-item strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.effect-item span {
    font-size: 1.2rem;
    font-weight: 700;
}

/* LVL Bearing Length Calculator */
.bearing-inputs {
    margin-bottom: 2rem;
}

.support-material-selection {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #e9ecef;
}

.support-material-selection h3 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.material-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    max-width: 300px;
    margin: 0 auto;
}

.material-radio {
    cursor: pointer;
    display: block;
}

.material-radio input[type="radio"] {
    display: none;
}

.radio-label {
    display: block;
    padding: 1rem;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.3s ease;
    text-align: center;
}

.radio-label strong {
    display: block;
    color: #2c3e50;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.radio-label small {
    color: #7f8c8d;
    font-size: 0.8rem;
}

.material-radio input[type="radio"]:checked + .radio-label {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    border-color: #8e44ad;
    color: white;
    transform: scale(1.02);
}

.material-radio input[type="radio"]:checked + .radio-label strong,
.material-radio input[type="radio"]:checked + .radio-label small {
    color: white;
}

.bearing-results {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    padding: 2rem;
    border-left: 4px solid #9b59b6;
}

.bearing-calculation {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.calc-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.calc-item strong {
    color: #2c3e50;
    font-size: 0.9rem;
}

.calc-item span {
    font-weight: 600;
    color: #9b59b6;
    font-size: 1rem;
}

.bearing-status {
    text-align: center;
}

.status-indicator {
    display: inline-block;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.status-indicator.adequate {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.status-indicator.inadequate {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.status-indicator.neutral {
    background: #f8f9fa;
    color: #7f8c8d;
    border: 2px solid #e9ecef;
}

/* Input Groups */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 600;
    color: #34495e;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.input-group input,
.input-group select {
    padding: 0.875rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.input-group input:invalid {
    border-color: #e74c3c;
}

/* Loading Configuration */
.loading-type {
    margin-bottom: 1.5rem;
}

.radio-group {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.radio-group:hover {
    background-color: #f8f9fa;
}

.radio-group input[type="radio"] {
    margin-right: 0.75rem;
    accent-color: #3498db;
}

.radio-group span {
    font-weight: 500;
    color: #2c3e50;
}

.load-inputs {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

/* Calculate Button */
.calculate-button {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calculate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(46, 204, 113, 0.3);
}

.calculate-button:active {
    transform: translateY(0);
}

.calculate-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Results Section */
.results {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 5px solid #3498db;
}

/* Load Summary */
.load-summary {
    margin-bottom: 2rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.summary-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.summary-item strong {
    color: #2c3e50;
    font-size: 0.9rem;
}

.summary-item span {
    font-weight: 600;
    color: #27ae60;
    font-size: 1rem;
}

/* Beam Sizing Tables */
.beam-sizing {
    margin-bottom: 2rem;
}

.sizing-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.table-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    background: #34495e;
    color: white;
    padding: 1rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.table-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
    transition: background-color 0.2s ease;
}

.table-row:hover {
    background-color: #f8f9fa;
}

.table-row:last-child {
    border-bottom: none;
}

.table-row.recommended {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    font-weight: 600;
}

.table-row.recommended:hover {
    background: linear-gradient(135deg, #229954, #27ae60);
}

/* Steel Requirements */
.steel-requirements {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.steel-req-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e9ecef;
}

.steel-req-item:last-child {
    border-bottom: none;
}

.steel-req-item strong {
    color: #2c3e50;
}

.steel-req-item span {
    font-weight: 600;
    color: #3498db;
}

.steel-note {
    background: #e8f4fd;
    border: 1px solid #3498db;
    border-radius: 8px;
    padding: 1rem;
}

.steel-note p {
    margin: 0;
    color: #2c3e50;
    line-height: 1.6;
}

/* Deflection Analysis */
.deflection-analysis {
    margin-bottom: 2rem;
}

.deflection-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.deflection-table .table-header {
    background: #8e44ad;
}

.deflection-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
}

.deflection-row:last-child {
    border-bottom: none;
}

.deflection-row.selected {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    font-weight: 600;
}

/* Status Indicators */
.status-pass {
    color: #27ae60 !important;
    font-weight: 600;
}

.status-fail {
    color: #e74c3c !important;
    font-weight: 600;
}

.status-warning {
    color: #f39c12 !important;
    font-weight: 600;
}

/* LVL Bearing Length Section in Results */
.bearing-length-section {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: 12px;
    padding: 2rem;
    border-left: 4px solid #9b59b6;
    margin-bottom: 2rem;
}

.bearing-length-section h3 {
    color: #9b59b6;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.bearing-description {
    color: #7f8c8d;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Final Recommendations */
.final-recommendations {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    border-left: 4px solid #f39c12;
}

.final-recommendations h3 {
    color: #e67e22;
    margin-bottom: 1rem;
}

#final-recommendation-text {
    color: #2c3e50;
    line-height: 1.6;
}

#final-recommendation-text .highlight {
    background: #fff3cd;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

#final-recommendation-text .success {
    color: #27ae60;
    font-weight: 600;
}

#final-recommendation-text .warning {
    color: #e74c3c;
    font-weight: 600;
}

/* Beam Properties */
.beam-properties {
    margin-bottom: 2rem;
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.property-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.property-item strong {
    color: #34495e;
    font-size: 0.9rem;
}

.property-item span {
    font-weight: 600;
    color: #3498db;
}

/* Recommendations */
.recommendations {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    border-left: 4px solid #f39c12;
}

.recommendations h3 {
    color: #e67e22;
    margin-bottom: 1rem;
}

#recommendation-text {
    color: #2c3e50;
    line-height: 1.6;
}

#recommendation-text .warning {
    color: #e74c3c;
    font-weight: 600;
}

#recommendation-text .success {
    color: #27ae60;
    font-weight: 600;
}

/* Status Indicators */
.status-pass {
    color: #27ae60 !important;
    font-weight: 600;
}

.status-fail {
    color: #e74c3c !important;
    font-weight: 600;
}

.status-warning {
    color: #f39c12 !important;
    font-weight: 600;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }
    
    .container {
        border-radius: 15px;
    }
    
    header {
        padding: 1.5rem;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .card h2 {
        font-size: 1.2rem;
    }
    
    .tributary-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .point-loading-options {
        gap: 1rem;
        padding: 0;
        margin: 0 auto;
    }
    
    .point-load-item {
        max-width: 100%;
        margin: 0 auto;
        padding: 1rem;
    }
    
    .input-grid-inline {
        gap: 0.75rem;
    }
    
    .point-load-effects {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .material-options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        max-width: 100%;
    }
    
    .bearing-calculation {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .calc-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .material-tabs {
        grid-template-columns: 1fr;
    }
    
    .material-tab {
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .material-tab:last-child {
        border-bottom: none;
    }
    
    .input-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .table-header,
    .table-row,
    .deflection-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        font-size: 0.85rem;
    }
    
    .table-header span:nth-child(3),
    .table-header span:nth-child(4),
    .table-row span:nth-child(3),
    .table-row span:nth-child(4),
    .deflection-row span:nth-child(3),
    .deflection-row span:nth-child(4) {
        display: none;
    }
    
    .summary-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .calculate-button {
        padding: 1rem;
        font-size: 1rem;
    }
    
    .total-load-item span {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.4rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    .material-grid {
        grid-template-columns: 1fr;
    }
    
    .card h2 {
        font-size: 1.1rem;
    }
    
    .point-loading-options {
        gap: 0.75rem;
        padding: 0;
    }
    
    .point-load-item {
        padding: 0.875rem;
        margin: 0;
    }
    
    .input-grid-inline {
        gap: 0.5rem;
    }
    
    .point-load-effects {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .material-options {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        max-width: 100%;
        margin: 0;
    }
}

/* Animation for loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.calculate-button.calculating {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
}

.calculate-button.calculating::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }
    
    .material-card {
        border: 2px solid #000;
    }
    
    .input-group input,
    .input-group select {
        border: 2px solid #000;
    }
}
