/* Dialog Service — styles for app-wide confirm/alert dialogs and toasts.
   Used by js/dialog-service.js. Uses theme variables with fallbacks so it
   works in light and dark mode. */

.app-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    /* Keep the dialog (and its buttons) clear of the iPhone home indicator */
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    /* Above every modal layer — a confirm/alert can be raised from within one. */
    z-index: var(--z-app-modal-nested);
}

.app-dialog {
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1a1a1a);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    max-width: 420px;
    width: 100%;
    padding: 1.5rem;
    animation: app-dialog-in 0.15s ease-out;
}

@keyframes app-dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .app-dialog { animation: none; }
}

.app-dialog-title {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
    font-weight: 600;
}

.app-dialog-message {
    margin: 0 0 1.25rem;
    line-height: 1.5;
    color: var(--text-secondary, #444444);
    word-wrap: break-word;
}

.app-dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.app-dialog-btn {
    min-height: 44px;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
}

.app-dialog-btn-outline {
    background: transparent;
    color: var(--text-primary, #1a1a1a);
    border-color: var(--border-color, #cccccc);
}

.app-dialog-btn-outline:hover {
    background: var(--bg-secondary, #f2f2f2);
}

.app-dialog-btn-primary {
    background: var(--primary-color, #2d6a4f);
    color: #ffffff;
}

.app-dialog-btn-primary:hover {
    filter: brightness(1.1);
}

.app-dialog-btn-danger {
    background: #c0392b;
    color: #ffffff;
}

.app-dialog-btn-danger:hover {
    background: #a93226;
}

.app-dialog-btn:focus-visible {
    outline: 2px solid var(--primary-color, #2d6a4f);
    outline-offset: 2px;
}

/* Toasts */

.app-dialog-toasts {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: var(--z-app-toast);
    max-width: min(360px, calc(100vw - 2rem));
}

.app-dialog-toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1a1a1a);
    border-left: 4px solid var(--primary-color, #2d6a4f);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    padding: 0.75rem 1rem;
    line-height: 1.4;
}

.app-dialog-toast-success { border-left-color: #2d6a4f; }
.app-dialog-toast-error   { border-left-color: #c0392b; }
.app-dialog-toast-warning { border-left-color: #e67e22; }
.app-dialog-toast-info    { border-left-color: #2980b9; }

.app-dialog-toast-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    color: inherit;
    min-width: 44px;
    min-height: 44px;
    margin: -0.5rem -0.5rem -0.5rem auto;
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .app-dialog {
        padding: 1.25rem;
    }
    .app-dialog-footer .app-dialog-btn {
        flex: 1 1 auto;
    }
}
