/**
 * Google Sheets Integration - Frontend Styles (Korrigiert)
 */

/* Basis-Styles für GSI-Tabellen */
.gsi-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-family: Arial, sans-serif;
}

.gsi-table th,
.gsi-table td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #ddd;
    vertical-align: top;
}

.gsi-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.gsi-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.gsi-table tr:hover {
    background-color: #f0f0f0;
}

/* Spezielle Styles basierend auf den class-tags */

/* Sprachspezifische Zellen */
.gsi-table td.de,
.gsi-table td.en,
.gsi-table td.th {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.gsi-table td.de:hover,
.gsi-table td.en:hover,
.gsi-table td.th:hover {
    background-color: #e8f4f8;
    border-color: #4a9eff;
}

/* Deutsche Inhalte */
.gsi-table td.de {
    font-family: 'Segoe UI', Arial, sans-serif;
}

/* Englische Inhalte */
.gsi-table td.en {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-style: italic;
}

/* Thailändische Inhalte */
.gsi-table td.th {
    font-family: 'Noto Sans Thai', 'Segoe UI', Arial, sans-serif;
    font-size: 1.1em;
}

/* Überschriften */
.gsi-table td.de-h1,
.gsi-table td.en-h1,
.gsi-table td.th-h1 {
    font-size: 1.4em;
    font-weight: bold;
    background-color: #e8f4f8;
    border: 2px solid #4a9eff;
}

.gsi-table td.de-h2,
.gsi-table td.en-h2,
.gsi-table td.th-h2 {
    font-size: 1.2em;
    font-weight: bold;
    background-color: #f0f8ff;
    border: 1px solid #7bb3ff;
}

.gsi-table td.de-h3,
.gsi-table td.en-h3,
.gsi-table td.th-h3 {
    font-size: 1.1em;
    font-weight: bold;
    background-color: #f8fbff;
    border: 1px solid #a6c8ff;
}

/* Transliteration */
.gsi-table td.trans {
    font-family: 'Courier New', monospace;
    background-color: #fffbf0;
    color: #8b4513;
    font-style: italic;
}

/* Leere Felder */
.gsi-table td.empty {
    background-color: #f8f8f8;
    opacity: 0.5;
}

/* Container und Controls */
.gsi-container {
    margin: 20px 0;
}

.gsi-controls {
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons für Sheet-Aktionen */
.gsi-button {
    background-color: #4a9eff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.gsi-button:hover {
    background-color: #3a8eef;
    transform: translateY(-1px);
}

.gsi-button:active {
    background-color: #2a7edf;
    transform: translateY(0);
}

.gsi-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.gsi-button.secondary {
    background-color: #6c757d;
}

.gsi-button.secondary:hover {
    background-color: #5a6268;
}

/* Status-Anzeigen */
.gsi-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 3px;
    font-weight: bold;
    transition: all 0.3s ease;
    min-width: 100px;
    text-align: center;
}

.gsi-status-loading {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.gsi-status-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.gsi-status-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f1b0b7;
}

/* Loading-Indikator für Tabellen */
.gsi-table.gsi-loading {
    opacity: 0.6;
    position: relative;
}

.gsi-table.gsi-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top: 2px solid #3498db;
    animation: gsi-spin 1s linear infinite;
    z-index: 10;
}

@keyframes gsi-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Auto-Update Indikator */
.gsi-container[data-auto-update="true"] .gsi-controls::before {
    content: "🔄";
    font-size: 12px;
    opacity: 0.7;
    margin-right: 5px;
}

/* Versteckte Tabellen (aber im DOM verfügbar) */
.gsi-table.gsi-hidden,
.gsi-container.gsi-hidden {
    display: none !important;
}

/* Sprachindikator */
.gsi-language-indicator {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8em;
    font-weight: bold;
    margin-left: 5px;
}

.gsi-language-indicator.de {
    background-color: #ffebee;
    color: #c62828;
}

.gsi-language-indicator.en {
    background-color: #e8f5e8;
    color: #2e7d32;
}

.gsi-language-indicator.th {
    background-color: #fff3e0;
    color: #f57c00;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gsi-table {
        font-size: 0.9em;
    }
    
    .gsi-table th,
    .gsi-table td {
        padding: 6px 8px;
    }
    
    .gsi-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .gsi-button {
        margin: 2px 0;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .gsi-table {
        font-size: 0.8em;
    }
    
    .gsi-table th,
    .gsi-table td {
        padding: 4px 6px;
    }
}

/* Accessibility */
.gsi-table td[class*="de"]:focus,
.gsi-table td[class*="en"]:focus,
.gsi-table td[class*="th"]:focus {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

.gsi-button:focus {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

/* Animation für Updates */
.gsi-table.gsi-updating {
    animation: gsi-pulse 1s ease-in-out;
}

@keyframes gsi-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Print Styles */
@media print {
    .gsi-controls {
        display: none !important;
    }
    
    .gsi-table {
        border-collapse: collapse;
        page-break-inside: avoid;
    }
    
    .gsi-table td.de:hover,
    .gsi-table td.en:hover,
    .gsi-table td.th:hover {
        background-color: transparent !important;
    }
    
    .gsi-status {
        display: none !important;
    }
}

/* Debug-Modus */
.gsi-debug-info {
    background: #f0f0f0;
    border: 1px solid #ccc;
    padding: 10px;
    margin: 10px 0;
    font-family: monospace;
    font-size: 12px;
    border-radius: 4px;
}

.gsi-debug-info pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}