/* ==========================================================================
   Speedy Admin — Components (cards, KPI tiles, badges, tabs, charts, misc)
   ========================================================================== */

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; font-weight: 700; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) { .grid-4 { grid-template-columns: 1fr; } }

/* ---------- KPI tiles ---------- */
.kpi {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
}
.kpi.kpi-success::before { background: var(--success); }
.kpi.kpi-warning::before { background: var(--warning); }
.kpi.kpi-danger::before { background: var(--danger); }

.kpi-label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
}
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.kpi-sub { font-size: 12.5px; color: var(--text-2); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.7;
    white-space: nowrap;
    text-transform: capitalize;
}
.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-info    { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: var(--neutral-soft); color: var(--text-2); }
.badge.no-dot::before { display: none; }

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
    overflow-x: auto;
}
.tab {
    padding: 9px 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-2);
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Simple bar chart (dashboard revenue trend) ---------- */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 160px;
    padding-top: 10px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; justify-content: flex-end; }
.bar {
    width: 100%;
    max-width: 42px;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    opacity: 0.9;
    transition: opacity var(--transition);
    position: relative;
}
.bar:hover { opacity: 1; }
.bar-label { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.bar[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 8px;
    background: var(--text);
    color: var(--surface);
    font-size: 11px;
    font-weight: 600;
    border-radius: 5px;
    white-space: nowrap;
    z-index: 5;
}

/* ---------- Lists (recent activity etc.) ---------- */
.list { list-style: none; }
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 12px; color: var(--text-3); }

/* ---------- Empty state ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 48px 20px;
    color: var(--text-3);
    text-align: center;
}
.empty-state .empty-icon { font-size: 30px; opacity: 0.6; }
.empty-state p { font-size: 13.5px; }

/* ---------- Key-value details ---------- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px 20px;
}
.detail-item .dt {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 2px;
}
.detail-item .dd { font-size: 13.5px; font-weight: 500; word-break: break-word; }

/* ---------- Toolbar (filters above tables) ---------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.toolbar .spacer { flex: 1; }
.toolbar .search-box { position: relative; }
.toolbar .search-box input { padding-left: 32px; min-width: 220px; }
.toolbar .search-box svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

/* ---------- Code / key display ---------- */
.key-reveal {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 13px;
    word-break: break-all;
}

/* ---------- Alert boxes ---------- */
.alert {
    display: flex;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid transparent;
}
.alert-info { background: var(--info-soft); color: var(--info); border-color: rgba(8, 145, 178, 0.25); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(217, 119, 6, 0.25); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(220, 38, 38, 0.25); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: rgba(22, 163, 74, 0.25); }

/* ---------- Dropdown action menu (table rows) ---------- */
.row-menu { position: relative; display: inline-block; }
.row-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 170px;
    padding: 5px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 20;
}
.row-menu-item {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}
.row-menu-item:hover { background: var(--surface-2); }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { background: var(--danger-soft); }

/* ---------- Permission matrix ---------- */
.perm-group { margin-bottom: 14px; }
.perm-group-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    margin-bottom: 6px;
}
.perm-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px; }
.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
}
.perm-item:hover { background: var(--surface-2); }
