/*
 * ui-components.css — Shared styles for UIModal, UIDropdown, UIToast, UIConfirmDialog.
 * These standardised components replace ad-hoc inline-styled modals, dropdowns, and toasts
 * across the application, providing a consistent look and feel.
 */

/* ========================================
   MODAL — Overlay + Panel
   ======================================== */

.ui-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 1rem;
}

.ui-modal-overlay.ui-visible {
    opacity: 1;
}

/* Panel */
.ui-modal {
    background: var(--sidebar-bg, #1e293b);
    border-radius: 12px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    width: 100%;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.2s ease;
    overflow: hidden;
}

.ui-modal-overlay.ui-visible .ui-modal {
    transform: scale(1) translateY(0);
}

/* Size variants */
.ui-modal--sm { max-width: 400px; }
.ui-modal--md { max-width: 500px; }
.ui-modal--lg { max-width: 600px; }
.ui-modal--xl { max-width: 960px; }
.ui-modal--full { max-width: 95vw; }

/* Header */
.ui-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ui-modal-title {
    margin: 0;
    color: var(--text-primary, #f8fafc);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
}

.ui-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.ui-modal-close:hover {
    color: var(--text-primary, #f8fafc);
    background: rgba(255, 255, 255, 0.08);
}

/* Body */
.ui-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    color: var(--text-primary, #f8fafc);
}

/* Footer */
.ui-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* Standard footer buttons */
.ui-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-main, 'Outfit', sans-serif);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.15s;
    border: 1px solid transparent;
    line-height: 1.4;
}

.ui-btn--ghost {
    background: transparent;
    border-color: var(--border-color, rgba(255, 255, 255, 0.1));
    color: var(--text-secondary, #94a3b8);
}

.ui-btn--ghost:hover {
    border-color: var(--text-secondary, #94a3b8);
    color: var(--text-primary, #f8fafc);
    background: rgba(255, 255, 255, 0.05);
}

.ui-btn--primary {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--accent-color, #38bdf8);
}

.ui-btn--primary:hover {
    background: rgba(56, 189, 248, 0.3);
    border-color: rgba(56, 189, 248, 0.6);
}

.ui-btn--danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.ui-btn--danger:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.6);
}


/* ========================================
   DROPDOWN — Positioned menu
   ======================================== */

.ui-dropdown {
    position: absolute;
    z-index: 2100;
    background: var(--sidebar-bg, #1e293b);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 180px;
    max-height: 320px;
    overflow-y: auto;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    padding: 0.35rem;
}

.ui-dropdown.ui-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Search input inside dropdown */
.ui-dropdown-search {
    display: block;
    width: calc(100% - 0.7rem);
    margin: 0.35rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 6px;
    background: var(--bg-color, #0f172a);
    color: var(--text-primary, #f8fafc);
    font-family: var(--font-main, 'Outfit', sans-serif);
    font-size: 0.9rem;
    outline: none;
}

.ui-dropdown-search:focus {
    border-color: var(--accent-color, #38bdf8);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.ui-dropdown-search::placeholder {
    color: var(--text-secondary, #94a3b8);
}

/* Items */
.ui-dropdown-item {
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    color: var(--text-primary, #f8fafc);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.ui-dropdown-item:hover,
.ui-dropdown-item.ui-active {
    background: rgba(56, 189, 248, 0.15);
}

.ui-dropdown-item--selected {
    color: var(--accent-color, #38bdf8);
    font-weight: 600;
}

.ui-dropdown-item-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    margin-top: 0.1rem;
}

.ui-dropdown-empty {
    padding: 0.75rem;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.85rem;
    text-align: center;
}

/* Divider between groups */
.ui-dropdown-divider {
    height: 1px;
    background: var(--border-color, rgba(255, 255, 255, 0.1));
    margin: 0.35rem 0;
}


/* ========================================
   TOAST — Corner notifications
   ======================================== */

.ui-toast-container {
    position: fixed;
    z-index: 3000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 400px;
    width: calc(100% - 2rem);
}

/* Position variants */
.ui-toast-container--bottom-right {
    bottom: 24px;
    right: 24px;
}

.ui-toast-container--bottom-left {
    bottom: 24px;
    left: 24px;
}

.ui-toast-container--top-right {
    top: 24px;
    right: 24px;
    flex-direction: column;
}

.ui-toast-container--top-left {
    top: 24px;
    left: 24px;
    flex-direction: column;
}

.ui-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: var(--font-main, 'Outfit', sans-serif);
    font-size: 0.95rem;
    color: var(--text-primary, #f8fafc);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transform: translateX(30px);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    cursor: pointer;
}

.ui-toast.ui-visible {
    transform: translateX(0);
    opacity: 1;
}

.ui-toast.ui-hiding {
    transform: translateX(30px);
    opacity: 0;
}

/* Toast type variants */
.ui-toast--success {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
}

.ui-toast--success .ui-toast-icon {
    color: #22c55e;
}

.ui-toast--error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
}

.ui-toast--error .ui-toast-icon {
    color: #ef4444;
}

.ui-toast--warning {
    background: rgba(251, 191, 36, 0.15);
    border-color: rgba(251, 191, 36, 0.3);
}

.ui-toast--warning .ui-toast-icon {
    color: #f59e0b;
}

.ui-toast--info {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.3);
}

.ui-toast--info .ui-toast-icon {
    color: #38bdf8;
}

.ui-toast-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
    line-height: 1;
}

.ui-toast-message {
    flex: 1;
    line-height: 1.4;
}


/* ========================================
   CONFIRM DIALOG — Async confirm replacement
   ======================================== */

.ui-confirm-body {
    text-align: center;
    padding: 0.5rem 0;
}

.ui-confirm-message {
    color: var(--text-secondary, #94a3b8);
    font-size: 1rem;
    line-height: 1.5;
    margin-top: 0.5rem;
}

.ui-confirm-footer {
    justify-content: center;
}


/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 600px) {
    .ui-modal {
        max-height: 90vh;
    }

    .ui-modal--sm,
    .ui-modal--md,
    .ui-modal--lg {
        max-width: 100%;
    }

    .ui-modal-header {
        padding: 1rem;
    }

    .ui-modal-body {
        padding: 1rem;
    }

    .ui-modal-footer {
        padding: 0.75rem 1rem;
    }

    .ui-toast-container {
        left: 1rem !important;
        right: 1rem !important;
        max-width: none;
        width: auto;
    }

    .ui-toast {
        transform: translateY(20px);
    }

    .ui-toast.ui-visible {
        transform: translateY(0);
    }

    .ui-toast.ui-hiding {
        transform: translateY(20px);
    }
}
