/* ===== Fumble Lab Styles ===== */

/* API Key Banner (ported from index.css and updated for Fumble Lab) */
.fumble-api-banner {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    text-align: center;
}

.fumble-api-banner p {
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    font-size: 0.9rem;
}

/* View Toggle */
.fumble-view-toggle {
    display: flex;
    gap: 0.4rem;
    padding: var(--space-xs);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}

.fumble-view-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.fumble-view-btn:hover {
    color: var(--text-light);
    border-color: var(--primary);
}

.fumble-view-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* View Switching */
.fumble-view {
    display: none;
}

.fumble-view.active {
    display: block;
}

/* Input Form */
.fumble-input-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.fumble-input-group label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.fumble-input-group textarea, 
.fumble-input-group input[type="text"] {
    width: 100%;
    padding: var(--space-sm);
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-family: var(--font-japanese);
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.fumble-input-group textarea:focus, 
.fumble-input-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

/* Formality Selector */
.formality-selector {
    display: flex;
    gap: 0.4rem;
}

.formality-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.formality-btn:hover {
    border-color: var(--primary);
    color: var(--text-light);
}

.formality-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Result Display */
.fumble-result {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-md);
    line-height: 1.6;
    font-size: 0.95rem;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease-out;
}

.fumble-result strong {
    color: var(--primary);
    display: block;
    margin-top: 0.75rem;
}

.fumble-result strong:first-child {
    margin-top: 0;
}

/* Loading state */
.fumble-result.loading {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

.fumble-result.loading::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* History Styles */
.fumble-history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-sm);
    max-height: 70vh;
    overflow-y: auto;
}

.fumble-history-item {
    background: hsl(220, 18%, 20%);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    border-left: 4px solid var(--border);
    transition: all 0.2s ease;
}

.fumble-history-item:hover {
    border-left-color: var(--primary);
    background: hsl(220, 18%, 25%);
}

.fumble-history-item.starred {
    border-left-color: #f5c518;
}

/* Star button inside each history card */
.fumble-item-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.fumble-star-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.2rem;
    color: var(--text-muted);
    transition: transform 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.fumble-star-btn:hover {
    transform: scale(1.2);
    color: #f5c518;
}

.fumble-star-btn.starred {
    color: #f5c518;
}

.fumble-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.fumble-preview {
    font-size: 0.9rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.3rem;
    font-family: var(--font-japanese);
}

.fumble-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.fumble-history-detail {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
    cursor: default;
}

.fumble-history-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
    padding: var(--space-md);
}

.fumble-empty-history {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: var(--space-xl);
}

/* Inline English translations (shared logic with app) */
.inline-en {
    color: var(--accent);
    font-size: 0.85em;
    opacity: 0.9;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .fumble-api-banner {
        border-radius: 0;
        margin: 0;
        border-left: none;
        border-right: none;
    }

    .fumble-view-toggle {
        border-radius: 0;
        margin: 0;
        border-bottom: 1px solid var(--border);
        padding: 0.5rem;
    }

    .fumble-input-form {
        border-radius: 0;
        padding: 1rem;
    }

    .fumble-result {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .fumble-history-list {
        max-height: none;
    }

    #fumblelab-mode.active {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 44px); /* Subtracting mode selector height */
        overflow-y: auto;
    }
}
