/* components.css — buttons, forms, cards, alerts, panels, modals, lists, tables, toast */

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 14px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    text-decoration: none; line-height: 1.2;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover { background: var(--color-surface-2); }
.btn-ghost.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-block { width: 100%; }
.icon-btn-lg { width: 40px; height: 40px; padding: 0; }
.btn-text {
    background: transparent; border: 0;
    color: var(--color-primary); cursor: pointer;
    font-size: 12.5px; font-weight: 600; padding: 4px 6px;
    border-radius: 4px;
}
.btn-text:hover { background: var(--color-surface-2); }

/* ============ FORMS ============ */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span { font-weight: 500; color: var(--color-text); }
.field input, .field textarea, .field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.field-error { color: var(--color-danger); font-size: 12.5px; }
.form-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.form-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    padding: 10px 12px;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
}
.form-meta > div { display: flex; flex-direction: column; gap: 2px; }
.checkbox-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    background: var(--color-surface-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.checkbox-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    font-size: 13.5px;
    padding: 8px 6px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background .1s ease;
    width: 100%;
    text-align: left;
}
.checkbox-row:hover {
    background: var(--color-surface);
}
.checkbox-row input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--color-primary);
}
.checkbox-row > span {
    flex: 1;
    min-width: 0;
    text-align: left;
}

/* ============ ALERTS ============ */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; }
.alert-error { background: rgba(220, 38, 38, .1); color: var(--color-danger); border: 1px solid rgba(220, 38, 38, .25); }
.alert-success { background: rgba(22, 163, 74, .1); color: var(--color-success); border: 1px solid rgba(22, 163, 74, .25); }
.alert-warning { background: rgba(217, 119, 6, .1); color: var(--color-warning); border: 1px solid rgba(217, 119, 6, .25); }

/* ============ PANELS ============ */
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 18px;
}
.panel:last-child { margin-bottom: 0; }
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    margin-bottom: 14px;
}
.panel-header h2 { font-size: 15px; margin: 0; font-weight: 600; }

/* ============ PAGE HEADER (konsisten app & admin) ============ */
.page-header { margin-bottom: 18px; }
.page-header h1 { font-size: 22px; margin-bottom: 4px; }
.page-header p { color: var(--color-muted); font-size: 13.5px; margin: 0; }
.page-header-actions {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 12px; flex-wrap: wrap;
}

/* ============ CARD GRID ============ */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 18px;
    color: inherit;
    text-decoration: none;
    display: flex; flex-direction: column; gap: 6px;
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.card-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--color-surface-2);
    color: var(--color-primary);
    margin-bottom: 4px;
}
.card h3 { font-size: 15px; margin: 0; }
.card p { font-size: 13.5px; color: var(--color-muted); margin: 0; }

/* ============ STAT GRID (dipakai admin & app) ============ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-muted); }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-sub { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.stat-sub a { font-size: 12.5px; }

/* ============ TABLES (unified) ============ */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    -webkit-overflow-scrolling: touch;
}
.admin-table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}
.admin-table th, .admin-table td,
.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
.admin-table th, .data-table th {
    background: var(--color-surface-2);
    font-weight: 600; font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--color-muted);
}
.admin-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td, .data-table tbody tr:hover td { background: var(--color-surface-2); }

/* ============ LISTS ============ */
.list-clean { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item {
    padding: 12px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: flex; justify-content: space-between; gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.list-item-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.list-item-title { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list-item-sub { font-size: 12.5px; color: var(--color-muted); }
.list-item-body { font-size: 13.5px; margin-top: 2px; }
.list-item-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ============ FILTER ============ */
/*.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }*/
.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding: 2px 0;
}
.filter-bar .filter-chip { flex-shrink: 0; }
.filter-chip {
    padding: 5px 12px; border-radius: 999px;
    font-size: 13px; color: var(--color-muted);
    text-decoration: none;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: all .12s ease;
}
.filter-chip:hover { text-decoration: none; color: var(--color-text); }
.filter-chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* Admin filter form (samakan style dengan form biasa) */
.admin-filters {
    display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
    align-items: center;
}
.admin-filters input, .admin-filters select {
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 14px;
    min-width: 0;
}
.admin-filters input:focus, .admin-filters select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.admin-filters .btn { flex-shrink: 0; }

/* ============ BADGES ============ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--color-surface-2);
    color: var(--color-muted);
    text-transform: lowercase;
}
.badge-active { background: rgba(22,163,74,.15); color: var(--color-success); }
.badge-banned { background: rgba(220,38,38,.15); color: var(--color-danger); }
.badge-admin  { background: rgba(37,99,235,.15); color: var(--color-primary); }
.badge-mod    { background: rgba(217,119,6,.15); color: var(--color-warning); }

/* ============ REPORT / LOG LISTS (admin) ============ */
.report-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.report-item {
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.report-item:hover { border-color: var(--color-primary); }
.report-item-main { min-width: 0; flex: 1; }
.report-item-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.report-item-meta { font-size: 12.5px; color: var(--color-muted); }
.report-item-body { margin-top: 8px; white-space: pre-wrap; }
.report-item-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: flex-start; }

.log-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 6px;
    max-height: 420px; overflow-y: auto;
}
.log-list li {
    padding: 8px 10px;
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; gap: 8px;
    font-size: 13px;
}
.log-list li:last-child { border-bottom: none; }

/* ============ EMPTY STATE ============ */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--color-muted);
    font-size: 13.5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.empty-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
    background: var(--color-surface-2);
    border-radius: 50%;
    color: var(--color-muted);
    opacity: .8;
}
.empty-state h3 { color: var(--color-text); margin: 0; font-size: 15px; }
.empty-state p { margin: 0; }

/* ============ PROGRESS ============ */
.progress-bar {
    width: 100%; height: 5px;
    background: var(--color-surface-2);
    border-radius: 4px; overflow: hidden;
    margin-top: 6px;
}
.progress-fill {
    height: 100%; background: var(--color-primary);
    transition: width .2s ease;
}

/* ============ PAGINATION ============ */
.pagination { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pagination .btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ============ MODAL ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-card {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}
.modal-card.modal-md { max-width: 480px; }
.modal-card.modal-lg { max-width: 600px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 16px;
}

/* ============ SEARCH RESULTS ============ */
.search-results {
    list-style: none; margin: 6px 0 0; padding: 0;
    max-height: 220px; overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}
.search-results:empty { display: none; }
.search-results li {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover { background: var(--color-surface-2); }

/* ============ TOAST ============ */
.toast-container {
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottom-nav-h) + 16px);
    display: flex; flex-direction: column; gap: 8px;
    z-index: 200;
    max-width: 340px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    display: flex; align-items: flex-start; gap: 8px;
    animation: toastIn .2s ease-out;
    cursor: pointer;
}
.toast .toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast.success { border-color: var(--color-success); }
.toast.success .toast-icon { color: var(--color-success); }
.toast.error   { border-color: var(--color-danger);  }
.toast.error   .toast-icon { color: var(--color-danger); }
.toast.warn    { border-color: var(--color-warning); }
.toast.warn    .toast-icon { color: var(--color-warning); }
.toast.info    { border-color: var(--color-primary); }
.toast.info    .toast-icon { color: var(--color-primary); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ SKELETON ============ */
.skeleton {
    background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border) 50%, var(--color-surface-2) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.4s ease-in-out infinite;
    border-radius: 6px;
    height: 14px;
}
.skeleton.w40 { width: 40%; }
.skeleton.w60 { width: 60%; }
.skeleton.w80 { width: 80%; }
.skeleton-block { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============ LOADING / CONFIRM ============ */
.loading-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,.35);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.loading-overlay[hidden] { display: none; }
.loading-spinner {
    width: 34px; height: 34px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.confirm-overlay {
    position: fixed; inset: 0; z-index: 320;
    background: rgba(0,0,0,.45);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.confirm-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    width: 100%; max-width: 380px;
    box-shadow: var(--shadow-lg);
}
.confirm-card p { margin-bottom: 14px; font-size: 14.5px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============ AVATAR ============ */
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--color-primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.avatar-sm { width: 30px; height: 30px; font-size: 12px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
    .admin-filters { flex-direction: column; align-items: stretch; }
    .admin-filters input, .admin-filters select, .admin-filters .btn { width: 100%; }
    .admin-filters .btn-text { width: auto; }

    .admin-two-col { grid-template-columns: 1fr; }
    .admin-two-col-2-1 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .stat-value { font-size: 20px; }
}

@media (max-width: 430px) {
    .toast-container {
        left: 12px; right: 12px;
        bottom: calc(var(--bottom-nav-h) + 8px);
        max-width: none;
    }
    .page-header h1 { font-size: 20px; }
    .panel { padding: 14px; }
    .modal-card { padding: 16px; }
}

/* ============ Notification empty state (khusus dashboard) ============ */
.notif-empty-state {
    display: none; /* default: hidden — JS yang toggle pakai .show */
}
.notif-empty-state.show {
    display: flex;
}

/* Empty state dalam dropdown bell — pakai hidden attribute seperti biasa,
   karena .notif-empty tidak punya display flex dari CSS */
.notif-empty {
    display: none;
}
.notif-empty:not([hidden]) {
    display: block;
}

/* ============================================================
   Modal: search input & results (New conversation, Invite user)
   ============================================================ */

/* Input search di dalam modal */
.modal-card input[type="text"],
.modal-card input[type="search"],
.modal-card input[type="email"],
.modal-card input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-2);
    color: var(--color-text);
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-family: inherit;
    transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.modal-card input[type="text"]:focus,
.modal-card input[type="search"]:focus,
.modal-card input[type="email"]:focus,
.modal-card input[type="number"]:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.modal-card input::placeholder {
    color: var(--color-muted);
    opacity: .85;
}

/* Search results list */
.search-results {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    -webkit-overflow-scrolling: touch;
}
.search-results:empty { display: none; }
.search-results li {
    padding: 11px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: background .1s ease;
}
.search-results li:last-child { border-bottom: none; }
.search-results li:hover,
.search-results li:focus {
    background: var(--color-surface-2);
}
.search-results li .text-muted {
    color: var(--color-muted);
    font-size: 12.5px;
    flex-shrink: 0;
}
.search-results li.text-muted {
    cursor: default;
    justify-content: center;
    font-size: 13px;
    padding: 16px;
}
.search-results li.text-muted:hover {
    background: transparent;
}