/* ============================================================================
   MODALS & CONTEXT WINDOWS - UNIFIED STYLING
   Einheitliches Styling für alle Modals, Dialoge und Context-Fenster
   Version: 1.0.0
   ============================================================================ */

/* ========== Modal Overlay & Base ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1;
}

/* ========== Modal Dialog ========== */
.modal-dialog {
    position: relative;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    z-index: 2;
    border: 1px solid var(--border-color);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ========== Modal Header ========== */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 16px 16px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

/* ========== Modal Body ========== */
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Custom scrollbar for modal body */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ========== Modal Footer ========== */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: 0 0 16px 16px;
}

/* ========== Assignment/Selection Modals ========== */
.assignment-modal-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.assignment-modal-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: normal;
}

/* ========== Checklist Container ========== */
.checklist-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checklist-search {
    position: relative;
}

.checklist-search input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.938rem;
    transition: all 0.2s;
}

.checklist-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(222, 12, 21, 0.1);
}

.checklist-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.checklist-search-icon svg {
    width: 18px;
    height: 18px;
}

/* ========== Checklist Items ========== */
.checklist {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.checklist-item:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    transform: translateX(2px);
}

.checklist-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--primary-color);
}

.checklist-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.checklist-item-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.938rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.checklist-item-desc {
    font-size: 0.813rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.checklist-item-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(222, 12, 21, 0.1);
    color: var(--primary-color);
}

/* Empty state */
.checklist-empty {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.checklist-empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

.checklist-empty-text {
    font-size: 0.938rem;
    margin-bottom: 0.5rem;
}

.checklist-empty-hint {
    font-size: 0.813rem;
    color: var(--text-secondary);
}

/* Loading state */
.checklist-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
}

.checklist-loading .loading-spinner {
    width: 32px;
    height: 32px;
}

/* ========== Modal Sizes ========== */
.modal-dialog.modal-sm {
    max-width: 400px;
}

.modal-dialog.modal-md {
    max-width: 600px;
}

.modal-dialog.modal-lg {
    max-width: 800px;
}

.modal-dialog.modal-xl {
    max-width: 1000px;
}

.modal-dialog.modal-fullscreen {
    max-width: 95vw;
    max-height: 95vh;
}

/* ========== Confirmation Modals ========== */
.modal-dialog.modal-confirm {
    max-width: 450px;
}

.modal-confirm .modal-body {
    text-align: center;
    padding: 2rem;
}

.modal-confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    padding: 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-confirm-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.modal-confirm-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.modal-confirm-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.modal-confirm-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.modal-confirm-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.modal-confirm-message {
    font-size: 0.938rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ========== Responsive Design ========== */
@media (max-width: 768px) {
    .modal {
        padding: 0.5rem;
    }
    
    .modal-dialog {
        max-width: 100%;
        max-height: 95vh;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer button {
        width: 100%;
    }
    
    .checklist {
        max-height: 300px;
    }
}

/* ========== Dark Mode Specific ========== */
[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .modal-dialog {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .checklist-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* ========== Accessibility ========== */
.modal[aria-hidden="true"] {
    display: none;
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-dialog:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========== Print Styles ========== */
@media print {
    .modal,
    .modal-overlay {
        display: none !important;
    }
}

/* ========== Animations ========== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.modal.active .modal-dialog {
    animation: slideUp 0.3s ease;
}

/* ========== Loading Spinner for Modals ========== */
.modal .loading-spinner {
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

