/* ==============================================
   CleanTable — Frontend Styles
   Inherits font from the active theme.
   ============================================== */

.cleantable-container {
    --ct-header-bg: #1e293b;
    --ct-header-text: #ffffff;
    --ct-accent: #2563eb;
    --ct-hover: #f1f5f9;
    --ct-radius: 6px;
    --ct-padding: 12px 16px;
    --ct-align: left;
    margin: 1.5em 0;
    font-family: inherit;
}

/* Search */
.ct-search-wrap {
    margin-bottom: 12px;
}
.ct-search-input {
    width: 100%;
    max-width: 320px;
    padding: 9px 14px;
    border: 1px solid #e2e8f0;
    border-radius: var(--ct-radius);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.ct-search-input:focus {
    border-color: var(--ct-accent);
}

/* Responsive wrapper */
.ct-table-responsive {
    overflow: visible;
}
.ct-scroll .ct-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---------- BASE TABLE ---------- */
.cleantable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: inherit;
    line-height: 1.5;
    border-radius: var(--ct-radius);
    overflow: hidden;
}
.cleantable th,
.cleantable td {
    padding: var(--ct-padding);
    text-align: var(--ct-align);
    vertical-align: middle;
}

/* Header */
.cleantable thead th {
    background: var(--ct-header-bg);
    color: var(--ct-header-text);
    font-weight: 600;
    font-size: 0.9em;
    text-transform: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
    position: relative;
    border: none;
}
.cleantable thead th:first-child {
    border-top-left-radius: var(--ct-radius);
}
.cleantable thead th:last-child {
    border-top-right-radius: var(--ct-radius);
}

/* Sortable */
.ct-sortable {
    cursor: pointer;
    user-select: none;
}
.ct-sortable:hover {
    opacity: 0.85;
}
.ct-sort-icon {
    display: inline-block;
    margin-left: 6px;
    font-size: 10px;
    opacity: 0.5;
}
.ct-sort-icon::after { content: "▲▼"; }
.ct-sort-asc .ct-sort-icon::after { content: "▲"; opacity: 1; }
.ct-sort-desc .ct-sort-icon::after { content: "▼"; opacity: 1; }

/* Body */
.cleantable tbody td {
    border-bottom: 1px solid #e9ecef;
}
.cleantable tbody tr:last-child td {
    border-bottom: none;
}
.cleantable tbody tr:last-child td:first-child {
    border-bottom-left-radius: var(--ct-radius);
}
.cleantable tbody tr:last-child td:last-child {
    border-bottom-right-radius: var(--ct-radius);
}
.cleantable tbody tr:hover td {
    background: var(--ct-hover);
}

/* Links */
.cleantable a {
    color: var(--ct-accent);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.15s;
}
.cleantable a:hover {
    opacity: 0.75;
    text-decoration: underline;
}

/* ===================== STYLE: minimal ===================== */
.ct-style-minimal .cleantable {
    border: none;
}
.ct-style-minimal .cleantable tbody td {
    border-bottom: 1px solid #f1f5f9;
}

/* ===================== STYLE: bordered ===================== */
.ct-style-bordered .cleantable {
    border: 1px solid #e2e8f0;
}
.ct-style-bordered .cleantable th,
.ct-style-bordered .cleantable td {
    border: 1px solid #e2e8f0;
}

/* ===================== STYLE: striped ===================== */
.ct-style-striped .cleantable tbody tr:nth-child(even) td {
    background: #f8fafc;
}

/* ===================== STYLE: card ===================== */
.ct-style-card .cleantable {
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
}

/* ===================== RESPONSIVE: STACK ===================== */
@media (max-width: 768px) {
    .ct-stack .ct-table-responsive {
        overflow: visible;
    }
    .ct-stack .cleantable,
    .ct-stack .cleantable thead,
    .ct-stack .cleantable tbody,
    .ct-stack .cleantable th,
    .ct-stack .cleantable td,
    .ct-stack .cleantable tr {
        display: block;
    }
    .ct-stack .cleantable thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0,0,0,0);
    }
    .ct-stack .cleantable tbody tr {
        border: 1px solid #e2e8f0;
        border-radius: var(--ct-radius);
        margin-bottom: 12px;
        padding: 4px 0;
        background: #fff;
    }
    .ct-stack .cleantable tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 16px;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
    }
    .ct-stack .cleantable tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        flex-shrink: 0;
        margin-right: 12px;
        color: var(--ct-header-bg);
        font-size: 0.9em;
    }
    .ct-stack .cleantable tbody td:last-child {
        border-bottom: none;
    }
    .ct-stack .cleantable tbody tr:last-child td:first-child,
    .ct-stack .cleantable tbody tr:last-child td:last-child {
        border-radius: 0;
    }
}
