/* ── Debitas Custom Styles ──────────────────────────────── */
/* Modern Bootstrap 5.3 enhancement layer                    */

:root {
    /* Brand Colors */
    --df-primary: #2563a8;
    --df-primary-hover: #1a3a5c;
    --df-primary-light: #f0f4ff;

    /* Bootstrap primary override */
    --bs-primary: #2563a8;
    --bs-primary-rgb: 37, 99, 168;
    --bs-link-color: #2563a8;
    --bs-link-hover-color: #1a3a5c;
    --bs-link-color-rgb: 37, 99, 168;
    --df-secondary: #475569;
    --df-success: #16a34a;
    --df-warning: #d97706;
    --df-danger: #dc2626;
    --df-info: #0891b2;

    /* Neutrals */
    --df-bg: #f8fafc;
    --df-surface: #ffffff;
    --df-border: #e2e8f0;
    --df-text: #1e293b;
    --df-text-muted: #64748b;

    /* Spacing */
    --df-sidebar-width: 260px;
    --df-sidebar-collapsed: 70px;
    --df-topbar-height: 60px;
    --df-radius: 0.5rem;
    --df-radius-lg: 0.75rem;

    /* Shadows */
    --df-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --df-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --df-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --df-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

    /* Transitions */
    --df-transition: 0.2s ease;
}

/* ── Dark Mode ────────────────────────────────────────────── */
[data-bs-theme="dark"] {
    --df-bg: #0f172a;
    --df-surface: #1e293b;
    --df-border: #334155;
    --df-text: #f1f5f9;
    --df-text-muted: #94a3b8;
    --df-primary-light: #1e3a5f;
    --df-shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --df-shadow: 0 1px 3px rgba(0,0,0,0.3);
    --df-shadow-md: 0 4px 6px rgba(0,0,0,0.3);
}

/* ── Base ─────────────────────────────────────────────────── */
body {
    background-color: var(--df-bg);
    color: var(--df-text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

a { color: var(--df-primary); }
a:hover { color: var(--df-primary-hover); }

/* ── Sidebar ──────────────────────────────────────────────── */
.df-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--df-sidebar-width);
    height: 100vh;
    background: var(--df-surface);
    border-right: 1px solid var(--df-border);
    box-shadow: var(--df-shadow);
    z-index: 1040;
    transition: width var(--df-transition), transform var(--df-transition);
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.df-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--df-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--df-border);
    flex-shrink: 0;
}

.df-sidebar-brand i { font-size: 1.5rem; }

.df-sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
    flex: 1;
}

.df-sidebar-nav .nav-item { padding: 0 0.75rem; }

.df-sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--df-radius);
    color: var(--df-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--df-transition);
    margin-bottom: 2px;
}

.df-sidebar-nav .nav-link:hover {
    background: var(--df-primary-light);
    color: var(--df-primary);
}

.df-sidebar-nav .nav-link.active {
    background: var(--df-primary);
    color: #fff;
    box-shadow: var(--df-shadow-sm);
}

.df-sidebar-nav .nav-link i { width: 20px; text-align: center; font-size: 1rem; }

.df-sidebar-section {
    padding: 0.5rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--df-text-muted);
    margin-top: 0.5rem;
}

/* ── Topbar ───────────────────────────────────────────────── */
.df-topbar {
    position: fixed;
    top: 0;
    left: var(--df-sidebar-width);
    right: 0;
    height: var(--df-topbar-height);
    background: var(--df-surface);
    border-bottom: 1px solid var(--df-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 1030;
    box-shadow: var(--df-shadow-sm);
    transition: left var(--df-transition);
}

.df-topbar-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.df-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ── Main Content ─────────────────────────────────────────── */
.df-main {
    margin-left: var(--df-sidebar-width);
    padding-top: var(--df-topbar-height);
    min-height: 100vh;
    transition: margin-left var(--df-transition);
}

.df-content {
    padding: 1.5rem;
    max-width: 1400px;
}

/* ── Cards ────────────────────────────────────────────────── */
.df-card {
    background: var(--df-surface);
    border: 1px solid var(--df-border);
    border-radius: var(--df-radius-lg);
    box-shadow: var(--df-shadow-sm);
    transition: box-shadow var(--df-transition);
}

.df-card:hover { box-shadow: var(--df-shadow-md); }

.df-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--df-border);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.df-card-body { padding: 1.25rem; }

/* ── Stat Cards ───────────────────────────────────────────── */
.df-stat-card {
    background: var(--df-surface);
    border: 1px solid var(--df-border);
    border-radius: var(--df-radius-lg);
    padding: 1.25rem;
    box-shadow: var(--df-shadow-sm);
    transition: all var(--df-transition);
}

.df-stat-card:hover {
    box-shadow: var(--df-shadow-md);
    transform: translateY(-2px);
}

.df-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--df-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.df-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.df-stat-label {
    font-size: 0.8rem;
    color: var(--df-text-muted);
    font-weight: 500;
}

/* ── Tables ───────────────────────────────────────────────── */
.df-table {
    width: 100%;
    border-collapse: collapse;
}

.df-table thead th {
    background: var(--df-bg);
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--df-text-muted);
    border-bottom: 2px solid var(--df-border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.df-table thead th:hover { color: var(--df-primary); }

.df-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--df-border);
    font-size: 0.875rem;
    vertical-align: middle;
}

.df-table tbody tr:hover { background: var(--df-primary-light); }
.df-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges / Status ──────────────────────────────────────── */
.df-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
}

.df-badge-active { background: #dcfce7; color: #166534; }
.df-badge-paid { background: #f0f4ff; color: #1a3a5c; }
.df-badge-overdue { background: #fef2f2; color: #991b1b; }
.df-badge-arrangement { background: #fef3c7; color: #92400e; }
.df-badge-legal { background: #fce7f3; color: #9d174d; }
.df-badge-hold { background: #f1f5f9; color: #475569; }

[data-bs-theme="dark"] .df-badge-active { background: #064e3b; color: #6ee7b7; }
[data-bs-theme="dark"] .df-badge-paid { background: #1e3a5f; color: #93c5fd; }
[data-bs-theme="dark"] .df-badge-overdue { background: #450a0a; color: #fca5a5; }
[data-bs-theme="dark"] .df-badge-arrangement { background: #451a03; color: #fcd34d; }
[data-bs-theme="dark"] .df-badge-legal { background: #500724; color: #f9a8d4; }
[data-bs-theme="dark"] .df-badge-hold { background: #334155; color: #94a3b8; }

/* ── Forms ────────────────────────────────────────────────── */
.df-form-control {
    border: 1px solid var(--df-border);
    border-radius: var(--df-radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color var(--df-transition), box-shadow var(--df-transition);
    background: var(--df-surface);
    color: var(--df-text);
}

.df-form-control:focus {
    border-color: var(--df-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.df-form-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--df-text-muted);
    margin-bottom: 0.375rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.df-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--df-radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--df-transition);
}

.df-btn-primary { background: var(--df-primary); color: #fff; }
.df-btn-primary:hover { background: var(--df-primary-hover); }
.df-btn-outline { background: transparent; border: 1px solid var(--df-border); color: var(--df-text); }
.df-btn-outline:hover { background: var(--df-bg); border-color: var(--df-primary); color: var(--df-primary); }
.df-btn-danger { background: var(--df-danger); color: #fff; }
.df-btn-danger:hover { background: #b91c1c; }
.df-btn-success { background: var(--df-success); color: #fff; }
.df-btn-success:hover { background: #15803d; }
.df-btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

/* ── Loading / Skeleton ───────────────────────────────────── */
.df-skeleton {
    background: linear-gradient(90deg, var(--df-border) 25%, var(--df-bg) 50%, var(--df-border) 75%);
    background-size: 200% 100%;
    animation: df-shimmer 1.5s infinite;
    border-radius: var(--df-radius);
}

@keyframes df-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.df-skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.df-skeleton-card { height: 120px; }

.df-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--df-border);
    border-top-color: var(--df-primary);
    border-radius: 50%;
    animation: df-spin 0.6s linear infinite;
}

@keyframes df-spin { to { transform: rotate(360deg); } }

.df-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}

[data-bs-theme="dark"] .df-loading-overlay { background: rgba(15,23,42,0.7); }

/* ── Toast ────────────────────────────────────────────────── */
.df-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.df-toast {
    padding: 0.75rem 1rem;
    border-radius: var(--df-radius);
    box-shadow: var(--df-shadow-lg);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: df-slideIn 0.3s ease;
    max-width: 400px;
}

.df-toast-success { background: #065f46; color: #fff; }
.df-toast-error { background: #991b1b; color: #fff; }
.df-toast-warning { background: #92400e; color: #fff; }
.df-toast-info { background: #1a3a5c; color: #fff; }

@keyframes df-slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Auth Pages ───────────────────────────────────────────── */
.df-auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a3a5c 0%, #2563a8 100%);
    padding: 2rem;
}

.df-auth-card {
    background: var(--df-surface);
    border-radius: var(--df-radius-lg);
    box-shadow: var(--df-shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
}

.df-auth-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.df-auth-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--df-primary);
}

.df-auth-logo p {
    color: var(--df-text-muted);
    font-size: 0.875rem;
}

/* ── Responsive ───────────────────────────────────────────── */

/* Tablet / landscape phone — sidebar slides off-canvas */
@media (max-width: 991.98px) {
    .df-sidebar { transform: translateX(-100%); }
    .df-sidebar.show { transform: translateX(0); }
    .df-topbar { left: 0; }
    .df-main { margin-left: 0; }
}

/* Tablet portrait (576px – 767px) — content narrower, compress table */
@media (max-width: 767.98px) {
    .df-content { padding: 1rem; }

    /* Topbar: less horizontal padding, truncate long titles */
    .df-topbar { padding: 0 1rem; }
    .df-topbar-title {
        font-size: 1rem;
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Compact table cells */
    .df-table thead th,
    .df-table tbody td { padding: 0.5rem 0.625rem; font-size: 0.8125rem; }

    /* Card headers can wrap when they have multiple actions */
    .df-card-header { flex-wrap: wrap; gap: 0.5rem; }

    /* Stat cards */
    .df-stat-card { padding: 1rem; }
    .df-stat-value { font-size: 1.5rem; }

    /* Pagination: stack count + buttons */
    .df-pagination { flex-direction: column; gap: 0.5rem; text-align: center; }
}

/* Mobile (< 576px) — single-column, very compact */
@media (max-width: 575.98px) {
    .df-content { padding: 0.75rem; }
    .df-auth-card { padding: 1.5rem; }

    /* Topbar title: shorter truncation */
    .df-topbar-title {
        max-width: 130px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Page header (title + primary action button) — wrap to two lines */
    .df-content > .d-flex.justify-content-between.align-items-center {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Compact table cells */
    .df-table thead th,
    .df-table tbody td { padding: 0.375rem 0.5rem; font-size: 0.75rem; }

    /* Table action buttons: tighter padding on mobile */
    .df-table .btn.btn-sm { padding: 0.2rem 0.35rem; font-size: 0.7rem; }
    .df-table .btn.btn-sm.me-1 { margin-right: 0.15rem !important; }

    /* Stat cards */
    .df-stat-value { font-size: 1.25rem; }
    .df-stat-icon { width: 40px; height: 40px; font-size: 1rem; }

    /* Filter bar labels: smaller to save vertical space */
    .df-card-body .form-label { font-size: 0.8rem; margin-bottom: 0.2rem; }

    /* Form elements: full-height touch targets */
    .df-card-body .form-control,
    .df-card-body .form-select { font-size: 0.875rem; }

    /* Card header wrap */
    .df-card-header { flex-wrap: wrap; gap: 0.5rem; }
}

/* ── Empty State ──────────────────────────────────────────── */
.df-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--df-text-muted);
}

.df-empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.df-empty-state h5 { color: var(--df-text); margin-bottom: 0.5rem; }
.df-empty-state p { font-size: 0.875rem; }

/* ── Pagination ───────────────────────────────────────────── */
.df-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--df-border);
    font-size: 0.8rem;
    color: var(--df-text-muted);
}

.df-pagination-btns {
    display: flex;
    gap: 0.25rem;
}

.df-page-btn {
    padding: 0.3rem 0.6rem;
    border-radius: var(--df-radius);
    border: 1px solid var(--df-border);
    background: var(--df-surface);
    color: var(--df-text);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--df-transition);
}

.df-page-btn:hover { border-color: var(--df-primary); color: var(--df-primary); }
.df-page-btn.active { background: var(--df-primary); color: #fff; border-color: var(--df-primary); }
.df-page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--df-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--df-text-muted); }

/* ── Utilities ────────────────────────────────────────────── */
.df-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.df-clickable { cursor: pointer; }
.df-divider { border-top: 1px solid var(--df-border); margin: 1rem 0; }
