/* Thai-German Learning - Frontend Styles v2.2 */

/* Error Messages */
.tglg-error {
    padding: 20px;
    background: #fee;
    border: 2px solid #c33;
    border-radius: 8px;
    color: #c33;
    text-align: center;
    font-weight: 500;
}

/* Index/Table of Contents Page */
.tglg-index-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.tglg-index-title {
    text-align: center;
    font-size: 32px;
    margin-bottom: 40px;
    color: #1a1a1a;
}

.tglg-index-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.tglg-index-item {
    display: block;
    padding: 30px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 2px solid #ddd;
    border-radius: 12px;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: 5px 5px 10px rgba(0,0,0,0.1),
                -2px -2px 5px rgba(255,255,255,0.7);
    position: relative;
}

.tglg-index-item:hover {
    transform: translateY(-5px);
    box-shadow: 8px 8px 15px rgba(0,0,0,0.15),
                -3px -3px 8px rgba(255,255,255,0.8);
}

.index-item-number {
    position: absolute;
    top: 10px;
    left: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #666;
}

.index-item-title-de {
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 10px;
}

.index-item-title-th {
    font-size: 18px;
    color: #666;
}

/* Game Container */
.tglg-game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: Arial, sans-serif;
}

/* Title Bar */
.tglg-title-bar {
    background: linear-gradient(135deg, #c41e3a 0%, #8b0000 100%);
    color: white;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 15px;
}

.title-number {
    font-size: 36px;
    font-weight: bold;
    opacity: 0.9;
    min-width: 50px;
}

.title-content {
    flex: 1;
}

.title-de {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 8px;
}

.title-th {
    font-size: 18px;
    opacity: 0.95;
}

/* Tab Navigation */
.tglg-tabs {
    display: flex;
    background: #f0f0f0;
    border-bottom: 3px solid #ddd;
}

.tglg-tab {
    flex: 1;
    padding: 15px 10px;
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    border: 2px solid #aaa;
    border-bottom: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: #333;
    transition: all 0.2s ease;
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.2),
                inset 2px 2px 5px rgba(255,255,255,0.7);
}

.tglg-tab:hover {
    background: linear-gradient(145deg, #d0d0d0, #b0b0b0);
}

.tglg-tab.active {
    background: linear-gradient(145deg, #4a9eff, #0066cc);
    color: white;
    border-color: #0066cc;
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.3),
                inset 2px 2px 5px rgba(255,255,255,0.3);
}

.tab-subtitle {
    display: block;
    font-size: 11px;
    font-weight: normal;
    margin-top: 4px;
    opacity: 0.9;
}

/* Tab Content */
.tglg-tab-content {
    display: none;
    background: #f9f9f9;
    padding: 30px;
    min-height: 500px;
}

.tglg-tab-content.active {
    display: block;
}

/* ===== ALL WORDS TABLE ===== */
.tglg-words-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tglg-words-table tr {
    border-bottom: 1px solid #e0e0e0;
}

.tglg-words-table tr:hover {
    background: #f5f5f5;
}

.tglg-words-table tr.empty-row {
    background: transparent;
    border: none;
}

.tglg-words-table tr.empty-row td {
    padding: 10px;
}

.tglg-words-table td {
    padding: 12px 16px;
    border-right: 1px solid #e0e0e0;
    vertical-align: middle;
}

.tglg-words-table td:last-child {
    border-right: none;
}

.tglg-words-table td.has-play {
    padding-left: 16px;
}

.tglg-words-table td:nth-child(1) {
    font-size: 18px;
    font-weight: 500;
    width: 25%;
}

.tglg-words-table td:nth-child(2),
.tglg-words-table td:nth-child(3) {
    font-weight: 500;
    width: 37.5%;
}

/* Play Button in Table - NO JUMP */
.play-btn-table {
    background: linear-gradient(145deg, #ffd700, #ffb700);
    border: 2px solid #cc9500;
    color: #654800;
    width: 35px;
    height: 35px;
    min-width: 35px;
    min-height: 35px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-right: 10px;
    box-shadow: 3px 3px 6px rgba(0,0,0,0.2),
                inset -1px -1px 3px rgba(0,0,0,0.2),
                inset 1px 1px 3px rgba(255,255,255,0.5);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.play-btn-table:hover {
    background: linear-gradient(145deg, #ffe44d, #ffc700);
}

.play-btn-table:active {
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.3);
}

.play-btn-table.speaking {
    background: linear-gradient(145deg, #90ee90, #70d070);
    border-color: #50b050;
}

.cell-content {
    display: inline;
    vertical-align: middle;
}

/* ===== GAME TABS (Thai→Deutsch, Deutsch→Thai, Hören 1, Hören 2) ===== */

/* Question Box */
.question-box {
    background: linear-gradient(135deg, #c41e3a 0%, #8b0000 100%);
    color: white;
    font-size: 42px;
    font-weight: bold;
    text-align: center;
    padding: 50px 40px;
    border-radius: 12px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.3),
                inset 0 -3px 10px rgba(0,0,0,0.2);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.4;
    margin-bottom: 15px;
}

/* Multi-line question box for Deutsch→Thai */
.question-box-multiline {
    flex-direction: column;
    gap: 10px;
    font-size: 36px;
    line-height: 1.3;
}

/* Question Buttons (below question) */
.question-buttons {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
}

/* Answer Grid */
.answer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px 20px;
    margin-bottom: 30px;
}

/* Answer Item */
.answer-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Answer Content Box */
.answer-content {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 3px solid #ccc;
    border-radius: 12px;
    padding: 35px 20px;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
    transition: all 0.3s ease;
    box-shadow: 5px 5px 10px rgba(0,0,0,0.1),
                inset -2px -2px 5px rgba(0,0,0,0.05),
                inset 2px 2px 5px rgba(255,255,255,0.7);
}

/* Answer Item States */
.answer-item.correct .answer-content {
    background: linear-gradient(145deg, #c8e6c9, #a5d6a7);
    border-color: #66bb6a;
    animation: pulse-correct 0.5s ease;
}

.answer-item.incorrect .answer-content {
    background: linear-gradient(145deg, #ffcc80, #ffb74d);
    border-color: #ff9800;
    animation: shake 0.5s ease;
}

@keyframes pulse-correct {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Answer Buttons (below answer content) */
.answer-buttons {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

/* Game Buttons - NO JUMP ON HOVER/CLICK */
.play-btn-game,
.select-btn-game {
    flex: 1;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    border: 2px solid;
}

/* Yellow Play Button */
.play-btn-game {
    background: linear-gradient(145deg, #ffd700, #ffb700);
    border-color: #cc9500;
    color: #654800;
    box-shadow: 3px 3px 6px rgba(0,0,0,0.2),
                inset -1px -1px 3px rgba(0,0,0,0.2),
                inset 1px 1px 3px rgba(255,255,255,0.5);
}

.play-btn-game:hover {
    background: linear-gradient(145deg, #ffe44d, #ffc700);
}

.play-btn-game:active {
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.3);
}

.play-btn-game.speaking {
    background: linear-gradient(145deg, #90ee90, #70d070);
    border-color: #50b050;
}

/* Blue Select Button - NO SPEAKER ICON */
.select-btn-game {
    background: linear-gradient(145deg, #4a9eff, #0066cc);
    border-color: #0055aa;
    color: white;
    box-shadow: 3px 3px 6px rgba(0,0,0,0.2),
                inset -1px -1px 3px rgba(0,0,0,0.2),
                inset 1px 1px 3px rgba(255,255,255,0.3);
}

.select-btn-game:hover {
    background: linear-gradient(145deg, #5aaeff, #1177dd);
}

.select-btn-game:active {
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.3);
}

/* Game Navigation */
.game-nav {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 30px;
}

.game-nav button {
    padding: 15px 40px;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(145deg, #90ee90, #70d070);
    border: 3px solid #50b050;
    border-radius: 10px;
    color: #1a5c1a;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 4px 4px 8px rgba(0,0,0,0.2),
                inset -2px -2px 4px rgba(0,0,0,0.1),
                inset 2px 2px 4px rgba(255,255,255,0.5);
    text-align: center;
    line-height: 1.4;
}

.game-nav button:hover:not(:disabled) {
    background: linear-gradient(145deg, #a0ffa0, #80e080);
}

.game-nav button:active:not(:disabled) {
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.2);
}

.game-nav button:disabled {
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
    color: #999;
    border-color: #aaa;
    cursor: not-allowed;
    opacity: 0.5;
}

.game-nav .thai-text {
    display: block;
    font-size: 13px;
    font-weight: normal;
    margin-top: 4px;
}

/* Footer */
.tglg-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid #ddd;
}

.btn-reset,
.btn-toc {
    padding: 12px 30px;
    font-size: 15px;
    font-weight: 600;
    background: linear-gradient(145deg, #f0f0f0, #d0d0d0);
    border: 3px solid #aaa;
    border-radius: 8px;
    color: #333;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s ease;
    box-shadow: 3px 3px 6px rgba(0,0,0,0.2),
                inset -1px -1px 3px rgba(0,0,0,0.1),
                inset 1px 1px 3px rgba(255,255,255,0.6);
    text-align: center;
    line-height: 1.4;
}

.btn-reset:hover,
.btn-toc:hover {
    background: linear-gradient(145deg, #e0e0e0, #c0c0c0);
}

.btn-reset:active,
.btn-toc:active {
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.2);
}

.btn-toc .thai-text {
    display: block;
    font-size: 12px;
    font-weight: normal;
    margin-top: 3px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .tglg-game-container {
        padding: 15px;
    }
    
    .question-box {
        font-size: 36px;
        padding: 40px 30px;
    }
    
    .answer-content {
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .tglg-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .tglg-tab {
        font-size: 12px;
        padding: 12px 8px;
        white-space: nowrap;
    }
    
    .answer-grid {
        grid-template-columns: 1fr;
    }
    
    .game-nav {
        flex-direction: column;
        gap: 15px;
    }
    
    .game-nav button {
        width: 100%;
    }
    
    .question-box {
        font-size: 28px;
        padding: 30px 20px;
    }
}

/* v2.2.1 - Smaller font for bilingual buttons */
.play-btn-game,
.select-btn-game {
    font-size: 13px;
    line-height: 1.3;
}

/* v2.4 - SPA Mode Styles */

/* SPA Container */
.tglg-spa-container {
    position: relative;
    min-height: 400px;
}

/* Views */
.tglg-view {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s 0.2s;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.tglg-view.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease;
    position: relative;
}

/* Loading Indicator */
.tglg-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

/* Index items - remove target blank indicator */
.tglg-index-item {
    text-decoration: none;
    cursor: pointer;
}

.tglg-index-item:hover {
    transform: translateY(-3px);
}

/* Standalone mode */
.tglg-standalone-container .btn-toc {
    display: none;
}

/* Ensure footer buttons are visible in SPA mode */
.tglg-spa-container .btn-toc {
    display: inline-block;
}

/* v2.5 - Top Buttons & Auto-fit Columns */

/* Top Buttons (above title) */
.tglg-top-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 0;
}

.btn-toc-top,
.btn-reset-top {
    flex: 1;
    height: 40px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.btn-toc-top {
    border-color: #2271b1;
    color: #2271b1;
}

.btn-toc-top:hover {
    background: #2271b1;
    color: white;
}

.btn-reset-top {
    border-color: #d63638;
    color: #d63638;
}

.btn-reset-top:hover {
    background: #d63638;
    color: white;
}

/* Auto-fit columns for "alle Wörter" table */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tglg-words-table {
    table-layout: auto !important;
    width: 100%;
}

.tglg-words-table td {
    white-space: nowrap;
    padding: 10px 15px;
}

.tglg-words-table .cell-content {
    display: inline;
    white-space: normal;
    word-wrap: break-word;
}

/* Mobile: horizontal scroll for table */
@media (max-width: 768px) {
    .table-wrapper {
        overflow-x: scroll;
    }
    
    .tglg-words-table {
        min-width: 600px;
    }
}
