/**
 * Modal Component
 * Vanilla CSS modal system for forms and dialogs
 * Aligneer Design System v1.0
 *
 * Rules:
 *  - No hardcoded colours — CSS variables only.
 *  - Never redefine input / label / .form-group here;
 *    those come from core/inputs/*.css.
 */

/* ===== OVERLAY ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

/* ===== CONTAINER ===== */
.modal {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    position: relative;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

/* ===== HEADER ===== */
.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ===== BODY ===== */
.modal-body {
    padding: 1.5rem;
}

/* ===== FOOTER ===== */
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ===== LOADING STATE ===== */
.modal.loading {
    pointer-events: none;
    opacity: 0.6;
}

/* ===== SIZE VARIANTS ===== */
.modal.modal-lg {
    max-width: 900px;
}

.modal.modal-sm {
    max-width: 400px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .modal {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
}
