/* ════════════════════════════════════════════════════════════════════════
   CleanLemon - Admin Panel Styles
   Brand: Verde #5BAD27, Amarillo #FAD71B, Dorado #F5C501, Verde claro #9BCD52
   ════════════════════════════════════════════════════════════════════════ */

:root {
    --cl-green: #5BAD27;
    --cl-green-dark: #4A8E20;
    --cl-green-light: #9BCD52;
    --cl-yellow: #FAD71B;
    --cl-gold: #F5C501;
    --cl-bg: #f8f9fa;
    --cl-sidebar-width: 260px;
    --cl-sidebar-collapsed: 60px;
}

html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 15px;
    }
}

body {
    background-color: var(--cl-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
}

/* ─── Navbar ─────────────────────────────────────────────────────────── */

.cl-navbar {
    background: linear-gradient(135deg, var(--cl-green) 0%, var(--cl-green-dark) 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 0 1rem;
    height: 56px;
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
}

.cl-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
}

.cl-navbar .navbar-brand img {
    height: 36px;
}

.cl-navbar .navbar-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.875rem;
}

.cl-navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cl-navbar-right a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.875rem;
}

.cl-navbar-right a:hover {
    color: white;
}

.cl-sidebar-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
}

/* ─── Sidebar ────────────────────────────────────────────────────────── */

.cl-sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: var(--cl-sidebar-width);
    background: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.2s ease;
    z-index: 1020;
    padding-top: 0.5rem;
}

.cl-sidebar-section {
    padding: 0.25rem 0;
}

.cl-sidebar-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
    padding: 0.75rem 1.25rem 0.25rem;
    font-weight: 600;
}

.cl-sidebar a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    color: #555;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.cl-sidebar a:hover {
    background: #f0f7e8;
    color: var(--cl-green);
}

.cl-sidebar a.active {
    background: #eef6e4;
    color: var(--cl-green);
    border-left-color: var(--cl-green);
    font-weight: 600;
}

.cl-sidebar a i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

/* ─── Main Content ───────────────────────────────────────────────────── */

.cl-main {
    margin-left: var(--cl-sidebar-width);
    margin-top: 56px;
    padding: 1.5rem;
    min-height: calc(100vh - 56px);
    transition: margin-left 0.2s ease;
}

/* ─── Page Header ────────────────────────────────────────────────────── */

.cl-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--cl-green-light);
}

.cl-page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin: 0;
}

/* ─── Cards ──────────────────────────────────────────────────────────── */

.cl-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #eee;
    margin-bottom: 1.5rem;
}

.cl-card-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    color: #444;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cl-card-body {
    padding: 1.25rem;
}

/* ─── KPI Cards ──────────────────────────────────────────────────────── */

.cl-kpi-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #eee;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cl-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cl-kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    flex-shrink: 0;
}

.cl-kpi-icon.green { background: linear-gradient(135deg, var(--cl-green), var(--cl-green-light)); }
.cl-kpi-icon.yellow { background: linear-gradient(135deg, var(--cl-gold), var(--cl-yellow)); }
.cl-kpi-icon.blue { background: linear-gradient(135deg, #4A90D9, #6BB3F0); }
.cl-kpi-icon.purple { background: linear-gradient(135deg, #7B5EA7, #A78BDB); }

.cl-kpi-content {
    flex: 1;
}

.cl-kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

.cl-kpi-label {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.25rem;
}

/* ─── Tables / Grid ──────────────────────────────────────────────────── */

.cl-grid {
    width: 100%;
    border-collapse: collapse;
}

.cl-grid thead th {
    background: #fafafa;
    border-bottom: 2px solid #e8e8e8;
    padding: 0.65rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #666;
    white-space: nowrap;
}

.cl-grid thead th a {
    color: #666;
    text-decoration: none;
}

.cl-grid thead th a:hover {
    color: var(--cl-green);
}

.cl-grid tbody td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.875rem;
    color: #444;
    vertical-align: middle;
}

.cl-grid tbody tr:hover {
    background: #fafff5;
}

.cl-grid tbody tr:last-child td {
    border-bottom: none;
}

.cl-grid a.cl-grid-link {
    color: var(--cl-green);
    font-weight: 600;
    text-decoration: none;
}

.cl-grid a.cl-grid-link:hover {
    color: var(--cl-green-dark);
    text-decoration: underline;
}

/* ─── Forms ──────────────────────────────────────────────────────────── */

.cl-fieldset {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid #eee;
    margin-bottom: 1.5rem;
    padding: 0;
    overflow: hidden;
}

.cl-fieldset-legend {
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    color: #444;
    font-size: 0.95rem;
    margin: 0;
}

.cl-fieldset-body {
    padding: 1.25rem;
}

.cl-form-group {
    margin-bottom: 1rem;
}

.cl-form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.cl-form-group .form-control,
.cl-form-group .form-select {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cl-form-group .form-control:focus,
.cl-form-group .form-select:focus {
    border-color: var(--cl-green);
    box-shadow: 0 0 0 0.2rem rgba(91, 173, 39, 0.15);
}

.cl-form-group .form-check-input:checked {
    background-color: var(--cl-green);
    border-color: var(--cl-green);
}

.cl-form-group textarea.form-control {
    min-height: 100px;
}

/* ─── Toolbar ────────────────────────────────────────────────────────── */

.cl-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.cl-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cl-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cl-total-label {
    font-size: 0.8rem;
    color: #888;
}

/* ─── Buttons ────────────────────────────────────────────────────────── */

.btn-cl-primary {
    background: linear-gradient(135deg, var(--cl-green), var(--cl-green-dark));
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    cursor: pointer;
}

.btn-cl-primary:hover {
    background: linear-gradient(135deg, var(--cl-green-dark), #3d7518);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(91, 173, 39, 0.3);
}

.btn-cl-secondary {
    background: white;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    cursor: pointer;
    text-decoration: none;
}

.btn-cl-secondary:hover {
    background: #f8f8f8;
    color: #333;
    border-color: #ccc;
    text-decoration: none;
}

.btn-cl-danger {
    background: white;
    color: #dc3545;
    border: 1px solid #dc3545;
    border-radius: 6px;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    cursor: pointer;
}

.btn-cl-danger:hover {
    background: #dc3545;
    color: white;
}

.btn-cl-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

.btn-cl-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.15s ease;
}

/* ─── Badges ─────────────────────────────────────────────────────────── */

.cl-badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
}

.cl-badge-success {
    background: #e8f5e0;
    color: var(--cl-green-dark);
}

.cl-badge-warning {
    background: #fff8e1;
    color: #b8860b;
}

.cl-badge-danger {
    background: #fde8e8;
    color: #c0392b;
}

.cl-badge-info {
    background: #e8f0fe;
    color: #2962ff;
}

/* ─── Pager ──────────────────────────────────────────────────────────── */

.cl-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem 0;
}

.cl-pager a,
.cl-pager span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.15s ease;
}

.cl-pager a {
    color: #555;
    border: 1px solid #ddd;
}

.cl-pager a:hover {
    background: var(--cl-green);
    color: white;
    border-color: var(--cl-green);
}

.cl-pager span.active {
    background: var(--cl-green);
    color: white;
    border: 1px solid var(--cl-green);
    font-weight: 700;
}

/* ─── Alerts ─────────────────────────────────────────────────────────── */

.cl-alert-success {
    background: #e8f5e0;
    border: 1px solid #c3e6a8;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    color: var(--cl-green-dark);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cl-alert-success i {
    font-size: 1.25rem;
}

/* ─── Validation ─────────────────────────────────────────────────────── */

.field-validation-error {
    color: #dc3545;
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: block;
}

.input-validation-error {
    border-color: #dc3545 !important;
}

.validation-summary-errors {
    background: #fde8e8;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    color: #721c24;
    font-size: 0.875rem;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* ─── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 991px) {
    .cl-sidebar {
        width: var(--cl-sidebar-collapsed);
    }

    .cl-sidebar .cl-sidebar-section-title,
    .cl-sidebar a span {
        display: none;
    }

    .cl-sidebar a {
        justify-content: center;
        padding: 0.65rem 0;
    }

    .cl-sidebar a i {
        margin: 0;
    }

    .cl-main {
        margin-left: var(--cl-sidebar-collapsed);
    }
}

@media (max-width: 767px) {
    .cl-sidebar {
        display: none;
    }

    .cl-main {
        margin-left: 0;
        padding: 1rem;
    }

    .cl-sidebar.show {
        display: block;
        width: var(--cl-sidebar-width);
    }
}

/* ─── Utilities ──────────────────────────────────────────────────────── */

.text-cl-green { color: var(--cl-green); }
.text-cl-gold { color: var(--cl-gold); }
.bg-cl-green { background-color: var(--cl-green); color: white; }
.bg-cl-gold { background-color: var(--cl-gold); color: #333; }

/* ─── Login ─────────────────────────────────────────────────────────── */

.login-standalone-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
    padding: 2rem;
}

.login-form-inner {
    max-width: 380px;
    margin: 0 auto;
    padding: 1.5rem 0.5rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 1rem;
}

.login-logo img {
    height: 72px;
}

.login-title {
    text-align: center;
    font-weight: 700;
    color: var(--cl-green-dark);
    margin-bottom: 1.5rem;
}

.login-btn {
    background-color: var(--cl-green);
    border-color: var(--cl-green);
    font-weight: 600;
    padding: 0.6rem;
    margin-top: 0.5rem;
}

.login-btn:hover {
    background-color: var(--cl-green-dark);
    border-color: var(--cl-green-dark);
}

/* ─── Navbar logout ─────────────────────────────────────────────────── */

.cl-navbar-logout {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.cl-navbar-logout:hover {
    color: white;
}

/* ═══════════════════════════════════════════════════════════════════════
   MKFactory Component Overrides
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── mk-editor / mk-viewer fieldsets ───────────────────────────────── */

fieldset {
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    padding: 0;
    overflow: hidden;
}

fieldset > legend {
    background: linear-gradient(135deg, #fafafa, #f4f4f4);
    border-bottom: 1px solid #e8e8e8;
    padding: 0.7rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #444;
    margin: 0;
    float: none;
    width: 100%;
}

fieldset > .fieldset-body,
fieldset > div:not(:first-child) {
    padding: 1rem 1.25rem;
}

/* ─── Form groups inside mk-editor ──────────────────────────────────── */

.form-group {
    margin-bottom: 0.85rem;
}

.form-group > label,
.control-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 0.3rem;
}

.form-control,
.form-select,
select.form-control {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.45rem 0.75rem;
    font-size: 0.9rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background-color: #fff;
}

.form-control:focus,
.form-select:focus,
select.form-control:focus {
    border-color: var(--cl-green);
    box-shadow: 0 0 0 0.2rem rgba(91, 173, 39, 0.15);
    outline: none;
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
    background-color: #f5f5f5;
    color: #777;
    border-color: #e8e8e8;
}

textarea.form-control {
    min-height: 80px;
}

.form-check-input:checked {
    background-color: var(--cl-green);
    border-color: var(--cl-green);
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(91, 173, 39, 0.2);
    border-color: var(--cl-green);
}

/* ─── mk-editor horizontal layout ──────────────────────────────────── */

.form-group .row {
    align-items: center;
}

.form-group .col-form-label,
.form-group .form-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: #555;
}

/* ─── Read-only viewer values ───────────────────────────────────────── */

.form-control-plaintext,
.form-control-static {
    font-size: 0.9rem;
    color: #333;
    padding: 0.45rem 0;
}

/* ─── Edit toolbar ──────────────────────────────────────────────────── */

.btn-toolbar.edit-toolbar {
    background: white;
    padding: 0.6rem 1rem;
    margin: -1.5rem -1.5rem 1.25rem -1.5rem;
    border-bottom: 1px solid #e8e8e8 !important;
    display: flex;
    align-items: center;
}

.btn-toolbar.edit-toolbar .justify-content-start {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

/* ─── mk-toolbar-link / mk-toolbar-button ───────────────────────────── */

.btn-mk-sm,
.btn-toolbar .btn-mk-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: white;
    color: #555;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
    line-height: 1.4;
}

.btn-mk-sm:hover,
.btn-toolbar .btn-mk-sm:hover {
    background: #f0f7e8;
    border-color: var(--cl-green);
    color: var(--cl-green);
    text-decoration: none;
}

.btn-mk-sm i {
    font-size: 0.85rem;
}

/* ─── Form submit area ──────────────────────────────────────────────── */

.form-submit {
    padding: 1rem 0 0.5rem;
    margin-top: 0.5rem;
}

.form-submit .btn-primary,
.form-submit input[type="submit"].btn-primary {
    background: linear-gradient(135deg, var(--cl-green), var(--cl-green-dark));
    border: none;
    border-radius: 6px;
    padding: 0.55rem 2rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    cursor: pointer;
    transition: all 0.15s ease;
}

.form-submit .btn-primary:hover,
.form-submit input[type="submit"].btn-primary:hover {
    background: linear-gradient(135deg, var(--cl-green-dark), #3d7518);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(91, 173, 39, 0.3);
}

/* ─── data-content wrapper ──────────────────────────────────────────── */

.data-content {
    padding: 0.25rem 0;
}

/* ─── mk-grid (table) ───────────────────────────────────────────────── */

.table,
table.mk-grid,
.data-content table {
    width: 100%;
    background: white;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #e8e8e8;
}

.table thead th,
table.mk-grid thead th,
.data-content table thead th {
    background: linear-gradient(135deg, #fafafa, #f4f4f4);
    border-bottom: 2px solid #e0e0e0;
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #666;
    white-space: nowrap;
}

.table thead th a,
table.mk-grid thead th a {
    color: #666;
    text-decoration: none;
}

.table thead th a:hover,
table.mk-grid thead th a:hover {
    color: var(--cl-green);
}

.table tbody td,
table.mk-grid tbody td,
.data-content table tbody td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.875rem;
    color: #444;
    vertical-align: middle;
}

.table tbody tr:hover,
table.mk-grid tbody tr:hover,
.data-content table tbody tr:hover {
    background: #f8fcf4;
}

.table tbody tr:last-child td,
.data-content table tbody tr:last-child td {
    border-bottom: none;
}

.table a,
table.mk-grid a,
.data-content table a {
    color: var(--cl-green);
    font-weight: 600;
    text-decoration: none;
}

.table a:hover,
table.mk-grid a:hover,
.data-content table a:hover {
    color: var(--cl-green-dark);
    text-decoration: underline;
}

/* ─── Grid filter row ───────────────────────────────────────────────── */

.table thead tr.mk-filter-row th,
table.mk-grid thead tr.mk-filter-row th {
    background: #f8f8f8;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.table thead tr.mk-filter-row input,
.table thead tr.mk-filter-row select {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
}

/* ─── mk-pager ──────────────────────────────────────────────────────── */

.mk-pager,
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.6rem 0;
}

.mk-pager a,
.mk-pager span,
.pagination-container a,
.pagination-container span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 0.4rem;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.15s ease;
}

.mk-pager a,
.pagination-container a {
    color: #555;
    border: 1px solid #ddd;
    background: white;
}

.mk-pager a:hover,
.pagination-container a:hover {
    background: var(--cl-green);
    color: white;
    border-color: var(--cl-green);
}

.mk-pager span.active,
.mk-pager .active > a,
.pagination-container .active > a {
    background: var(--cl-green);
    color: white;
    border: 1px solid var(--cl-green);
    font-weight: 700;
}

/* ─── mk-total-items label ──────────────────────────────────────────── */

.mk-total-items,
.total-items-label {
    font-size: 0.8rem;
    color: #888;
    padding: 0.4rem 0;
}

/* ─── Index toolbar (above grids) ───────────────────────────────────── */

.btn-toolbar.border-bottom {
    background: white;
    padding: 0.6rem 1rem;
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    border-bottom: 1px solid #e8e8e8 !important;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-toolbar.border-bottom .justify-content-start {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

/* ─── mk-fieldset ───────────────────────────────────────────────────── */

mk-fieldset fieldset,
.mk-fieldset {
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

/* ─── bg-white wrapper ──────────────────────────────────────────────── */

.bg-white {
    background: white;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 0;
    overflow: hidden;
}

/* ─── Grid filterstate toolbar button ───────────────────────────────── */

.btn-mk-sm.btn-warning,
.btn-mk-sm.active-filters {
    background: #fff8e1;
    border-color: var(--cl-gold);
    color: #b8860b;
}

.btn-mk-sm.btn-warning:hover,
.btn-mk-sm.active-filters:hover {
    background: var(--cl-gold);
    color: #333;
}

/* ─── Validation tooltip overrides ──────────────────────────────────── */

.tooltip-inner {
    background: #dc3545;
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
}

.tooltip.bs-tooltip-top .tooltip-arrow::before,
.tooltip .arrow::before {
    border-top-color: #dc3545;
}

/* ─── SweetAlert / MKFactory alert overrides ────────────────────────── */

.swal2-confirm.swal2-styled {
    background: var(--cl-green) !important;
    border-radius: 6px !important;
}

.swal2-cancel.swal2-styled {
    border-radius: 6px !important;
}

/* ─── Pagination (MKFactory uses .pagination) ──────────────────────── */

.pagination {
    margin-top: 15px;
    margin-bottom: 15px;
    margin-left: 20px;
    font-size: 11px;
}

.pagination .active a {
    background-color: var(--cl-green);
    border-color: var(--cl-green);
}

.pagination .active a:hover {
    background-color: var(--cl-green-dark);
    border-color: var(--cl-green-dark);
}

/* ─── grid-mobile-filters: hidden on desktop ────────────────────────── */

.grid-mobile-filters {
    display: none;
}

/* ─── Responsive form adjustments ───────────────────────────────────── */

@media (max-width: 767px) {
    .btn-toolbar.edit-toolbar,
    .btn-toolbar.border-bottom {
        margin: -1rem -1rem 1rem -1rem;
        padding: 0.5rem 0.75rem;
    }

    fieldset > legend {
        font-size: 0.85rem;
        padding: 0.6rem 1rem;
    }

    fieldset > .fieldset-body,
    fieldset > div:not(:first-child) {
        padding: 0.75rem 1rem;
    }

    .form-submit .btn-primary,
    .form-submit input[type="submit"].btn-primary {
        width: 100%;
    }

    .data-content {
        padding: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   MKFactory Grid - Mobile Card View
   When responsive="true" (default), small screens show a card layout
   with labels on the left and values on the right.
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

    /* Show mobile filter panel */
    .grid-mobile-filters {
        display: block;
    }

    .grid-mobile-filters .btn[aria-expanded="true"] .bi-chevron-down {
        transform: rotate(180deg);
    }

    .grid-mobile-filters .bi-chevron-down {
        transition: transform 0.2s ease-in-out;
    }

    /* Hide columns marked with hide-on-mobile */
    table.grid th.hide-on-mobile,
    table.grid td.hide-on-mobile {
        display: none !important;
    }

    /* Card-view table transformation */
    table.grid.card-view {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        border: none;
        box-shadow: none;
        background: transparent;
    }

    table.grid.card-view thead {
        display: none;
    }

    table.grid.card-view tbody {
        display: block;
        width: 100%;
    }

    /* Each row becomes a card */
    table.grid.card-view tbody tr {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.5rem;
        padding: 0.5rem;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        max-width: 100%;
        overflow: hidden;
    }

    /* Each cell uses grid for label + value layout */
    table.grid.card-view tbody td {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 1rem;
        padding: 0.5rem 0.75rem;
        border-bottom: 1px solid #eee;
        width: 100%;
        overflow: hidden;
    }

    /* Label on the left via data-label attribute */
    table.grid.card-view tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        text-align: left;
        white-space: nowrap;
    }

    /* Value on the right with truncation */
    table.grid.card-view tbody td > .cell-value {
        display: block;
        text-align: right;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }

    table.grid.card-view tbody td > .cell-value > a {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Hide pseudo-element if no data-label */
    table.grid.card-view tbody td:not([data-label])::before,
    table.grid.card-view tbody td[data-label=""]::before {
        display: none;
    }

    /* Last cell has no bottom border */
    table.grid.card-view tbody td:last-child {
        border-bottom: none;
    }

    /* Action cells (no header) grouped at bottom */
    table.grid.card-view tbody td:not([data-label]),
    table.grid.card-view tbody td[data-label=""] {
        order: 9999;
        width: auto;
        flex: 0 0 auto;
        justify-content: center;
        padding: 0.5rem 0.75rem;
        border-bottom: none;
    }

    /* Separator line before action cells */
    table.grid.card-view tbody tr:has(td:not([data-label]))::after,
    table.grid.card-view tbody tr:has(td[data-label=""])::after {
        content: '';
        order: 9998;
        width: 100%;
        height: 0;
        border-top: 1px solid #eee;
        margin-top: 0.25rem;
        padding-top: 0.25rem;
    }

    /* Empty state message (colspan cells) */
    table.grid.card-view tbody td[colspan] {
        text-align: center;
        color: #6c757d;
        font-style: italic;
    }

    table.grid.card-view tbody td[colspan]::before {
        display: none;
    }

    /* Footer */
    table.grid.card-view tfoot {
        display: block;
    }

    table.grid.card-view tfoot tr {
        display: block;
        padding: 0.5rem;
        background: #f8f9fa;
        border-radius: 0.5rem;
    }

    table.grid.card-view tfoot td {
        display: block;
        padding: 0.25rem 0.5rem;
    }
}
