/* ═══════════════════════════════════════════════════════════
   Canifa AI Platform — Shared UI Components
   Inspired by Memos SettingRow, SettingSection, SearchBar
   ═══════════════════════════════════════════════════════════ */

/* ── Setting Section ─────────────────────────────────── */
.setting-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 0 16px;
}
.setting-section-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.setting-section-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--foreground);
    margin: 0;
}
.setting-section-header .desc {
    font-size: 13px;
    color: var(--muted-fg);
    margin: 0;
}
.setting-section-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Setting Group ───────────────────────────────────── */
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.setting-group-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted-fg);
    margin: 0;
}
.setting-separator {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

/* ── Setting Row (label ←→ control) ──────────────────── */
.setting-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.setting-row.vertical {
    flex-direction: column;
    align-items: stretch;
}
.setting-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.setting-label-text {
    font-size: 13px;
    color: var(--foreground);
}
.setting-row.vertical .setting-label-text {
    font-weight: 500;
}
.setting-label-desc {
    font-size: 11px;
    color: var(--muted-fg);
    margin: 0;
}
.setting-control {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* ── Section Menu Item (sidebar nav) ─────────────────── */
.section-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--muted-fg);
    transition: all 0.15s;
    user-select: none;
    width: 100%;
}
.section-menu-item:hover {
    background: var(--muted);
    color: var(--foreground);
}
.section-menu-item.active {
    background: var(--accent);
    color: var(--foreground);
    box-shadow: var(--shadow-xs);
}
.section-menu-item i,
.section-menu-item .icon {
    font-size: 14px;
    width: 16px;
    text-align: center;
    opacity: 0.8;
    flex-shrink: 0;
}

/* ── Search Bar (icon-prefix input) ──────────────────── */
.search-bar {
    position: relative;
    width: 100%;
}
.search-bar .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--muted-fg);
    opacity: 0.5;
    pointer-events: none;
}
.search-bar input {
    width: 100%;
    padding: 7px 12px 7px 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--foreground);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 89, 152, 0.1);
}
.search-bar input::placeholder {
    color: var(--muted-fg);
    opacity: 0.6;
}

/* ── Card (base Memos-style card) ────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground);
    margin: 0;
}
.card-desc {
    font-size: 12px;
    color: var(--muted-fg);
    margin: 2px 0 0;
}
.card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Badge / Pill ────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-error   { background: var(--error-light); color: var(--error); }
.badge-warn    { background: var(--warn-light); color: var(--warn); }
.badge-info    { background: var(--info-light); color: var(--info); }
.badge-muted   { background: var(--muted); color: var(--muted-fg); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    user-select: none;
}
.btn-primary {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline {
    background: var(--card);
    color: var(--foreground);
    border-color: var(--border);
}
.btn-outline:hover { background: var(--muted); }
.btn-ghost {
    background: transparent;
    color: var(--muted-fg);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--muted); color: var(--foreground); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon-only {
    width: 32px; height: 32px;
    padding: 0;
    border-radius: var(--radius);
}

/* ── Select / Dropdown ───────────────────────────────── */
.select {
    padding: 6px 28px 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    appearance: none;
    cursor: pointer;
    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='%2378716c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.15s;
}
.select:focus { border-color: var(--primary); }
.select:hover { border-color: var(--input); }

/* ── Input Text ──────────────────────────────────────── */
.input {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    width: 100%;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 89, 152, 0.1);
}

/* ── Switch Toggle ───────────────────────────────────── */
.switch {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: var(--input);
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    padding: 0;
}
.switch::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: white;
    box-shadow: var(--shadow-xs);
    transition: transform 0.2s;
}
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(16px); }

/* ── Table (clean minimal) ───────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.table th,
.table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.table th {
    background: var(--muted);
    color: var(--muted-fg);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.table tbody tr:hover { background: var(--primary-light); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--muted-fg);
}
.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.25;
}
.empty-state h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--foreground);
    margin: 0 0 4px;
}
.empty-state p {
    font-size: 13px;
    margin: 0;
}

/* ── Tooltip ─────────────────────────────────────────── */
.tooltip-trigger { cursor: help; }

/* ── Separator ───────────────────────────────────────── */
.separator {
    border: none;
    border-top: 1px solid var(--border);
    margin: 12px 0;
}

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}
.animate-fade { animation: fadeIn 0.25s ease; }
.animate-slide { animation: slideIn 0.25s ease; }
