/* ═══════════════════════════════════════════════════════════
   NP2 Shared UI Components — Styles
   Toast, Modal, DataTable, FormBuilder
   ═══════════════════════════════════════════════════════════ */

/* ─── Toast ─────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 420px;
}

.toast-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-item.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-item.toast-exit {
    opacity: 0;
    transform: translateX(100%);
}

.toast-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.toast-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.toast-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.toast-icon { flex-shrink: 0; display: flex; }
.toast-message { flex: 1; }
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    color: inherit;
    padding: 0 2px;
}
.toast-close:hover { opacity: 1; }


/* ─── Modal ─────────────────────────────────────────────── */

.np2-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.np2-modal-overlay.np2-modal-visible {
    opacity: 1;
    visibility: visible;
}

.np2-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    min-width: 380px;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(-10px);
    transition: transform 0.2s ease;
}

.np2-modal.np2-modal-enter {
    transform: scale(1) translateY(0);
}

.np2-modal.np2-modal-exit {
    transform: scale(0.95) translateY(-10px);
}

.np2-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.np2-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.np2-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #6b7280;
    padding: 4px;
    border-radius: 4px;
}
.np2-modal-close:hover { background: #f3f4f6; }

.np2-modal-body {
    padding: 16px 24px;
    overflow-y: auto;
    flex: 1;
}

.np2-modal-message {
    margin: 0;
    font-size: 14px;
    color: #4b5563;
    line-height: 1.6;
}

.np2-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px 20px;
}

.btn-danger {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
}
.btn-danger:hover {
    background: #b91c1c !important;
}


/* ─── DataTable ─────────────────────────────────────────── */

.dt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.dt-search {
    flex: 1;
    max-width: 320px;
}

.dt-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s;
}
.dt-search-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dt-info {
    font-size: 12px;
    color: #6b7280;
}

.dt-table-wrap {
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.dt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dt-table thead {
    background: #f9fafb;
}

.dt-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    user-select: none;
    white-space: nowrap;
}

.dt-sortable { cursor: pointer; }
.dt-sortable:hover { color: #2563eb; }
.dt-sort-asc::after { content: ' ↑'; color: #2563eb; }
.dt-sort-desc::after { content: ' ↓'; color: #2563eb; }

.dt-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
}

.dt-table tbody tr:hover {
    background: #f9fafb;
}

.dt-clickable {
    cursor: pointer;
}

.dt-empty {
    text-align: center;
    color: #9ca3af;
    padding: 32px 14px !important;
    font-style: italic;
}

.dt-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 12px;
    padding: 8px 0;
}

.dt-page-btn {
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s;
}
.dt-page-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
}
.dt-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.dt-page-info {
    font-size: 12px;
    color: #6b7280;
}


/* ─── FormBuilder ───────────────────────────────────────── */

.fb-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 16px 0;
    color: #991b1b;
    font-size: 13px;
}

.fb-error div {
    padding: 2px 0;
}

.fb-field-error {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15) !important;
}

/* Form components (used by both FormBuilder and hand-coded forms) */

.form-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    margin-top: 16px;
}

.form-section {
    padding: 16px 0;
    border-bottom: 1px solid #f3f4f6;
}
.form-section:last-of-type { border-bottom: none; }

.form-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 16px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group-toggle {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-hint {
    font-size: 11px;
    color: #9ca3af;
}

.form-row-inline {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 20px;
    margin-top: 8px;
    border-top: 1px solid #f3f4f6;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.btn-back:hover { background: #f3f4f6; color: #374151; }

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}