/* EC2 Part 4 Fastener Design Calculator - Styles */

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

:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --secondary-color: #4CAF50;
    --danger-color: #F44336;
    --warning-color: #FF9800;
    --success-color: #4CAF50;
    --text-dark: #212121;
    --text-light: #757575;
    --border-color: #E0E0E0;
    --bg-light: #FAFAFA;
    --bg-white: #FFFFFF;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-dark);
    background-color: var(--bg-light);
    line-height: 1.6;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
}

/* Panels */
.input-panel, .output-panel {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(33, 150, 243, 0.05);
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--bg-white);
}

/* Tab Content */
.tab-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.tab-pane h3 {
    margin-bottom: 1.5rem;
    color: var(--text-dark);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.tab-pane h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-dark);
    font-size: 1.1rem;
}

.tab-pane h5 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-size: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form-group input[type="number"],
.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input[type="number"]:focus,
.form-group input[type="text"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 18px;
    height: 18px;
}

/* Buttons */
button {
    font-family: inherit;
}

.btn-primary, .btn-secondary, .btn-danger {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

.btn-secondary:hover {
    background: var(--text-dark);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #D32F2F;
}

.btn-large {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    margin-top: 1.5rem;
}

/* Tables */
.table-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    overflow-x: auto;
}

.data-table thead {
    background: var(--bg-light);
}

.data-table th {
    padding: 0.75rem 0.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background: var(--bg-light);
}

.data-table input[type="number"],
.data-table input[type="text"] {
    width: 100%;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 2px;
}

.data-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.wide-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

/* Info Box */
.info-box {
    background: #E3F2FD;
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    margin-top: 1.5rem;
    border-radius: 4px;
}

.info-box p {
    margin-bottom: 0.5rem;
}

.info-box p:last-child {
    margin-bottom: 0;
}

.small-text {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Load Case Controls */
.load-case-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.load-case-controls label {
    font-weight: 500;
}

.load-case-controls select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* Material Factors Display */
.material-factors-display {
    background: var(--bg-light);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.material-factors-display h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.material-factors-display p {
    margin-bottom: 0.25rem;
}

/* Failure Modes Checkboxes */
.failure-modes-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.failure-modes-checkboxes label {
    display: flex;
    align-items: center;
    margin-left: 1rem;
}

.failure-modes-checkboxes input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 18px;
    height: 18px;
}

/* Visualization */
.visualization-section {
    padding: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.visualization-section h3 {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.plot-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.plot-controls label {
    font-weight: 500;
}

.plot-controls input[type="number"] {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

#plot-canvas {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
}

.legend {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 2px;
    margin-right: 0.5rem;
    border: 1px solid var(--border-color);
}

/* Results */
.results-section {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.results-section h3 {
    margin-bottom: 1rem;
    color: var(--text-dark);
}

.no-results {
    color: var(--text-light);
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

.result-status {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-weight: 600;
    text-align: center;
}

.result-status.pass {
    background: #C8E6C9;
    color: #2E7D32;
}

.result-status.fail {
    background: #FFCDD2;
    color: #C62828;
}

.result-section {
    margin-bottom: 1.5rem;
}

.result-section h4 {
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.result-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.result-table td:first-child {
    font-weight: 500;
    width: 40%;
}

.pass-text {
    color: var(--success-color);
    font-weight: 600;
}

.fail-text {
    color: var(--danger-color);
    font-weight: 600;
}

/* Utilization Display */
.utilization-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.utilization-table th {
    background: var(--bg-light);
    padding: 0.5rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-color);
}

.utilization-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.util-bar-container {
    position: relative;
    width: 100%;
    height: 24px;
    background: #F5F5F5;
    border-radius: 4px;
    overflow: visible;
}

.util-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.util-bar-ok {
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
}

.util-bar-warning {
    background: linear-gradient(90deg, #FF9800, #FFB74D);
}

.util-bar-fail {
    background: linear-gradient(90deg, #F44336, #EF5350);
}

.util-text {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
}

/* Footer */
.app-footer {
    background: var(--text-dark);
    color: white;
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#loading-overlay p {
    color: white;
    font-size: 1.2rem;
    margin-top: 1rem;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 1400px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .output-panel {
        min-height: 800px;
    }
}

@media (max-width: 768px) {
    .tabs {
        overflow-x: auto;
    }

    .tab-btn {
        white-space: nowrap;
    }

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

    .table-controls {
        flex-direction: column;
    }

    .table-controls button {
        width: 100%;
    }
}
