/**
 * Legionella Risk Assessment Tool - Frontend Styles
 * Version: 2.0.0
 */

/* Form Styling */
.form-group { 
    margin-bottom: 15px; 
}

label { 
    display: block; 
    margin-bottom: 5px; 
    font-weight: bold; 
}

input, select, textarea { 
    width: 100%; 
    padding: 8px; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    box-sizing: border-box; 
}

textarea { 
    resize: vertical; 
    min-height: 100px; 
}

button {
    padding: 15px 35px;
    border-radius: 100px;
    border: 1px solid #027c8b;
    background: #027c8b;
    color: #FFF;
    text-align: center;
    font-family: Inter;
    font-size: 18px;
    font-style: normal;
    font-weight: 300;
    line-height: normal;
}

button:hover {
    background: transparent;
    color: #027c8b;
}

/* Risk Level Styling */
.risk-high { 
    color: #e74c3c; 
    font-weight: bold; 
}

.risk-medium { 
    color: #f39c12; 
    font-weight: bold; 
}

.risk-low { 
    color: #27ae60; 
    font-weight: bold; 
}

#result { 
    margin-top: 20px; 
    padding: 15px; 
    border-radius: 4px; 
    background: #f9f9f9; 
}

/* Info Tooltips */
.info-container {
    display: inline-flex;
    align-items: center;
    position: relative;
}

.info-icon { 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background-color: #027c8b;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    cursor: help;
    margin-left: 5px;
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.info-tooltip {
    position: absolute;
    left: 25px;
    top: 0;
    z-index: 10000;
    background: #ffffff;
    border: 2px solid #027c8b;
    padding: 15px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    word-wrap: break-word;
    color: #333;
    display: block;
    white-space: normal;
}

.info-icon:hover .info-tooltip,
.info-icon:focus .info-tooltip,
.info-icon.active .info-tooltip {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto;
    display: block !important;
}

.info-tooltip:hover {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
}

.section-header {
    display: flex;
    align-items: center;
    position: relative;
}

.section-header .info-icon {
    margin-left: 10px;
}

.section-header .info-tooltip {
    left: 0;
    top: 100%;
    transform: translateY(10px);
    margin-top: 5px;
}

.jacuzzi-tooltip {
    left: -420px !important;
    top: 0 !important;
    transform: none !important;
}

/* Character Counter */
.char-counter {
    font-size: 0.8em;
    color: #666;
    text-align: right;
    margin-top: 2px;
}

.char-counter.low {
    color: #e74c3c;
    font-weight: bold;
}

/* Room Table */
.appliance-table { 
    width: 100%; 
    border-collapse: collapse; 
    margin-top: 15px;
    margin-bottom: 15px;
}

.appliance-table th, .appliance-table td { 
    border: 1px solid #ddd; 
    padding: 8px; 
    text-align: center; 
}

.appliance-table th { 
    background-color: #f2f2f2; 
    font-weight: bold;
}

.appliance-table input[type="number"] {
    width: 80px !important;
    text-align: center;
}

.appliance-table input[type="text"] {
    width: 120px;
}

.add-room-row {
    background-color: #f0f8ff;
    cursor: pointer;
}

.add-room-row:hover {
    background-color: #e1f0fa;
}

.remove-room {
    color: red;
    cursor: pointer;
}

/* Mitigation Messages */
.mitigation-pass { 
    color: green; 
    font-weight: bold; 
}

.mitigation-fail { 
    color: red; 
    font-weight: bold; 
}

.mitigation-medium { 
    color: #f39c12; 
    font-weight: bold; 
}

/* Viral Popup */
.viral-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

.viral-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.viral-popup h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 24px;
}

.viral-popup p {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.viral-email-inputs {
    margin-bottom: 20px;
}

.viral-email-inputs input {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.viral-email-inputs input:focus {
    border-color: #3498db;
    outline: none;
}

.viral-buttons {
    margin-top: 20px;
}

.viral-send-btn {
    background-color: #27ae60;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 15px;
    width: 100%;
}

.viral-send-btn:hover {
    background-color: #229954;
}

.viral-skip {
    color: #999;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}

.viral-skip:hover {
    color: #666;
}

/* Stripe Popup */
.stripe-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1001;
}

.stripe-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.stripe-popup h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 22px;
}

.stripe-popup p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.stripe-donate-btn {
    background-color: #6772e5;
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    margin: 10px;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.stripe-donate-btn:hover {
    background-color: #5469d4;
}

.stripe-donate-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.stripe-close {
    color: #999;
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
    margin-top: 15px;
    display: block;
}

.stripe-close:hover {
    color: #666;
}

/* Download Counter */
.download-counter {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-family: monospace;
    display: none; 
    z-index: 9999;
}

.download-counter.admin-visible {
    display: block;
}

/* High Risk Warning */
.high-risk-warning {
    background-color: #ffe6e6;
    border: 2px solid #ff6b6b;
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    color: #d63031;
    font-weight: 500;
    display: none;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.15);
}

.high-risk-warning.visible {
    display: block;
}

.high-risk-warning strong {
    color: #b71c1c;
}

/* Water System Mitigation */
.water-system-mitigation { 
    margin-top: 15px; 
}

select:disabled {
    color: #999;
    background-color: #f5f5f5;
    cursor: not-allowed;
}

/* Image Preview */
.image-preview, .photos-preview {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.preview-item {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin: 10px;
    max-width: 200px;
}

.preview-img {
    max-width: 150px;
    max-height: 150px;
    border: 2px solid #ddd;
    border-radius: 8px;
    object-fit: contain;
    width: auto;
    height: auto;
}

.photo-notes {
    width: 150px;
    min-height: 40px;
    margin: 5px 0;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
    resize: vertical;
}

.remove-img {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    padding: 0 !important;
}

.remove-img:hover {
    background: #c0392b;
}

/* Company Branding */
.company-branding {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #027c8b;
}

.company-branding h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.company-branding small {
    color: #666;
    font-style: italic;
}

/* Preview Modal */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-content {
    background: white;
    border-radius: 10px;
    max-width: 900px;
    width: 95%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.preview-header h2 {
    margin: 0;
    color: #2c3e50;
}

.close-preview {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-preview:hover {
    color: #e74c3c;
}

.preview-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.preview-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-primary {
    background: #27ae60;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.btn-primary:hover {
    background: #229954;
}

.preview-section {
    margin-bottom: 25px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 15px;
}

.preview-section:last-child {
    border-bottom: none;
}

.preview-section h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 18px;
}

.preview-detail {
    margin-bottom: 8px;
}

.preview-detail strong {
    color: #34495e;
}

.risk-preview {
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
    font-weight: bold;
    font-size: 18px;
}

.risk-preview.high {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.risk-preview.medium {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffeaa7;
}

.risk-preview.low {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

/* PDF Styles */
.pdf-page {
    background: white;
    border: 1px solid #ddd;
    margin-bottom: 20px;
    padding: 30px;
    min-height: 400px;
    position: relative;
    font-family: Arial, sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pdf-header {
    text-align: center;
    margin-bottom: 20px;
}

.company-header {
    font-size: 14px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

.pdf-title {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    color: #2c3e50;
}

.pdf-subtitle {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    margin: 15px 0;
    color: #2c3e50;
}

.pdf-address {
    text-align: center;
    font-size: 14px;
    line-height: 1.6;
    margin: 20px 0;
    color: #34495e;
}

.pdf-assessor {
    text-align: center;
    font-size: 12px;
    margin: 30px 0;
    color: #34495e;
}

.pdf-section-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.pdf-content {
    font-size: 12px;
    line-height: 1.6;
    color: #34495e;
    margin-bottom: 15px;
}

.pdf-toc {
    font-size: 12px;
    line-height: 2;
    text-align: center;
    margin: 40px 0;
    color: #34495e;
}

.pdf-table-container {
    margin: 20px 0;
    overflow-x: auto;
}

.pdf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    margin: 10px 0;
}

.pdf-table th,
.pdf-table td {
    border: 1px solid #ddd;
    padding: 6px 4px;
    text-align: center;
}

.pdf-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    font-size: 9px;
}

.pdf-signature {
    margin-top: 30px;
    font-size: 12px;
    line-height: 1.8;
    color: #34495e;
}

.pdf-footer {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #666;
    text-align: center;
}

/* Room Limit Warning */
.room-limit-warning {
    color: #e74c3c;
    display: none;
    font-size: 0.9em;
    margin-top: 5px;
}

.tank-na {
    color: #999;
    font-style: italic;
}

/* Room Boxes (Mobile) */
.room-box {
    border: 2px solid #3498db;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    background-color: #f8f9fa;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.room-heading {
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    border: none;
    background: none;
    width: 100%;
    padding: 5px;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 2px solid #3498db;
}

.room-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    padding: 8px 0;
}

.room-field label {
    font-weight: bold;
    color: #2c3e50;
    flex: 1;
    margin: 0;
}

.room-field input[type="number"] {
    width: 80px !important;
    text-align: center;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.room-field input[type="checkbox"] {
    transform: scale(1.5);
    margin-left: auto;
    margin-right: 0;
    width: 20px;
    flex-shrink: 0;
}

.room-field input[type="checkbox"]:checked + label {
    text-decoration: line-through;
}

.remove-room-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    font-size: 14px;
}

.remove-room-btn:hover {
    background: #c0392b;
}

.add-room-box {
    border: 2px dashed #3498db;
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
    text-align: center;
    cursor: pointer;
    background-color: #f0f8ff;
    color: #3498db;
    font-weight: bold;
    font-size: 16px;
}

.add-room-box:hover {
    background-color: #e1f0fa;
    border-color: #2980b9;
}

.room-boxes {
    display: none;
}

/* Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .info-tooltip {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90vw !important;
        max-width: 350px !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
        z-index: 10001 !important;
        margin: 0 !important;
    }
    
    .section-header .info-tooltip {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90vw !important;
        max-width: 350px !important;
        margin: 0 !important;
    }
    
    .jacuzzi-tooltip {
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90vw !important;
        max-width: 350px !important;
        margin: 0 !important;
    }
    
    .info-tooltip::after {
        content: "Tap anywhere to close";
        display: block;
        text-align: center;
        font-size: 12px;
        color: #666;
        margin-top: 15px;
        padding-top: 10px;
        border-top: 1px solid #ddd;
        font-style: italic;
        background-color: #f8f9fa;
        margin-left: -15px;
        margin-right: -15px;
        margin-bottom: -15px;
        padding-left: 15px;
        padding-right: 15px;
        padding-bottom: 15px;
        border-radius: 0 0 6px 6px;
    }
    
    .appliance-table {
        display: none !important;
    }
    
    .room-boxes {
        display: block !important;
    }
    
    .room-box {
        margin: 10px 0;
        padding: 12px;
    }
    
    .room-field {
        margin: 8px 0;
    }
    
    .room-field input[type="number"] {
        width: 70px !important;
    }
    
    body {
        width: 100%;
        max-width: 100%;
        padding: 10px;
    }
    
    #notes {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        margin: 0 auto;
        display: block;
    }
    
    .viral-popup {
        padding: 15px !important;
        margin: 10px !important;
        max-width: 320px !important;
        width: 85% !important;
    }
    
    .viral-popup h3 {
        font-size: 18px !important;
        margin-bottom: 12px !important;
    }
    
    .viral-popup p {
        font-size: 14px !important;
        margin-bottom: 15px !important;
    }
    
    .viral-send-btn {
        font-size: 13px !important;
        padding: 8px 12px !important;
    }
    
    .viral-skip {
        font-size: 11px !important;
        margin-top: 8px !important;
    }
    
    .viral-popup, .stripe-popup {
        padding: 20px;
        margin: 20px;
    }
    
    .viral-popup h3 {
        font-size: 20px;
    }
    
    .stripe-popup h3 {
        font-size: 18px;
    }
}

@media (min-width: 769px) {
    .room-boxes {
        display: none !important;
    }
    
    .appliance-table {
        display: table !important;
    }
}

/* Preview Modal Styles */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-content {
    background: white;
    border-radius: 10px;
    max-width: 900px;
    width: 95%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.preview-header h2 {
    margin: 0;
    color: #2c3e50;
}

.close-preview {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-preview:hover {
    color: #e74c3c;
}

.preview-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.preview-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-primary {
    background: #27ae60;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.btn-primary:hover {
    background: #229954;
}

.preview-section {
    margin-bottom: 25px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 15px;
}

.preview-section:last-child {
    border-bottom: none;
}

.preview-section h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 18px;
}

.preview-detail {
    margin-bottom: 8px;
}

.preview-detail strong {
    color: #34495e;
}

.risk-preview {
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
    font-weight: bold;
    font-size: 18px;
}

.risk-preview.high {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.risk-preview.medium {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffeaa7;
}

.risk-preview.low {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

/* PDF-style preview pages */
.pdf-page {
    background: white;
    border: 1px solid #ddd;
    margin-bottom: 20px;
    padding: 30px;
    min-height: 400px;
    position: relative;
    font-family: Arial, sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pdf-header {
    text-align: center;
    margin-bottom: 20px;
}

.company-header {
    font-size: 14px;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 10px;
}

.pdf-title {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    color: #2c3e50;
}

.pdf-subtitle {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    margin: 15px 0;
    color: #2c3e50;
}

.pdf-address {
    text-align: center;
    font-size: 14px;
    line-height: 1.6;
    margin: 20px 0;
    color: #34495e;
}

.pdf-assessor {
    text-align: center;
    font-size: 12px;
    margin: 30px 0;
    color: #34495e;
}

.pdf-section-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.pdf-content {
    font-size: 12px;
    line-height: 1.6;
    color: #34495e;
    margin-bottom: 15px;
}

.pdf-toc {
    font-size: 12px;
    line-height: 2;
    text-align: center;
    margin: 40px 0;
    color: #34495e;
}

.pdf-table-container {
    margin: 20px 0;
    overflow-x: auto;
}

.pdf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    margin: 10px 0;
}

.pdf-table th,
.pdf-table td {
    border: 1px solid #ddd;
    padding: 6px 4px;
    text-align: center;
}

.pdf-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    font-size: 9px;
}

.pdf-signature {
    margin-top: 30px;
    font-size: 12px;
    line-height: 1.8;
    color: #34495e;
}

.pdf-footer {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #666;
    text-align: center;
}
