/**
 * Modals, Toasts, Alerts & Loading States
 * 
 * Overlay components including modals, notifications,
 * alerts, and loading indicators.
 * 
 * @package Silva_Customer_Portal
 * @version 2.0.0
 */

/* ========================================
   MODALS
   ======================================== */

.silva-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.silva-modal.is-open {
    display: flex;
}

.silva-modal[hidden] {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    cursor: pointer;
    z-index: var(--z-modal-backdrop);
}

.modal-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    z-index: var(--z-modal);
}

.modal-container-small {
    max-width: 500px;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--modal-radius);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.modal-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0;
}

.modal-icon {
    font-size: 32px;
    margin-right: var(--spacing-sm);
}

.modal-close {
    min-width: 40px;
    min-height: 40px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--button-radius);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-gray);
    border-color: var(--text-secondary);
}

.modal-close:focus-visible {
    outline: var(--focus-outline);
    outline-offset: 2px;
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-toast);
    max-width: 400px;
}

.toast {
    background: white;
    border-left: 4px solid var(--primary-blue);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    cursor: pointer;
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
}

.toast:hover {
    opacity: 0.95;
}

.toast.toast-success {
    border-left-color: var(--success-green);
}

.toast.toast-error {
    border-left-color: var(--danger-red);
}

.toast.toast-warning {
    border-left-color: var(--warning-yellow);
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.toast-message {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

/* ========================================
   ALERTS
   ======================================== */

.balance-alert {
    background: var(--warning-light);
    border: 1px solid var(--warning-yellow);
    border-left: 4px solid var(--warning-yellow);
    border-radius: var(--card-radius);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
}

.alert-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.alert-heading {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.alert-text {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    margin: 0;
}

/* ========================================
   LOADING STATES
   ======================================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: var(--z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay[hidden] {
    display: none;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--spacing-md);
}

.loading-text {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
}

/* Skeleton Loaders */
.loading-skeleton {
    display: inline-block;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.loading-skeleton-block {
    width: 100%;
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--card-radius);
}

.skeleton-card {
    width: 100%;
    height: 180px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--modal-radius);
    margin-bottom: var(--spacing-lg);
}

.skeleton-photo {
    aspect-ratio: 1;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--card-radius);
}
