/**
 * Base Modal Styles
 * Foundation styles for all modal dialogs
 * Uses color variables from /styles/base/colors.css
 */

@import url('../base/colors.css');
@import url('../base/design-tokens.css');

/* ========================================
   MODAL CONTAINER & OVERLAY
   ======================================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-high);
    padding: var(--space-md);
}

/* ========================================
   MODAL CONTENT
   ======================================== */

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px var(--shadow-strong);
    animation: modalSlideIn 0.3s ease;
    overflow: hidden;
}

/* Size variants */
.modal-small {
    max-width: 500px;
}

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

/* ========================================
   ANIMATIONS
   ======================================== */

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

@keyframes modalFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ========================================
   MODAL HEADER
   ======================================== */

.modal-header {
    padding: var(--space-lg) 30px;
    background: var(--gradient-blue-purple);
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--white);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-weight: 600;
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.modal-header h2 i,
.modal-header h3 i {
    font-size: 1.4rem;
    color: var(--white);
}

/* Close button */
.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--white);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    line-height: 1;
    padding: 0;
    margin-left: var(--space-sm);
}

.modal-close:hover {
    opacity: 0.8;
    color: var(--white) !important;
    background: transparent !important;
}

.modal-close:focus {
    outline: none;
}

/* ========================================
   MODAL BODY
   ======================================== */

.modal-body {
    padding: var(--space-md);
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.modal-body p {
    margin: 0 0 var(--space-sm) 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

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

/* ========================================
   MODAL FOOTER
   ======================================== */

.modal-footer {
    padding: var(--space-md) 30px;
    border-top: 1px solid var(--gray-450);
    display: flex;
    gap: var(--space-xs);
    justify-content: flex-end;
    flex-shrink: 0;
}

.modal-footer button {
    /* Button classes from buttons.css handle their own styling */
    padding: var(--space-xs) 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    height: 36px;
    box-sizing: border-box;
    line-height: 1;
}

/* Ensure btn-primary gradient shows in modals */
.modal-footer button.btn-primary {
    background: var(--gradient-blue-purple) !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .modal {
        padding: var(--space-xs);
        align-items: flex-start;
        padding-top: 60px;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-md);
    }

    .modal-footer {
        flex-direction: column-reverse;
    }

    .modal-footer button {
        width: 100%;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Ensure focus is visible */
.modal-footer button:focus {
    outline: 2px solid var(--purple-primary);
    outline-offset: 2px;
}

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