/* =================================================================
   AI Vindkraftskalkyl - 26 juni 2025 - Huvudstilmall
   Desktop-layout med kompakt header och footer-kontroller
   ================================================================= */

/* === GRUNDLÄGGANDE STYLING === */
body { 
    font-family: Arial, sans-serif;
    max-width: 1400px;
    margin: 20px auto;
    padding: 20px;
    background-color: #f5f5f5;
}

/* === HEADER === */
.header {
    text-align: center;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.header h1 {
    margin: 0 0 8px 0;
    font-size: 24px;
}

.version-info {
    font-size: 11px;
    opacity: 0.9;
    margin: 2px 0;
    line-height: 1.3;
}

/* === JAVASCRIPT WARNING === */
.js-warning {
    color: red;
    font-weight: bold;
    padding: 10px;
    background: #ffe6e6;
    border-radius: 5px;
    margin-bottom: 15px;
}

/* === LOADING STATES === */
.loading-container {
    text-align: center;
    padding: 50px;
    color: #666;
}

.loading-icon {
    font-size: 24px;
    margin-bottom: 15px;
}

.loading-subtitle {
    font-size: 12px;
    margin-top: 10px;
}

/* === DESKTOP LAYOUT: TVÅ KOLUMNER + FOOTER === */
.main-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-column {
    display: flex;
    flex-direction: column;
}

/* === FOOTER CONTROLS === */
.footer-controls {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-top: 3px solid #4CAF50;
    margin-top: 20px;
}

.footer-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

.footer-section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.footer-section-title {
    font-weight: bold;
    color: #4CAF50;
    margin-right: 10px;
    font-size: 13px;
}

/* === CONTAINER === */
.container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* === INDATA-SEKTION === */
.input-group {
    padding: 15px;
    background-color: #ffffcc; /* Gul bakgrund för indata enligt regel 18 */
    border-radius: 8px;
    border: 2px solid #f0e68c;
}

.input-field {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.input-field label {
    display: inline-block;
    width: 200px;
    font-weight: bold;
    margin-bottom: 5px;
}

.input-field input {
    width: 100px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 4px;
    margin-right: 10px;
    background-color: #fffacd; /* Ljusare gul bakgrund för input-fält */
}

.unit {
    color: #666;
    font-style: italic;
}

/* === RESULTAT-SEKTION === */
.result-group {
    padding: 15px;
    background-color: #f0f0f0;
    border-radius: 8px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.results-table th, .results-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: right;
    font-size: 12px;
}

.results-table th {
    background-color: #f8f9fa;
    font-weight: bold;
}

.results-table td.label-cell {
    text-align: left;
    background-color: #fafafa;
    font-weight: 500;
}

/* === CHAT-SEKTION === */
.chat-container {
    background: #f8f9fa;
    border-radius: 8px;
    border-top: 3px solid #4CAF50;
    padding: 20px;
    height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
}

.api-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    color: white;
    margin-left: 15px;
}

.api-connected { background-color: #4CAF50; }
.api-testing { background-color: #FF9800; }
.api-error { background-color: #f44336; }

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 15px;
    margin: 15px 0;
    background: white;
    border-radius: 6px;
}

.message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    max-width: 90%;
    line-height: 1.5;
}

.message.ai {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
    line-height: 1.6;
    font-size: 14px;
}

.message.ai strong {
    color: #2196F3;
    font-weight: bold;
    display: block;
    margin: 8px 0 4px 0;
}

.message.ai .ai-list-item {
    margin: 4px 0 4px 15px;
}

.message.ai .ai-bullet {
    color: #4CAF50;
    font-weight: bold;
}

.message.ai .ai-number {
    color: #FF6B35;
    font-weight: bold;
}

.message.user {
    background-color: #e8f5e8;
    border: 1px solid #c8e6c9;
    margin-left: auto;
    text-align: right;
}

.message.system {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.message-header {
    font-weight: bold;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    margin-top: auto;
}

.chat-input {
    flex-grow: 1;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    min-height: 60px;
    max-height: 200px;
    resize: vertical;
    font-family: Arial, sans-serif;
}

.send-button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 15px 25px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    min-width: 80px;
}

.send-button:hover {
    background: #45a049;
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* === MODALER === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.info-button {
    background: #f8f9fa;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin: 5px;
}

.info-button:hover {
    background: #e9ecef;
}

.info-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.auto-analysis-toggle {
    margin: 10px 0;
    padding: 8px;
    background: #f0f8ff;
    border-radius: 4px;
    border: 1px solid #cce7ff;
    font-size: 12px;
}

/* === FORMLER OCH INFORMATION === */
.formula-box {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin: 10px 0;
    font-family: 'Courier New', monospace;
}

.formula-title {
    font-weight: bold;
    color: #495057;
    margin-bottom: 8px;
}

.section-title {
    color: #4CAF50;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 5px;
    margin: 20px 0 15px 0;
}

/* === TOOLTIP FÖR API-STATUS === */
.api-status-tooltip {
    pointer-events: none; /* Tooltip blockerar inte hover */
}

/* Visa tooltip bara vid hover på API-status-span:en, inte hela div:en */
.api-status:hover + .api-status-tooltip {
    opacity: 1 !important;
    visibility: visible !important;
}

/* === RESPONSIV DESIGN: MOBIL LAYOUT === */
/* På mobil/tablet: Stapla vertikalt enligt användarens önskemål */
@media (max-width: 1024px) {
    body {
        margin: 0;
        padding: 10px;
        max-width: 100%;
        overflow-x: hidden;
        /* Tillåt naturlig scrollning */
        height: auto;
        min-height: 100vh;
    }
    
    .header {
        padding: 10px 15px;
        margin-bottom: 15px;
    }
    
    .header h1 {
        font-size: 20px;
        margin-bottom: 6px;
    }
    
    .version-info {
        font-size: 10px;
    }
    
    .main-container {
        display: block; /* Ändra från grid till block för naturlig scrollning */
        margin-bottom: 120px; /* Plats för fast footer */
    }
    
    /* Kalkyl-sektion: Full storlek och synlig först */
    .left-column {
        display: block;
        width: 100%;
        margin-bottom: 20px;
        /* Ingen höjdbegränsning - visa allt innehåll */
        height: auto;
        overflow: visible;
    }
    
    /* Kalkyl med normal storlek på mobil */
    .left-column .container {
        padding: 15px;
    }
    
    .left-column h2 {
        font-size: 18px;
        margin: 0 0 10px 0;
    }
    
    .input-group, .result-group {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    /* Normala input-fält på mobil */
    .input-field {
        margin-bottom: 10px;
    }
    
    .input-field label {
        font-size: 14px;
        margin-bottom: 5px;
    }
    
    .input-field input {
        padding: 10px;
        font-size: 16px; /* Förhindrar zoom */
    }
    
    /* Chat-sektion: Kommer efter kalkylen, naturlig scrollning */
    .right-column {
        width: 100%;
        /* Ingen höjdbegränsning - naturlig storlek */
        height: auto;
        min-height: 100vh; /* Minst en full skärm för bra UX */
        margin-bottom: 120px; /* Plats för fast footer */
    }
    
    /* Chat-container med naturlig scrollning på mobil */
    .chat-container {
        /* Ingen höjdbegränsning - naturlig storlek */
        height: auto;
        min-height: 80vh; /* Bra storlek för chat-upplevelse */
        padding: 15px;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
    }
    
    .chat-container h3 {
        margin: 0 0 15px 0;
        font-size: 18px;
        text-align: center;
    }
    
    /* Kontroll-sektion för AI-inställningar på mobil */
    .chat-container > div:first-of-type {
        font-size: 11px;
        padding: 8px;
        margin: 8px 0;
        background: #f0f8ff;
        border: 1px solid #cce7ff;
        border-radius: 6px;
        /* Använd flexbox för bättre fyllning av utrymme */
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        justify-content: space-between;
        line-height: 1.3;
    }
    
    /* AI-kontroller med bättre storlek för touch */
    .chat-container select {
        padding: 8px 10px;
        font-size: 14px;
        border-radius: 6px;
        border: 2px solid #ddd;
        background: white;
        min-height: 44px; /* iOS touch-standard */
    }
    
    .chat-container input[type="number"] {
        width: 70px;
        padding: 8px;
        font-size: 14px;
        border-radius: 6px;
        border: 2px solid #ddd;
        background: #fffacd;
        min-height: 44px;
    }
    
    .chat-container .api-status {
        font-size: 12px;
        padding: 6px 10px;
        border-radius: 12px;
        text-align: center;
        font-weight: bold;
        color: white;
        min-height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Token-snabbknappar större för touch */
    .chat-container button {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 6px;
        border: 1px solid #ccc;
        background: #f8f9fa;
        margin: 2px;
        min-width: 44px;
        min-height: 36px;
    }
    
    .chat-container button:active, 
    .chat-container button[style*="4CAF50"] {
        background: #4CAF50 !important;
        color: white !important;
    }
    
    /* Token-info synlig och läsbar på mobil */
    .chat-container > div:nth-child(3) {
        display: block;
        font-size: 12px;
        padding: 10px;
        margin: 10px 0;
        background: #e8f4fd;
        border-radius: 8px;
        line-height: 1.4;
        /* Ingen höjdbegränsning */
        max-height: none;
        overflow: visible;
    }
    
    /* Chat-meddelanden med naturlig storlek */
    .chat-messages {
        /* Ingen flex - naturlig höjd */
        min-height: 300px;
        /* Ingen max-höjd - låt innehållet bestämma */
        max-height: none;
        margin: 15px 0;
        padding: 15px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border: 2px solid #ddd;
        border-radius: 8px;
        background: white;
    }
    
    .message {
        margin-bottom: 8px;
        padding: 8px;
        font-size: 13px;
        line-height: 1.3;
        border-radius: 6px;
    }
    
    .message-header {
        font-size: 10px;
        margin-bottom: 4px;
    }
    
    /* Chat-input med naturlig placering */
    .chat-input-area {
        margin-top: 20px;
        padding: 15px;
        background: #f8f9fa;
        border-radius: 10px;
        gap: 12px;
        display: flex;
        flex-direction: column;
        border: 2px solid #e9ecef;
    }
    
    .chat-input {
        min-height: 60px;
        max-height: 120px;
        font-size: 16px; /* Förhindrar zoom på iOS */
        padding: 15px;
        border: 2px solid #ddd;
        border-radius: 8px;
        resize: none;
        width: 100%;
        box-sizing: border-box;
        font-family: Arial, sans-serif;
        line-height: 1.4;
    }
    
    .send-button {
        width: 100%;
        padding: 15px;
        font-size: 16px;
        border-radius: 8px;
        min-height: 50px;
        background: #4CAF50;
        color: white;
        border: none;
        font-weight: bold;
        cursor: pointer;
    }
    
    .send-button:hover {
        background: #45a049;
    }
    
    .send-button:disabled {
        background: #ccc;
        cursor: not-allowed;
    }
    
    /* Input-fält anpassningar */
    .input-field {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 8px;
    }
    
    .input-field label {
        width: 100%;
        margin-bottom: 4px;
        font-size: 14px;
    }
    
    .input-field input {
        width: 100%;
        max-width: 200px;
        padding: 10px;
        font-size: 16px; /* Förhindrar zoom på iOS */
    }
    
    /* Tabell-anpassningar */
    .results-table {
        font-size: 10px;
    }
    
    .results-table th, .results-table td {
        padding: 4px;
    }
    
    /* Footer-anpassningar för mobil - kompakt layout */
    .footer-controls {
        padding: 8px;
        margin-top: 5px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 2px solid #4CAF50;
        box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
        z-index: 100;
    }
    
    .footer-buttons-container {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 4px;
        max-height: 120px;
        overflow-y: auto;
    }
    
    .footer-section {
        display: none; /* Göm sektioner på mobil */
    }
    
    .footer-section:first-child {
        display: block; /* Visa första sektionen */
        grid-column: span 3;
        text-align: center;
        margin-bottom: 6px;
    }
    
    .footer-section:nth-child(2) {
        display: block; /* Visa API & Data sektionen */
        grid-column: span 3;
        text-align: center;
    }
    
    .footer-section-title {
        font-size: 10px;
        margin-bottom: 4px;
        display: block;
    }
    
    .info-button {
        padding: 6px 8px;
        font-size: 10px;
        margin: 1px;
        min-width: 80px;
        border-radius: 4px;
    }
    
    /* API-status på mobil */
    .api-status {
        padding: 4px 8px;
        font-size: 9px;
        margin: 2px auto;
        display: block;
        border-radius: 8px;
    }
    
    /* Modal-anpassningar för mobil */
    /* Kompakt info-sektion på mobil */
    .chat-container > div:first-of-type {
        font-size: 11px;
        padding: 6px;
        margin: 5px 0;
        line-height: 1.3;
    }
    
    .chat-container select, .chat-container input[type="number"] {
        padding: 6px 8px;
        font-size: 14px;
        margin: 2px;
    }
    
    .chat-container button {
        padding: 6px 10px;
        font-size: 12px;
        margin: 2px;
    }
    
    /* Token-knappar med specifik styling */
    .chat-container .token-button {
        padding: 6px 10px !important;
        font-size: 11px !important;
        border-radius: 4px !important;
        border: 1px solid #ccc !important;
        margin: 2px !important;
        min-width: 50px !important;
        cursor: pointer !important;
        background: #f8f9fa !important;
        color: black !important;
    }
    
    .chat-container .token-button.active {
        background: #4CAF50 !important;
        color: white !important;
    }
    
    .chat-container .token-button.token-1600 {
        border: 2px solid #FF6B35 !important;
        background: #fff3e0 !important;
        color: #FF6B35 !important;
        min-width: 60px !important;
        font-weight: bold !important;
    }
    
    .chat-container .token-button.token-1600.active {
        background: #FF6B35 !important;
        color: white !important;
    }
    
    /* Modal-anpassningar för mobil */
    .modal-content {
        margin: 10px;
        padding: 15px;
        max-height: 85vh;
        width: calc(100% - 20px);
    }
    
    .stats-table {
        font-size: 11px;
        overflow-x: auto;
        display: block;
        white-space: nowrap;
    }
    
    .stats-table th, .stats-table td {
        padding: 6px 4px;
        min-width: 80px;
    }
}

/* === YTTERLIGARE FÖRBÄTTRINGAR === */
/* Smooth transitions för bättre användarupplevelse */
.info-button, .send-button {
    transition: background-color 0.2s ease;
}

/* Bättre fokus-states för tillgänglighet */
.chat-input:focus, .input-field input:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* Styling för modal-knappar */
.modal-close-button {
    padding: 12px 30px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.modal-close-button:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
}

/* Statistik-tabeller i modaler */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

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

.stats-table th {
    background-color: #f8f9fa;
    font-weight: bold;
}

.stats-table tr:nth-child(even) {
    background-color: #f9f9f9;
} 