/* Scribigo Favorites Styles */

/* ===== HAUPTCONTAINER ===== */
.scribigo-favorites-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

/* ===== HEADER ===== */
.favorites-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    border-bottom: 1px solid #e5e7eb;
}

.favorites-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.favorites-icon {
    font-size: 1.25rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.add-favorite-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    backdrop-filter: blur(10px);
}

.add-favorite-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.add-favorite-btn .btn-icon {
    font-size: 1rem;
    font-weight: 700;
}

/* ===== FAVORITEN LISTE ===== */
.favorites-list {
    padding: 1.5rem;
}

.no-favorites {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
    font-style: italic;
}

.no-favorites p {
    margin: 0;
    font-size: 0.9rem;
}

/* ===== FAVORITEN KARTEN ===== */
.favorite-card {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.favorite-card:last-child {
    margin-bottom: 0;
}

.favorite-card:hover {
    border-color: #fbbf24;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.2);
    transform: translateY(-1px);
}

.favorite-content {
    flex: 1;
    padding: 1rem;
    cursor: pointer;
    min-width: 0; /* Für text-overflow */
}

.favorite-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    word-break: break-word;
}

.favorite-details {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.mode-name {
    color: #6b7280;
    font-size: 0.8rem;
    background: #e5e7eb;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-weight: 500;
}

.has-instruction,
.has-language {
    font-size: 0.9rem;
    opacity: 0.8;
    cursor: help;
}

/* ===== AKTIONEN ===== */
.favorite-actions {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.favorite-card:hover .favorite-actions {
    opacity: 1;
}

.action-btn {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.rename-btn:hover {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.delete-btn:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}

/* ===== RENAME INPUT ===== */
.rename-input {
    background: white;
    border: 2px solid #3b82f6;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    width: 100%;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.rename-input:focus {
    outline: none;
    border-color: #1d4ed8;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.2);
}

/* ===== MODAL ===== */
/* Reset transforms für Container die das Modal beeinflussen könnten */
.scribigo-mode-selector-container,
.scribigo-favorites-section,
.category,
.category-header,
.modes-grid {
    transform: none !important;
}

/* Alternative: Nur wenn Modal aktiv ist */
body.modal-open .scribigo-mode-selector-container,
body.modal-open .scribigo-favorites-section {
    transform: none !important;
}


/* Modal Styles - Sicherstellen dass es über allem liegt */
.scribigo-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999 !important; /* Sehr hoher z-index */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.scribigo-modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;
    z-index: 2;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.scribigo-modal.active .modal-content {
    transform: scale(1);
}

/* Sicherstellen dass keine parent-transforms das Modal beeinflussen */
body > .scribigo-modal {
    transform: none !important;
}

/* Scrollbar styling für Modal */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Mobile Anpassungen */
@media (max-width: 600px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 1rem;
    }
}


.modal-header {
    padding: 1.5rem 1.5rem 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    margin: 0;
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #374151;
}

.modal-body {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.favorite-name-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.favorite-name-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ===== EINSTELLUNGEN VORSCHAU ===== */
.settings-preview {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}

.settings-preview h5 {
    margin: 0 0 0.75rem 0;
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    font-size: 0.85rem;
}

.setting-label {
    color: #6b7280;
    font-weight: 500;
    flex-shrink: 0;
}

.setting-value {
    color: #1f2937;
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

.instruction-preview {
    font-style: italic;
    color: #4b5563 !important;
    font-weight: 400 !important;
    line-height: 1.4;
    max-width: 250px;
}

/* ===== MODAL FOOTER ===== */
.modal-footer {
    padding: 0 1.5rem 1.5rem 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.primary-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.secondary-btn {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

/* ===== LOADING STATES ===== */
.scribigo-favorites-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

.loading-text {
    color: #374151;
    font-weight: 500;
}

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

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .favorites-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        text-align: center;
    }
    
    .add-favorite-btn {
        justify-content: center;
    }
    
    .favorites-list {
        padding: 1rem;
    }
    
    .favorite-card {
        flex-direction: column;
        align-items: stretch;
    }
    
    .favorite-content {
        padding: 1rem 1rem 0.5rem 1rem;
    }
    
    .favorite-actions {
        opacity: 1;
        justify-content: center;
        padding: 0.5rem 1rem 1rem 1rem;
        border-top: 1px solid #e5e7eb;
        margin-top: 0.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .setting-item {
        flex-direction: column;
        gap: 0.25rem;
        align-items: stretch;
    }
    
    .setting-value {
        text-align: left;
    }
    
    .instruction-preview {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .favorites-header {
        padding: 1rem;
    }
    
    .favorites-header h3 {
        font-size: 0.9rem;
    }
    
    .add-favorite-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .favorites-list {
        padding: 0.75rem;
    }
    
    .favorite-card {
        margin-bottom: 0.5rem;
    }
    
    .favorite-name {
        font-size: 0.85rem;
    }
    
    .mode-name {
        font-size: 0.75rem;
    }
    
    .modal-header h4 {
        font-size: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .primary-btn,
    .secondary-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===== ACCESSIBILITY ===== */
.favorite-card:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.add-favorite-btn:focus,
.action-btn:focus,
.primary-btn:focus,
.secondary-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.favorite-name-input:focus {
    outline: none; /* Custom focus bereits definiert */
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .favorite-card {
        border-color: #000000;
    }
    
    .favorites-header {
        background: #1f2937;
        border-bottom-color: #000000;
    }
    
    .add-favorite-btn {
        background: rgba(255, 255, 255, 0.9);
        color: #000000;
        border-color: #000000;
    }
    
    .action-btn {
        border-color: #000000;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    .scribigo-modal,
    .modal-content,
    .favorite-card,
    .action-btn,
    .add-favorite-btn {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}

/* ===== INTEGRATION MIT BESTEHENDEN STYLES ===== */
.scribigo-mode-selector-container + .scribigo-favorites-section {
    margin-top: -0.5rem; /* Überlappung vermeiden */
}

/* Falls Favoriten oberhalb der Modi angezeigt werden */
.scribigo-mode-selector-container .scribigo-favorites-section {
    order: -1;
    margin-bottom: 1.5rem;
    margin-top: 0;
}

