/**
 * Unified Modal System for Fiacore
 * Provides consistent modal styling across the entire application
 * Uses Fiacore blue gradient theme (#dbeafe, #93c5fd, #3b82f6)
 */

/* ========== BASE MODAL STYLES ========== */
.fiacore-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fiacoreModalFadeIn 0.3s ease;
    align-items: center;
    justify-content: center;
}

.fiacore-modal.show {
    display: flex;
}

.fiacore-modal-content {
    background-color: white;
    margin: auto;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 450px;
    width: 95%;
    animation: fiacoreModalSlideDown 0.3s ease;
}

.fiacore-modal-header {
    background: linear-gradient(135deg, #dbeafe 0%, #93c5fd 100%);
    color: #1e40af;
    padding: 2rem 1.5rem;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.fiacore-modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #3b82f6;
}

.fiacore-modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #3b82f6;
}

.fiacore-modal-body {
    padding: 1.5rem;
    color: #374151;
    text-align: center;
    background: white;
    border-radius: 0 0 12px 12px;
}

.fiacore-modal-body p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
    font-weight: 400;
}

.fiacore-modal-actions {
    display: flex;
    gap: 12px;
    padding: 1.5rem;
    background: white;
    border-radius: 0 0 12px 12px;
    justify-content: center;
}

/* ========== LOADING DOTS ANIMATION ========== */
.fiacore-loading-dots {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    height: 3rem;
    width: 3rem;
    position: relative;
    margin: 0 0 0.5rem 0;
}

.fiacore-loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3b82f6;
    animation: fiacoreLoadingBounce 1.4s infinite;
}

.fiacore-loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.fiacore-loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.fiacore-loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ========== HEADER VARIANTS ========== */

/* Success Header (Green) */
.fiacore-modal-header.success {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #15803d;
}

.fiacore-modal-header.success h2 {
    color: #15803d;
}

.fiacore-modal-header.success .fiacore-modal-icon {
    color: #15803d;
}

/* Error/Danger Header (Red) */
.fiacore-modal-header.error,
.fiacore-modal-header.danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.fiacore-modal-header.error h2,
.fiacore-modal-header.danger h2 {
    color: #dc2626;
}

.fiacore-modal-header.error .fiacore-modal-icon,
.fiacore-modal-header.danger .fiacore-modal-icon {
    color: #dc2626;
}

/* Warning Header (Amber) */
.fiacore-modal-header.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #b45309;
}

.fiacore-modal-header.warning h2 {
    color: #b45309;
}

.fiacore-modal-header.warning .fiacore-modal-icon {
    color: #b45309;
}

/* Info Header (Blue - Default) */
.fiacore-modal-header.info {
    background: linear-gradient(135deg, #dbeafe 0%, #93c5fd 100%);
    color: #1e40af;
}

.fiacore-modal-header.info h2 {
    color: #3b82f6;
}

/* ========== BUTTON STYLES ========== */
.fiacore-modal-btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.fiacore-modal-btn-primary {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.fiacore-modal-btn-primary:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.fiacore-modal-btn-secondary {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0ff 100%);
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}

.fiacore-modal-btn-secondary:hover {
    background: linear-gradient(135deg, #e8f0ff 0%, #dfe9ff 100%);
    border-color: #93c5fd;
}

.fiacore-modal-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.fiacore-modal-btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
}

.fiacore-modal-btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.fiacore-modal-btn-success:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    transform: translateY(-1px);
}

/* ========== KEYFRAME ANIMATIONS ========== */
@keyframes fiacoreModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes fiacoreLoadingBounce {
    0%, 100% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(-8px); opacity: 0.7; }
}

/* ========== LEGACY CLASS ALIASES (for backward compatibility) ========== */
/* These map the old class names to the new unified system */

.save-loading-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fiacoreModalFadeIn 0.3s ease;
    align-items: center;
    justify-content: center;
}

.save-loading-modal.show {
    display: flex;
}

.save-loading-modal-content {
    background-color: white;
    margin: auto;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 450px;
    width: 95%;
    animation: fiacoreModalSlideDown 0.3s ease;
}

.save-loading-modal-header {
    background: linear-gradient(135deg, #dbeafe 0%, #93c5fd 100%);
    color: #1e40af;
    padding: 2rem 1.5rem;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.save-loading-modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #3b82f6;
}

.save-loading-modal-header.success {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #15803d;
}

.save-loading-modal-header.success h2 {
    color: #15803d;
}

.save-loading-modal-header.error,
.save-loading-modal-header.danger {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.save-loading-modal-header.error h2,
.save-loading-modal-header.danger h2 {
    color: #dc2626;
}

.save-loading-modal-header.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #b45309;
}

.save-loading-modal-header.warning h2 {
    color: #b45309;
}

.save-loading-modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #3b82f6;
}

.save-loading-modal-body {
    padding: 1.5rem;
    color: #374151;
    text-align: center;
    background: white;
    border-radius: 0 0 12px 12px;
}

.save-loading-modal-body p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.save-loading-dots {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    height: 3rem;
    width: 3rem;
    position: relative;
    margin: 0 0 0.5rem 0;
}

.save-loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3b82f6;
    animation: fiacoreLoadingBounce 1.4s infinite;
}

.save-loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.save-loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.save-loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Reset Modal Aliases (for reset_database.html compatibility) */
.reset-loading-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fiacoreModalFadeIn 0.3s ease;
    align-items: center;
    justify-content: center;
}

.reset-loading-modal.show {
    display: flex;
}

.reset-loading-modal-content {
    background-color: white;
    margin: auto;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 450px;
    width: 95%;
    animation: fiacoreModalSlideDown 0.3s ease;
}

.reset-loading-modal-header {
    background: linear-gradient(135deg, #dbeafe 0%, #93c5fd 100%);
    color: #1e40af;
    padding: 2rem 1.5rem;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.reset-loading-modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #3b82f6;
}

.reset-loading-modal-body {
    background: white;
    padding: 1.5rem;
    border-radius: 0 0 12px 12px;
    text-align: center;
    color: #374151;
}

.reset-loading-modal-body p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
    color: #374151;
}

.reset-loading-dots {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    height: 3rem;
    width: 3rem;
    position: relative;
    margin: 0 0 0.5rem 0;
}

.reset-loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3b82f6;
    animation: fiacoreLoadingBounce 1.4s infinite;
}

.reset-loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.reset-loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.reset-loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Message Modal (Confirmation/Success) */
.reset-message-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    animation: fiacoreModalFadeIn 0.3s ease;
}

.reset-message-modal.show {
    display: flex;
}

.reset-message-content {
    background-color: white;
    margin: auto;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 450px;
    width: 95%;
    animation: fiacoreModalSlideDown 0.3s ease;
}

.reset-message-header {
    background: linear-gradient(135deg, #dbeafe 0%, #93c5fd 100%);
    color: #1e40af;
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.reset-message-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
    color: #3b82f6;
}

.reset-message-header.confirm {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.reset-message-header.confirm h2 {
    color: #dc2626;
}

.reset-message-header.error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.reset-message-header.error h2 {
    color: #dc2626;
}

.reset-message-header.success {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #16a34a;
}

.reset-message-header.success h2 {
    color: #16a34a;
}

.reset-message-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.reset-message-body {
    padding: 1.5rem;
    text-align: center;
    background: white;
}

.reset-message-body p {
    margin: 0.5rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
}

.reset-message-actions {
    display: flex;
    gap: 12px;
    padding: 1rem 1.5rem 1.5rem;
    background: white;
    border-radius: 0 0 12px 12px;
    justify-content: center;
}

.reset-msg-delete {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-msg-delete:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
}

.reset-msg-cancel {
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0ff 100%);
    color: #3b82f6;
    border: 1px solid #bfdbfe;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-msg-cancel:hover {
    background: linear-gradient(135deg, #e8f0ff 0%, #dfe9ff 100%);
    border-color: #93c5fd;
}

/* Custom Alert Overlay */
.custom-alert-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10999;
}

.custom-alert-overlay.show {
    display: block;
}

.custom-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 11000;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: fiacoreModalSlideDown 0.3s ease;
}

.custom-alert.hidden {
    display: none;
}

.custom-alert-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.custom-alert-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.custom-alert-message {
    font-size: 0.95rem;
    color: #4b5563;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.custom-alert-button {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
    border: none;
    padding: 10px 32px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-alert-button:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    transform: translateY(-1px);
}

/* ========== RESPONSIVE STYLES ========== */
@media (max-width: 576px) {
    .fiacore-modal-content,
    .save-loading-modal-content,
    .reset-loading-modal-content,
    .reset-message-content {
        max-width: 95%;
        margin: 1rem;
    }

    .fiacore-modal-header,
    .save-loading-modal-header,
    .reset-loading-modal-header,
    .reset-message-header {
        padding: 1.5rem 1rem;
    }

    .fiacore-modal-body,
    .save-loading-modal-body,
    .reset-loading-modal-body,
    .reset-message-body {
        padding: 1rem;
    }

    .fiacore-modal-actions,
    .reset-message-actions {
        flex-direction: column;
        padding: 1rem;
    }

    .fiacore-modal-btn {
        width: 100%;
        justify-content: center;
    }
}
