.dwr-wrap { font-family: sans-serif; position: relative; }
.dwr-wrap[data-layout="page"]   { max-width: 680px; }
.dwr-wrap[data-layout="header"] { width: 100%; }

.dwr-wrap .dwr-input {
    width: 100%; padding: 10px 14px; font-size: 15px;
    border: 1px solid #d1d5db; border-radius: 8px; outline: none; box-sizing: border-box;
}
.dwr-wrap .dwr-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }

.dwr-wrap .dwr-results { display: flex; flex-direction: column; gap: 10px; }
.dwr-wrap[data-layout="page"]   .dwr-results { margin-top: 12px; }
.dwr-wrap[data-layout="header"] .dwr-results {
    position: static; max-height: none; overflow-y: visible;
    padding: 0; background: transparent; border: none; border-radius: 0; box-shadow: none;
}

.dwr-wrap .dwr-doc {
    padding: 14px 16px; border: 1px solid #e5e7eb; border-radius: 10px;
    background: #fff; transition: box-shadow .15s;
}
.dwr-wrap .dwr-doc:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }

.dwr-wrap .dwr-doc-type { font-size: 11px; font-weight: 600; text-transform: uppercase; color: #6366f1; margin-bottom: 4px; }
.dwr-wrap .dwr-doc h3   { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.dwr-wrap .dwr-doc p    { margin: 0 0 8px; font-size: 13px; color: #6b7280; line-height: 1.5; }
.dwr-wrap .dwr-doc a    { font-size: 13px; color: #6366f1; text-decoration: none; font-weight: 500; }
.dwr-wrap .dwr-doc a:hover { text-decoration: underline; }

.dwr-wrap .dwr-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.dwr-wrap .dwr-tag   { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #fef3c7; color: #92400e; font-weight: 500; }
.dwr-wrap .dwr-cat   { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #dbeafe; color: #1e40af; font-weight: 500; }

.dwr-wrap .dwr-msg { font-size: 14px; color: #9ca3af; padding: 8px 0; }

/* ── Header layout: trigger button ─────────────────────────────── */
.dwr-wrap[data-layout="header"] .dwr-search-trigger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0;
    background: transparent; border: 1px solid #d1d5db; border-radius: 8px;
    cursor: pointer; color: #374151; transition: background .15s, border-color .15s;
}
.dwr-wrap[data-layout="header"] .dwr-search-trigger:hover {
    background: #f3f4f6; border-color: #9ca3af;
}

/* ── Modal overlay ──────────────────────────────────────────────── */
.dwr-search-modal {
    position: fixed; inset: 0; z-index: 99999;
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 80px;
}
.dwr-search-modal[hidden] { display: none; }

/* ── Backdrop ───────────────────────────────────────────────────── */
.dwr-modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 0;
}

/* ── Dialog box ─────────────────────────────────────────────────── */
.dwr-search-dialog {
    position: relative; z-index: 1;
    width: 100%; max-width: 680px; max-height: calc(100vh - 120px); overflow-y: auto;
    background: #fff; border-radius: 12px; padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25); box-sizing: border-box;
}

/* ── Close button ───────────────────────────────────────────────── */
.dwr-modal-close {
    position: absolute; top: 14px; right: 16px;
    width: 28px; height: 28px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; line-height: 1;
    background: transparent; border: none; border-radius: 6px;
    cursor: pointer; color: #6b7280;
}
.dwr-modal-close:hover { background: #f3f4f6; color: #111827; }

/* ── Body scroll lock ───────────────────────────────────────────── */
body.dwr-modal-open { overflow: hidden; }

/* ── Advanced search accordion ─────────────────────────────────── */
.dwr-advanced-search {
    margin-top: 12px; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden;
}
.dwr-advanced-toggle {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 14px; font-size: 13px; font-weight: 500; color: #374151;
    cursor: pointer; list-style: none; user-select: none;
}
.dwr-advanced-toggle::-webkit-details-marker { display: none; }
.dwr-advanced-toggle:hover { background: #f9fafb; }
.dwr-advanced-search[open] .dwr-chevron { transform: rotate(180deg); }
.dwr-chevron { margin-left: auto; transition: transform .2s; flex-shrink: 0; }

.dwr-advanced-fields {
    padding: 14px; display: flex; flex-direction: column; gap: 10px;
    border-top: 1px solid #e5e7eb;
}

/* ── Filter field groups ────────────────────────────────────────── */
.dwr-field-group  { display: flex; flex-direction: column; gap: 4px; }
.dwr-field-row    { display: flex; gap: 12px; }
.dwr-field-group--half { flex: 1; }
.dwr-field-label  { font-size: 12px; font-weight: 500; color: #6b7280; }
.dwr-field-input  {
    width: 100%; padding: 8px 12px; font-size: 14px;
    border: 1px solid #d1d5db; border-radius: 6px; outline: none;
    box-sizing: border-box; color: #111827;
}
.dwr-field-input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
select.dwr-field-input {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
    padding-right: 32px; cursor: pointer;
}

/* ── Field color indicators (matches result chip colors) ────────── */
.dwr-field-label--tag::after,
.dwr-field-label--category::after {
    content: ''; display: inline-block;
    width: 10px; height: 10px; border-radius: 3px;
    margin-left: 5px; vertical-align: middle;
}
.dwr-field-label--tag::after      { background: #fef3c7; border: 1.5px solid #92400e; }
.dwr-field-label--category::after { background: #dbeafe; border: 1.5px solid #1e40af; }
.dwr-field--tag:focus      { border-color: #92400e; box-shadow: 0 0 0 3px rgba(146,64,14,.12); }
.dwr-field--category:focus { border-color: #1e40af; box-shadow: 0 0 0 3px rgba(30,64,175,.12); }

/* ── Results inside modal ───────────────────────────────────────── */
.dwr-search-dialog .dwr-results { margin-top: 14px; }

/* ── Mobile: bottom-sheet ───────────────────────────────────────── */
@media (max-width: 720px) {
    .dwr-search-modal { padding-top: 0; align-items: flex-end; }
    .dwr-search-dialog { max-width: 100%; max-height: 90vh; border-radius: 16px 16px 0 0; }
    .dwr-field-row { flex-wrap: wrap; }
    .dwr-field-group--half { min-width: calc(50% - 6px); }
}
