/* =================================================================
   UNIFIED MODAL SYSTEM
   Presentify - Apple-Inspired Design

   This is the ONLY modal system to use across the app.
   DO NOT create custom modals or use Bootstrap modals.

   Usage: Modal.show({ title, body, buttons })
   ================================================================= */

/* ===============================================================
   CSS Custom Properties
   =============================================================== */
:root {
    --modal-z-index: 99999;
    --modal-max-width: 480px;
    --modal-backdrop-blur: 10px;
    --modal-backdrop-opacity: 0.6;
    --modal-radius: 16px;
    --modal-padding: 24px;
    --modal-animation-duration: 0.3s;
}

/* ===============================================================
   Modal Wrapper (Fullscreen Overlay)
   =============================================================== */
.modal-unified-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--modal-z-index);
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--modal-animation-duration) ease,
                visibility var(--modal-animation-duration) ease;
}

.modal-unified-wrapper.show {
    opacity: 1;
    visibility: visible;
}

.modal-unified-wrapper.hiding {
    opacity: 0;
}

/* ===============================================================
   Modal Backdrop
   =============================================================== */
.modal-unified-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, var(--modal-backdrop-opacity));
    backdrop-filter: blur(var(--modal-backdrop-blur));
    -webkit-backdrop-filter: blur(var(--modal-backdrop-blur));
}

/* ===============================================================
   Modal Container
   =============================================================== */
.modal-unified-container {
    position: relative;
    width: 100%;
    max-width: var(--modal-max-width);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: #ffffff;
    border-radius: var(--modal-radius);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    transform: translateY(20px) scale(0.98);
    transition: transform var(--modal-animation-duration) cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-unified-wrapper.show .modal-unified-container {
    transform: translateY(0) scale(1);
}

.modal-unified-wrapper.hiding .modal-unified-container {
    transform: translateY(10px) scale(0.98);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .modal-unified-container {
        background: #1c1c1e;
        box-shadow:
            0 25px 50px -12px rgba(0, 0, 0, 0.5),
            0 0 0 1px rgba(255, 255, 255, 0.1);
    }
}

/* ===============================================================
   Modal Close Button
   =============================================================== */
.modal-unified-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 0;
}

.modal-unified-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #374151;
    transform: rotate(90deg);
}

.modal-unified-close:active {
    transform: rotate(90deg) scale(0.95);
}

.modal-unified-close:focus-visible {
    outline: 2px solid var(--accent-primary, #5569ff);
    outline-offset: 2px;
}

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

@media (prefers-color-scheme: dark) {
    .modal-unified-close {
        background: rgba(255, 255, 255, 0.1);
        color: #9ca3af;
    }

    .modal-unified-close:hover {
        background: rgba(255, 255, 255, 0.15);
        color: #d1d5db;
    }
}

/* ===============================================================
   Modal Header
   =============================================================== */
.modal-unified-header {
    padding: var(--modal-padding) var(--modal-padding) 12px;
    text-align: center;
}

.modal-unified-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    font-size: 28px;
}

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

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

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

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

.modal-unified-icon.premium {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 193, 7, 0.2));
    color: #f59e0b;
}

.modal-unified-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
    letter-spacing: -0.3px;
}

@media (prefers-color-scheme: dark) {
    .modal-unified-title {
        color: #f3f4f6;
    }
}

/* ===============================================================
   Modal Body
   =============================================================== */
.modal-unified-body {
    padding: 0 var(--modal-padding) var(--modal-padding);
    color: #4b5563;
    font-size: 15px;
    line-height: 1.6;
    text-align: center;
}

.modal-unified-body p {
    margin: 0 0 12px;
}

.modal-unified-body p:last-child {
    margin-bottom: 0;
}

@media (prefers-color-scheme: dark) {
    .modal-unified-body {
        color: #9ca3af;
    }
}

/* ===============================================================
   Modal Footer
   =============================================================== */
.modal-unified-footer {
    padding: 0 var(--modal-padding) var(--modal-padding);
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Stack buttons on mobile */
@media (max-width: 400px) {
    .modal-unified-footer {
        flex-direction: column;
    }
}

/* ===============================================================
   Modal Buttons
   =============================================================== */
.modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    min-width: 120px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.modal-btn:hover {
    transform: translateY(-1px);
}

.modal-btn:active {
    transform: translateY(0);
}

.modal-btn:focus-visible {
    outline: 2px solid var(--accent-primary, #5569ff);
    outline-offset: 2px;
}

/* Button Variants */
.modal-btn.primary {
    background: linear-gradient(135deg, #5569ff 0%, #6c5ce7 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(85, 105, 255, 0.3);
}

.modal-btn.primary:hover {
    box-shadow: 0 6px 20px rgba(85, 105, 255, 0.4);
}

.modal-btn.secondary {
    background: #f3f4f6;
    color: #374151;
}

.modal-btn.secondary:hover {
    background: #e5e7eb;
}

.modal-btn.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.modal-btn.success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.modal-btn.danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.modal-btn.danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.modal-btn.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.modal-btn.info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.modal-btn.ghost {
    background: transparent;
    color: #6b7280;
}

.modal-btn.ghost:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #374151;
}

/* Dark Mode Buttons */
@media (prefers-color-scheme: dark) {
    .modal-btn.secondary {
        background: #374151;
        color: #e5e7eb;
    }

    .modal-btn.secondary:hover {
        background: #4b5563;
    }

    .modal-btn.ghost {
        color: #9ca3af;
    }

    .modal-btn.ghost:hover {
        background: rgba(255, 255, 255, 0.1);
        color: #d1d5db;
    }
}

/* Full Width Button (mobile) */
@media (max-width: 400px) {
    .modal-btn {
        width: 100%;
    }
}

/* ===============================================================
   Modal Content Helpers
   =============================================================== */

/* Feature List */
.modal-feature-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    margin: 16px 0;
    padding: 0;
    list-style: none;
}

.modal-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.08);
    border-radius: 10px;
    font-size: 14px;
}

.modal-feature-item i,
.modal-feature-item svg {
    color: #10b981;
    flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
    .modal-feature-item {
        background: rgba(16, 185, 129, 0.15);
    }
}

/* Highlight Text */
.modal-highlight {
    color: #f59e0b;
    font-weight: 600;
}

/* Badge */
.modal-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #744210;
    font-size: 13px;
    font-weight: 600;
    border-radius: 20px;
}

/* Stats Row */
.modal-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 16px;
    margin: 16px 0;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
}

.modal-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.modal-stat-value {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
}

.modal-stat-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (prefers-color-scheme: dark) {
    .modal-stats {
        background: rgba(255, 255, 255, 0.05);
    }

    .modal-stat-value {
        color: #f3f4f6;
    }
}

/* Pricing Highlight */
.modal-pricing {
    padding: 16px;
    margin: 16px 0;
    background: linear-gradient(135deg, var(--accent-primary, #5569ff), var(--accent-secondary, #6c5ce7));
    border-radius: 12px;
    color: white;
    text-align: center;
}

.modal-pricing-text {
    font-size: 18px;
    margin: 0 0 4px;
}

.modal-pricing-text strong {
    font-size: 20px;
}

.modal-pricing-subtext {
    font-size: 13px;
    opacity: 0.8;
    margin: 0;
}

/* ===============================================================
   Modal Sizes
   =============================================================== */
.modal-unified-container.small {
    max-width: 360px;
}

.modal-unified-container.large {
    max-width: 600px;
}

.modal-unified-container.fullscreen {
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    height: calc(100vh - 32px);
}

/* ===============================================================
   Animations
   =============================================================== */
@keyframes modal-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.modal-unified-container.shake {
    animation: modal-shake 0.5s ease;
}

/* ===============================================================
   Accessibility & Reduced Motion
   =============================================================== */
@media (prefers-reduced-motion: reduce) {
    .modal-unified-wrapper,
    .modal-unified-container,
    .modal-btn {
        transition: opacity 0.1s ease;
    }

    .modal-unified-container {
        transform: none;
    }

    .modal-unified-wrapper.show .modal-unified-container,
    .modal-unified-wrapper.hiding .modal-unified-container {
        transform: none;
    }
}

/* Screen Reader Only */
.modal-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===============================================================
   Responsive Adjustments
   =============================================================== */
@media (max-width: 640px) {
    :root {
        --modal-padding: 20px;
        --modal-radius: 14px;
    }

    .modal-unified-wrapper {
        padding: 12px;
        align-items: flex-end;
    }

    .modal-unified-container {
        max-height: calc(100vh - 24px);
        border-radius: var(--modal-radius) var(--modal-radius) 0 0;
    }

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

    .modal-unified-body {
        font-size: 14px;
    }

    .modal-btn {
        padding: 14px 20px;
        font-size: 15px;
    }

    .modal-stats {
        flex-direction: column;
        gap: 12px;
    }
}

/* ===============================================================
   High Contrast Mode
   =============================================================== */
@media (prefers-contrast: high) {
    .modal-unified-container {
        border: 2px solid;
    }

    .modal-btn {
        border: 2px solid currentColor;
    }

    .modal-feature-item {
        border: 1px solid currentColor;
    }
}
