/* ================================================
   GENERAL STYLES
   ================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

h1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.8em;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

h3 {
    color: #764ba2;
    margin-top: 20px;
    margin-bottom: 15px;
    font-size: 1.4em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ================================================
   LAYOUT
   ================================================ */

.content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
}

.left-panel, .right-panel {
    padding: 20px;
}

.left-panel {
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

.right-panel {
    background: #ffffff;
    border-radius: 10px;
    border: 2px solid #e9ecef;
}

/* ================================================
   FORM ELEMENTS
   ================================================ */

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 0.95em;
}

.input-group input[type="number"],
.input-group input[type="email"],
.input-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
    background: white;
}

.input-group input[type="number"]:focus,
.input-group input[type="email"]:focus,
.input-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group input[type="number"]:hover,
.input-group select:hover {
    border-color: #667eea;
}

/* ================================================
   BUTTONS
   ================================================ */

button {
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-weight: 600;
    font-family: inherit;
}

.calculate-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    font-size: 1.1em;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.calculate-btn:active {
    transform: translateY(0);
}

.add-layer-btn {
    width: 100%;
    padding: 12px;
    background: #28a745;
    color: white;
    border-radius: 8px;
    font-size: 1em;
    margin-top: 15px;
    margin-bottom: 20px;
}

.add-layer-btn:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.remove-layer-btn {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.remove-layer-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 8px 15px;
    background: #17a2b8;
    color: white;
    border-radius: 5px;
    font-size: 0.9em;
    white-space: nowrap;
}

.action-btn:hover {
    background: #138496;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(23, 162, 184, 0.4);
}

.action-btn.email {
    background: #ffc107;
    color: #333;
}

.action-btn.email:hover {
    background: #e0a800;
}

.nav-btn {
    padding: 8px 12px;
    background: #6c757d;
    color: white;
    border-radius: 5px;
    font-size: 0.85em;
    min-width: 70px;
}

.nav-btn:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* ================================================
   LAYER SECTIONS
   ================================================ */

#layersContainer {
    margin-bottom: 15px;
}

.layer-section {
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.layer-section:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.layer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.layer-title {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1em;
}

.layer-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

/* ================================================
   FORMULA BOX
   ================================================ */

.formula {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    padding: 20px;
    border-radius: 10px;
    margin-top: 25px;
    border-left: 5px solid #667eea;
    font-size: 0.95em;
    line-height: 1.8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.formula strong {
    color: #667eea;
    font-size: 1.1em;
}

/* ================================================
   RESULTS DISPLAY
   ================================================ */

.results {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 2px solid #dee2e6;
}

.results-container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 15px;
}

.results-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #dee2e6;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.results-content::-webkit-scrollbar {
    width: 10px;
}

.results-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

.results-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 5px;
}

.results-content::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

.nav-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ================================================
   MESSAGES
   ================================================ */

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 5px solid #28a745;
    margin-bottom: 20px;
    font-weight: 600;
}

.error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 5px solid #dc3545;
    margin-bottom: 20px;
    font-weight: 600;
}

/* ================================================
   EMAIL MODAL
   ================================================ */

.email-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.email-modal.active {
    display: flex;
}

.email-modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-size: 1em;
}

.modal-btn.send {
    background: #28a745;
    color: white;
}

.modal-btn.send:hover {
    background: #218838;
}

.modal-btn.cancel {
    background: #6c757d;
    color: white;
}

.modal-btn.cancel:hover {
    background: #5a6268;
}

/* ================================================
   VISUALIZATIONS
   ================================================ */

.wall-diagram {
    display: flex;
    height: 150px;
    border: 3px solid #333;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.wall-layer-visual {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    border-right: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 0.85em;
    padding: 5px;
    transition: all 0.3s ease;
}

.wall-layer-visual:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

.wall-layer-visual:last-child {
    border-right: none;
}

.wall-layer-visual div {
    margin: 2px 0;
}

.temperature-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding: 0 5px;
    font-weight: 600;
    color: #667eea;
}

.fin-diagram {
    position: relative;
    height: 200px;
    background: linear-gradient(to right, #f0f0f0, #e0e0e0);
    border: 2px solid #333;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ================================================
   CANVAS STYLING
   ================================================ */

canvas {
    display: block;
    margin: 20px auto;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ================================================
   RESPONSIVE DESIGN
   ================================================ */

@media (max-width: 1024px) {
    .content {
        grid-template-columns: 1fr;
    }
    
    .layer-details {
        grid-template-columns: 1fr;
    }
    
    h1 {
        font-size: 2em;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.5em;
        padding: 20px;
    }
    
    h2 {
        font-size: 1.4em;
    }
    
    h3 {
        font-size: 1.2em;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .content {
        padding: 15px;
        gap: 15px;
    }
    
    .results-container {
        grid-template-columns: 1fr;
    }
    
    .nav-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .action-btn {
        width: 100%;
    }
    
    canvas {
        width: 100% !important;
        height: auto !important;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.2em;
        padding: 15px;
    }
    
    .input-group label {
        font-size: 0.9em;
    }
    
    .input-group input,
    .input-group select {
        padding: 10px;
        font-size: 0.95em;
    }
    
    .calculate-btn {
        font-size: 1em;
        padding: 12px;
    }
    
    .formula {
        font-size: 0.85em;
        padding: 15px;
    }
    
    .results-content {
        font-size: 0.8em;
        padding: 15px;
    }
}

/* ================================================
   UTILITY CLASSES
   ================================================ */

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-20 {
    padding: 20px;
}

.hidden {
    display: none;
}

/* ================================================
   ANIMATIONS
   ================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results {
    animation: fadeIn 0.5s ease;
}

.layer-section {
    animation: fadeIn 0.3s ease;
}

/* ================================================
   PRINT STYLES
   ================================================ */

@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
    }
    
    .left-panel {
        display: none;
    }
    
    .content {
        grid-template-columns: 1fr;
    }
    
    button {
        display: none;
    }
    
    .email-modal {
        display: none !important;
    }
}