/* ===================================
   Custom Modal System (Unified Architecture)
   =================================== */

/* 1. THE OVERLAY (Formerly .guardfolio-modal-overlay, now .guardfolio-modal)
   This is the container with the ID that jQuery toggles.
   It handles positioning (Fixed Fullscreen) and Centering (Flexbox).
*/
.guardfolio-modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 10000;

    /* Centering Logic */
    align-items: center;
    justify-content: center;

    /* Reset properties that might be leftovers from legacy CSS */
    transform: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    max-width: none !important;
    max-height: none !important;
    overflow: hidden !important;
    /* Prevent double scrollbars */
}

/* 
   FORCE FLEXBOX COMPATIBILITY
   jQuery's .show() sets 'display: block'. We override this to ensure 
   Flexbox centering always works when the element is visible.
*/
.guardfolio-modal.active,
.guardfolio-modal[style*="display: block"] {
    display: flex !important;
}

/* 2. THE CARD (Formerly .guardfolio-modal, now .guardfolio-modal-content)
   This is the actual white box containing the UI.
*/
.guardfolio-modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
    width: 90%;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    /* Prevent overflowing screen */
    position: relative;
    /* Animation */
    animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* 3. SIZE MODIFIERS
   Applied to the Outer .guardfolio-modal to control the Inner Content width.
*/
.guardfolio-modal-sm .guardfolio-modal-content {
    max-width: 450px;
}

.guardfolio-modal-md .guardfolio-modal-content {
    max-width: 600px;
}

.guardfolio-modal-lg .guardfolio-modal-content {
    max-width: 900px;
}

.guardfolio-modal-xl .guardfolio-modal-content {
    max-width: 1200px;
}

/* Default fallback if no size class matches */
.guardfolio-modal:not([class*="guardfolio-modal-"]) .guardfolio-modal-content {
    max-width: 500px;
}


/* ===================================
   Start: Standard Inner Components
   =================================== */

/* Modal Header */
.guardfolio-modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    /* Sticky header needs bg */
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.guardfolio-modal-close {
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    margin-left: auto;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.guardfolio-modal-close:hover {
    background: #f3f4f6;
    color: #ef4444;
}

/* Modal Body */
.guardfolio-modal-body {
    padding: 24px;
    color: #374151;
    font-size: 15px;
    line-height: 1.6;
    overflow-y: auto;
    /* Scroll ONLY the body */
    flex: 1;
    /* Take remaining space */
}

/* Modal Footer */
.guardfolio-modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
    flex-shrink: 0;
}

/* Icons & Buttons (retained from previous) */
.guardfolio-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.guardfolio-modal-icon.warning {
    background: #fef3c7;
    color: #d97706;
}

.guardfolio-modal-icon.success {
    background: #d1fae5;
    color: #059669;
}

.guardfolio-modal-icon.info {
    background: #dbeafe;
    color: #2563eb;
}

.guardfolio-modal-icon.error {
    background: #fee2e2;
    color: #dc2626;
}

.guardfolio-modal-title {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.guardfolio-modal-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 4px 0 0;
}

.guardfolio-modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.guardfolio-modal-btn:hover {
    transform: translateY(-1px);
}

.guardfolio-modal-btn-primary {
    background: #2563eb;
    color: white;
}

.guardfolio-modal-btn-primary:hover {
    background: #1d4ed8;
}

.guardfolio-modal-btn-success {
    background: #10b981;
    color: white;
}

.guardfolio-modal-btn-success:hover {
    background: #059669;
}

.guardfolio-modal-btn-danger {
    background: #ef4444;
    color: white;
}

.guardfolio-modal-btn-danger:hover {
    background: #dc2626;
}

.guardfolio-modal-btn-secondary {
    background: white;
    border: 1px solid #d1d5db;
    color: #374151;
}

.guardfolio-modal-btn-secondary:hover {
    background: #f3f4f6;
}


/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .guardfolio-modal-content {
        background: #1f2937;
        border: 1px solid #374151;
    }

    .guardfolio-modal-header {
        background: #1f2937;
        border-bottom-color: #374151;
    }

    .guardfolio-modal-footer {
        background: #111827;
        border-top-color: #374151;
    }

    .guardfolio-modal-title {
        color: #f9fafb;
    }

    .guardfolio-modal-subtitle,
    .guardfolio-modal-body {
        color: #d1d5db;
    }

    .guardfolio-modal-btn-secondary {
        background: #374151;
        border-color: #4b5563;
        color: white;
    }

    .guardfolio-modal-btn-secondary:hover {
        background: #4b5563;
    }
}