/* =============================================
   PILAY - Modales, Overlays y Toasts
   ============================================= */

/* ===== OVERLAY BASE ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    backdrop-filter: blur(4px);
    padding: 1rem;
}

.overlay.active {
    display: flex;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    flex-direction: column;
}

.loading-content {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: var(--radius-xl);
    text-align: center;
    max-width: 400px;
    width: 100%;
    animation: modalIn 0.3s ease;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--pilay-primary);
    border-radius: 50%;
    margin: 0 auto 1.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* ===== MODAL ===== */
.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-xl);
    text-align: center;
    max-width: 450px;
    width: 100%;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 2rem;
}

.modal-icon.success {
    background: linear-gradient(135deg, var(--pilay-primary), var(--pilay-primary-dark));
    color: white;
}

.modal-icon.error {
    background: linear-gradient(135deg, var(--error), #dc2626);
    color: white;
}

.modal-icon.warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: white;
}

.modal-title {
    font-size: 1.375rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal-text {
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
    line-height: 1.6;
    font-size: 0.95rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-actions .btn {
    min-width: 110px;
}

/* ===== CONFIRM MODAL ===== */
.confirm-modal .modal-content {
    max-width: 380px;
    padding: 1.75rem;
}

.confirm-modal .modal-title {
    font-size: 1rem;
    text-align: left;
    margin-bottom: 0.5rem;
}

.confirm-modal .modal-text {
    text-align: left;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.confirm-modal .modal-actions {
    justify-content: flex-end;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-dark);
    color: white;
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 380px;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }

.toast-content { flex: 1; min-width: 0; }

.toast-message { font-size: 0.875rem; opacity: 0.95; }

.toast-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0.2rem;
    margin-left: 0.25rem;
    transition: color var(--transition-fast);
    font-size: 0.8rem;
}

.toast-close:hover { color: white; }

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--pilay-primary); }

@media (max-width: 480px) {
    .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
    .toast { max-width: none; }
}

/* ===== PREVIEW MODAL ===== */
.preview-modal-content {
    max-width: 860px;
    width: 100%;
    padding: 1.5rem;
    text-align: left;
}

.preview-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-modal-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 48px);
}

.preview-close-btn {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.preview-close-btn:hover {
    background: var(--error-bg);
    color: var(--error);
}

.preview-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 200px;
    max-height: 72vh;
    overflow: auto;
    border-radius: var(--radius-md);
    background: var(--bg-main);
}

/* ===== SEND / EXPORT SECTION ===== */
.send-section {
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-left: 4px solid var(--pilay-primary);
    border-radius: var(--radius-lg);
    padding: 1.125rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    box-shadow: var(--shadow-md);
}

.send-info h3 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: var(--text-primary);
}

.send-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.send-btn {
    background: var(--pilay-primary);
    color: white;
    padding: 0.6rem 1.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(0, 75, 238, 0.25);
    white-space: nowrap;
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--pilay-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 75, 238, 0.35);
}

.send-btn:disabled {
    background: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-btn.secondary {
    background: var(--bg-main);
    color: var(--pilay-primary);
    border: 1.5px solid var(--pilay-primary);
    box-shadow: none;
}

.send-btn.secondary:hover:not(:disabled) {
    background: var(--pilay-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 75, 238, 0.25);
}

.send-btn.secondary:disabled {
    background: var(--bg-main);
    color: var(--text-muted);
    border-color: var(--border-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.send-actions {
    display: flex;
    gap: 0.625rem;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .send-section {
        flex-direction: column;
        align-items: flex-start;
        padding: 1.125rem;
    }
    .send-actions { width: 100%; flex-direction: column; }
    .send-btn { width: 100%; justify-content: center; }
}
