/**
 * Единые стили модальных окон для всего проекта
 * Этап 1.4: Модалки
 * 
 * Использованы лучшие стили:
 * - Анимация: modalSlideUp из Messenger/Groups
 * - Close button: rotate эффект
 * - Glass фон: с градиентом
 */

/* ==================== МОДАЛЬНОЕ ОКНО ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.with-backdrop {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-overlay.active {
    opacity: 1;
    display: flex;
}

/* ==================== RUNTIME OVERLAY CONTRACT ==================== */

.runtime-overlay-backdrop {
    background: rgba(2, 6, 23, 0.58);
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
}

.runtime-panel-surface {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(17, 24, 39, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    box-shadow: 0 28px 70px rgba(2, 6, 23, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(18px) saturate(165%);
    -webkit-backdrop-filter: blur(18px) saturate(165%);
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

.runtime-panel-title {
    color: #f8fafc;
    text-wrap: balance;
}

.runtime-panel-label {
    color: #cbd5e1;
}

.runtime-panel-meta {
    color: #94a3b8;
}

.runtime-panel-time {
    color: #64748b;
}

.runtime-panel-field {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.runtime-panel-field::placeholder {
    color: #94a3b8;
}

.runtime-panel-secondary-btn {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.runtime-panel-secondary-btn:hover {
    background: rgba(255, 255, 255, 0.11);
}

.runtime-panel-secondary-btn:active {
    transform: scale(0.96);
}

.runtime-panel-list-row {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: inherit;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.runtime-panel-list-row:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(96, 165, 250, 0.26);
    transform: translateY(-1px);
}

.runtime-panel-close-btn {
    color: #94a3b8;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.runtime-panel-close-btn:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.08);
    transform: rotate(90deg);
}

.runtime-panel-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
    color: inherit;
}

.runtime-panel-card-soft {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: inherit;
}

.runtime-panel-card-accent {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(96, 165, 250, 0.18);
    color: inherit;
}

.runtime-panel-stat-number {
    color: #f8fafc;
}

.runtime-panel-progress-track {
    background: rgba(148, 163, 184, 0.18);
}

.runtime-panel-preview {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .runtime-overlay-backdrop {
    background: rgba(226, 232, 240, 0.78);
    backdrop-filter: blur(14px) saturate(170%);
    -webkit-backdrop-filter: blur(14px) saturate(170%);
}

html[data-theme="light"] .runtime-panel-surface {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border-color: rgba(148, 163, 184, 0.2);
    color: #0f172a;
    box-shadow: 0 26px 52px rgba(148, 163, 184, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.96);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

html[data-theme="light"] .runtime-panel-title {
    color: #0f172a;
}

html[data-theme="light"] .runtime-panel-label {
    color: #475569;
}

html[data-theme="light"] .runtime-panel-meta {
    color: #475569;
}

html[data-theme="light"] .runtime-panel-time {
    color: #64748b;
}

html[data-theme="light"] .runtime-panel-field {
    background: rgba(255, 255, 255, 0.84);
    border-color: rgba(148, 163, 184, 0.22);
    color: #0f172a;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] .runtime-panel-field::placeholder {
    color: #64748b;
}

html[data-theme="light"] .runtime-panel-secondary-btn {
    background: rgba(226, 232, 240, 0.82);
    color: #0f172a;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .runtime-panel-secondary-btn:hover {
    background: rgba(203, 213, 225, 0.9);
}

html[data-theme="light"] .runtime-panel-list-row {
    background: rgba(248, 250, 252, 0.88);
    border-color: rgba(203, 213, 225, 0.9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .runtime-panel-list-row:hover {
    background: rgba(241, 245, 249, 0.95);
    border-color: rgba(59, 130, 246, 0.22);
}

html[data-theme="light"] .runtime-panel-card {
    background: rgba(248, 250, 252, 0.96);
    border-color: rgba(203, 213, 225, 0.9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .runtime-panel-card-soft {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(226, 232, 240, 0.95);
}

html[data-theme="light"] .runtime-panel-card-accent {
    background: rgba(219, 234, 254, 0.72);
    border-color: rgba(147, 197, 253, 0.9);
}

html[data-theme="light"] .runtime-panel-stat-number {
    color: #0f172a;
}

html[data-theme="light"] .runtime-panel-progress-track {
    background: rgba(203, 213, 225, 0.72);
}

html[data-theme="light"] .runtime-panel-preview {
    background: rgba(248, 250, 252, 0.94);
    border-color: rgba(203, 213, 225, 0.9);
}

html[data-theme="light"] .runtime-panel-close-btn {
    color: #64748b;
}

html[data-theme="light"] .runtime-panel-close-btn:hover {
    color: #0f172a;
    background: rgba(226, 232, 240, 0.8);
}

/* ==================== МОДАЛЬНЫЙ КОНТЕЙНЕР ==================== */

.modal-container,
.modal-content {
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(15, 15, 15, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

/* Анимация появления модалки */
@keyframes modalSlideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #e0e0e0;
    margin: 0;
}

.modal-close,
.modal-close-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s ease;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover,
.modal-close-btn:hover {
    color: #fff;
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    color: #e0e0e0;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: rgba(0, 0, 0, 0.2);
}

.modal-footer .btn {
    min-width: 100px;
}

/* Размеры модалок */
.modal-container.max-w-md {
    max-width: 28rem;
}

.modal-container.max-w-2xl {
    max-width: 42rem;
}

.modal-container.max-w-4xl {
    max-width: 56rem;
}

.modal-container.max-w-full {
    max-width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
}

/* Кнопки */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(248, 113, 113, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.4);
}

/* Анимации */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .modal-container {
        max-width: 95% !important;
        margin: 10px;
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 16px;
    }

    .modal-title {
        font-size: 18px;
    }
}

/* ==================== LIGHT THEME ==================== */

html[data-theme="light"] .modal-overlay.with-backdrop {
    background: rgba(226, 232, 240, 0.62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

html[data-theme="light"] .modal-container,
html[data-theme="light"] .modal-content {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 247, 251, 0.98));
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: 0 28px 60px rgba(148, 163, 184, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .modal-header {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(14, 165, 233, 0.05) 100%);
    border-bottom-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="light"] .modal-title,
html[data-theme="light"] .modal-body {
    color: #0f172a;
}

html[data-theme="light"] .modal-close,
html[data-theme="light"] .modal-close-btn {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(148, 163, 184, 0.2);
    color: #475569;
    box-shadow: 0 10px 22px rgba(148, 163, 184, 0.12);
}

html[data-theme="light"] .modal-close:hover,
html[data-theme="light"] .modal-close-btn:hover {
    color: #b91c1c;
    background: rgba(254, 226, 226, 0.88);
    border-color: rgba(248, 113, 113, 0.28);
}

html[data-theme="light"] .modal-body::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.72);
}

html[data-theme="light"] .modal-body::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.34);
}

html[data-theme="light"] .modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.48);
}

html[data-theme="light"] .modal-footer {
    background: rgba(248, 250, 252, 0.92);
    border-top-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="light"] .btn-secondary {
    background: rgba(255, 255, 255, 0.86);
    color: #334155;
    border-color: rgba(148, 163, 184, 0.18);
    box-shadow: 0 12px 26px rgba(148, 163, 184, 0.12);
}

html[data-theme="light"] .btn-secondary:hover {
    background: rgba(241, 245, 249, 0.96);
}









