/* ============================================
   MIRACOLLO MODAL SYSTEM
   Unified modal styles following Jony Ive principles
   
   @version 2.0.0 - Advanced Features
   @date 2025-12-25
   @author Cervella 🧠
   
   Design Principles:
   - Simplicity: Clean, minimal design
   - Functionality: Design IS functionality
   - Details: Perfect micro-interactions
   - Animations: Smooth, premium transitions (0.4s cubic-bezier)
   - Space: Intelligent use of space
   
   v2.0 Features:
   - Draggable modals (drag by header)
   - Resizable modals (corner handles)
   - Multi-modal focus (click to bring front)
   
   Inherits tokens from planning.css:
   - Colors: var(--bg-secondary), var(--accent-primary)
   - Shadows: var(--shadow-lg)
   - Transitions: var(--transition-normal)
   - Z-Index: var(--z-modal) = 2000
   ============================================ */

/* ========== MODAL OVERLAY (Backdrop) ========== */
.miracollo-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 30, 0.25);
    /* 25% opacity - planning fully visible */
    /* No blur - planning information must be readable */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal, 2000);
    opacity: 0;
    /* § PIETRA FERMA: Minimal transition, only opacity */
    transition: opacity 0.15s ease;
    padding: 1rem;
}

.miracollo-modal-overlay.active {
    opacity: 1;
}

/* ========== MODAL CONTAINER ========== */
.miracollo-modal {
    background: var(--bg-secondary, #1a1a1a);
    border-radius: 16px;
    box-shadow: var(--shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.5));
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    /* § PIETRA FERMA: NO scale animation, instant appearance */
    transform: none;
    opacity: 1;
    transition: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* § PIETRA FERMA: Modal appears instantly, no animation needed */

/* ========== MODAL SIZES ========== */
.miracollo-modal--small {
    width: 100%;
    max-width: 400px;
}

.miracollo-modal--medium {
    width: 100%;
    max-width: 600px;
}

.miracollo-modal--large {
    width: 100%;
    max-width: 900px;
}

/* ========== MODAL HEADER ========== */
.miracollo-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color, #333333);
    flex-shrink: 0;
}

.miracollo-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    margin: 0;
}

.miracollo-modal-close {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all var(--transition-fast, 0.15s cubic-bezier(0.16, 1, 0.3, 1));
    flex-shrink: 0;
}

.miracollo-modal-close:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #ffffff;
    border-color: #ef4444;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.miracollo-modal-close:active {
    transform: scale(0.95);
}

/* ========== MODAL TABS ========== */
.miracollo-modal-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color, #333333);
    flex-shrink: 0;
    background: var(--bg-tertiary, #252525);
}

.miracollo-modal-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary, #a0a0a0);
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast, 0.15s cubic-bezier(0.16, 1, 0.3, 1));
    position: relative;
}

.miracollo-modal-tab:hover {
    color: var(--text-primary, #ffffff);
    background: rgba(255, 255, 255, 0.05);
}

.miracollo-modal-tab.active {
    color: var(--accent-primary, #6366f1);
    border-bottom-color: var(--accent-primary, #6366f1);
}

/* Smooth tab content transition */
.miracollo-modal-body {
    animation: fadeInTab 0.3s ease;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== MODAL BODY ========== */
.miracollo-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    /* Important for flex scrolling */
}

/* Smooth scrollbar */
.miracollo-modal-body::-webkit-scrollbar {
    width: 8px;
}

.miracollo-modal-body::-webkit-scrollbar-track {
    background: var(--bg-tertiary, #252525);
    border-radius: 4px;
}

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

.miracollo-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary, #6366f1);
}

/* ========== MODAL FOOTER ========== */
.miracollo-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color, #333333);
    flex-shrink: 0;
    background: var(--bg-tertiary, #252525);
    border-radius: 0 0 16px 16px;
}

/* ========== CONFIRM MODAL SPECIFIC ========== */
.confirm-message {
    font-size: 0.95rem;
    color: var(--text-secondary, #a0a0a0);
    line-height: 1.6;
    margin: 0.5rem 0;
}

/* ========== BUTTON STYLES (Generic) ========== */
.miracollo-modal-footer .btn-primary,
.miracollo-modal-footer .btn-secondary {
    padding: 0.625rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s cubic-bezier(0.16, 1, 0.3, 1));
    border: none;
    font-family: inherit;
}

.miracollo-modal-footer .btn-primary {
    background: var(--accent-primary, #6366f1);
    color: white;
}

.miracollo-modal-footer .btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.miracollo-modal-footer .btn-secondary {
    background: var(--bg-hover, #2d2d2d);
    color: var(--text-primary, #ffffff);
    border: 1px solid var(--border-color, #333333);
}

.miracollo-modal-footer .btn-secondary:hover {
    background: var(--bg-tertiary, #252525);
    border-color: var(--accent-primary, #6366f1);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .miracollo-modal {
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
    }

    .miracollo-modal--large,
    .miracollo-modal--medium {
        max-width: 100%;
    }

    .miracollo-modal-tabs {
        overflow-x: auto;
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
    }

    .miracollo-modal-tabs::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari */
    }

    .miracollo-modal-header {
        padding: 1.25rem;
    }

    .miracollo-modal-body {
        padding: 1.25rem;
    }

    .miracollo-modal-footer {
        padding: 1rem 1.25rem;
        flex-direction: column-reverse;
    }

    .miracollo-modal-footer .btn-primary,
    .miracollo-modal-footer .btn-secondary {
        width: 100%;
    }
}

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

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {

    .miracollo-modal-overlay,
    .miracollo-modal,
    .miracollo-modal-tab {
        transition: none;
    }
}

/* ========== ADVANCED FEATURES (v2.0) ========== */

/* Modal Pulse Animation (Focus Feedback) */
@keyframes modalPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 20px 30px rgba(0, 0, 0, 0.7), 0 0 0 2px var(--accent-primary, #6366f1);
    }
}