/* ================================================================
   RentFlow — CSS Premium
   Stack: Bootstrap 5.3 + Inter + Custom
   ================================================================ */

:root {
    --rf-font:            'Inter', system-ui, -apple-system, sans-serif;
    --rf-sidebar-w:       260px;
    --rf-sidebar-bg:      #0f1117;
    --rf-sidebar-border:  rgba(255,255,255,.06);
    --rf-sidebar-text:    rgba(255,255,255,.70);
    --rf-sidebar-hover:   rgba(255,255,255,.08);
    --rf-sidebar-active:  #4f46e5;
    --rf-topbar-h:        60px;
    --rf-topbar-bg:       #ffffff;
    --rf-topbar-border:   #e5e7eb;
    --rf-primary:         #4f46e5;
    --rf-primary-hover:   #4338ca;
    --rf-body-bg:         #f8f9fc;
    --rf-card-bg:         #ffffff;
    --rf-card-border:     #e5e7eb;
    --rf-card-shadow:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --rf-card-shadow-hover: 0 4px 12px rgba(0,0,0,.10);
    --rf-text:            #111827;
    --rf-text-muted:      #6b7280;
    --rf-radius:          .75rem;
    --rf-radius-sm:       .5rem;
    --rf-transition:      .15s ease;
}

/* ── Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--rf-font);
    font-size: .875rem;
    color: var(--rf-text);
    background: var(--rf-body-bg);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────────── */
.rf-body { display: flex; min-height: 100vh; }

.rf-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--rf-sidebar-w);
    height: 100vh;
    background: var(--rf-sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform var(--rf-transition);
    overflow: hidden;
}

.rf-main {
    margin-left: var(--rf-sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin var(--rf-transition);
}

/* ── Sidebar Brand ─────────────────────────────────────────────── */
.rf-sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--rf-sidebar-border);
    text-decoration: none;
}
.rf-sidebar-logo {
    width: 36px; height: 36px;
    background: var(--rf-primary);
    border-radius: var(--rf-radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: #fff;
    flex-shrink: 0;
}
.rf-sidebar-appname { font-size: .95rem; font-weight: 700; color: #fff; line-height: 1.2; }
.rf-sidebar-tenant  { font-size: .72rem; color: var(--rf-sidebar-text); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

/* ── Sidebar Nav ────────────────────────────────────────────────── */
.rf-sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .75rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent; }
.rf-sidebar-nav::-webkit-scrollbar { width: 4px; }
.rf-sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.rf-nav-item {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .55rem .75rem;
    border-radius: var(--rf-radius-sm);
    color: var(--rf-sidebar-text);
    text-decoration: none;
    font-size: .8rem;
    font-weight: 500;
    transition: background var(--rf-transition), color var(--rf-transition);
    white-space: nowrap;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
}
.rf-nav-item:hover          { background: var(--rf-sidebar-hover); color: #fff; }
.rf-nav-item.active         { background: var(--rf-primary); color: #fff; }
.rf-nav-item.active .rf-nav-icon { color: #fff; }
.rf-nav-icon { font-size: 1rem; flex-shrink: 0; opacity: .8; }
.rf-nav-item:hover .rf-nav-icon, .rf-nav-item.active .rf-nav-icon { opacity: 1; }

.rf-sidebar-footer  { padding: .75rem; border-top: 1px solid var(--rf-sidebar-border); }
.rf-nav-logout:hover { background: rgba(239,68,68,.15); color: #fca5a5; }

/* ── Topbar ─────────────────────────────────────────────────────── */
.rf-topbar {
    position: sticky; top: 0;
    height: var(--rf-topbar-h);
    background: var(--rf-topbar-bg);
    border-bottom: 1px solid var(--rf-topbar-border);
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1.5rem;
    z-index: 100;
    backdrop-filter: blur(8px);
}
.rf-sidebar-toggle {
    background: none; border: none; padding: .35rem .5rem;
    border-radius: var(--rf-radius-sm); color: var(--rf-text-muted);
    cursor: pointer; font-size: 1.25rem;
    display: none;
    transition: background var(--rf-transition);
}
.rf-sidebar-toggle:hover { background: var(--rf-body-bg); }
.rf-topbar-breadcrumb { flex: 1; }
.rf-topbar-right { display: flex; align-items: center; gap: .75rem; }

/* User button */
.rf-user-btn {
    display: flex; align-items: center; gap: .5rem;
    background: none; border: 1px solid var(--rf-card-border);
    border-radius: var(--rf-radius-sm); padding: .3rem .75rem;
    cursor: pointer; color: var(--rf-text);
    transition: background var(--rf-transition);
}
.rf-user-btn:hover { background: var(--rf-body-bg); }
.rf-user-avatar {
    width: 30px; height: 30px;
    background: var(--rf-primary); color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.rf-user-name  { font-size: .8rem; font-weight: 600; line-height: 1.2; }
.rf-user-role  { font-size: .7rem; color: var(--rf-text-muted); line-height: 1; }
.rf-dropdown   { min-width: 180px; border-radius: var(--rf-radius-sm); border-color: var(--rf-card-border); box-shadow: var(--rf-card-shadow-hover); }

/* ── Page ────────────────────────────────────────────────────────── */
.rf-page         { padding: 1.5rem; flex: 1; max-width: 100%; }
.rf-alert-bar    { border-radius: 0; font-size: .8rem; padding: .65rem 1.5rem; }
.rf-page-header  { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.rf-page-title   { font-size: 1.4rem; font-weight: 700; margin-bottom: .15rem; }
.rf-page-subtitle{ font-size: .82rem; color: var(--rf-text-muted); margin: 0; }

/* ── Cards ────────────────────────────────────────────────────────── */
.rf-card {
    background: var(--rf-card-bg);
    border: 1px solid var(--rf-card-border);
    border-radius: var(--rf-radius);
    box-shadow: var(--rf-card-shadow);
}
.rf-card-hover { transition: box-shadow var(--rf-transition), transform var(--rf-transition); }
.rf-card-hover:hover { box-shadow: var(--rf-card-shadow-hover); transform: translateY(-1px); }
.rf-card-header { padding: 1rem 1.25rem .75rem; border-bottom: 1px solid var(--rf-card-border); }
.rf-card-title  { font-size: .9rem; font-weight: 600; margin: 0; color: var(--rf-text); }
.rf-card-body   { padding: 1.25rem; }

/* ── KPI Cards ────────────────────────────────────────────────────── */
.rf-kpi-card {
    background: var(--rf-card-bg);
    border: 1px solid var(--rf-card-border);
    border-radius: var(--rf-radius);
    box-shadow: var(--rf-card-shadow);
    display: flex; align-items: center; gap: 1rem;
    padding: 1.25rem 1.5rem;
    transition: box-shadow var(--rf-transition);
}
.rf-kpi-card:hover { box-shadow: var(--rf-card-shadow-hover); }
.rf-kpi-icon {
    width: 48px; height: 48px;
    border-radius: var(--rf-radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; flex-shrink: 0;
}
.rf-kpi-body        { flex: 1; }
.rf-kpi-label       { font-size: .78rem; color: var(--rf-text-muted); font-weight: 500; margin-bottom: .25rem; }
.rf-kpi-value       { font-size: 1.45rem; font-weight: 700; line-height: 1; }
.rf-kpi-danger      { border-left: 3px solid var(--bs-danger); }

/* ── Soft backgrounds ────────────────────────────────────────────── */
.bg-primary-soft  { background: rgba(79,70,229,.1); }
.bg-success-soft  { background: rgba(34,197,94,.1); }
.bg-danger-soft   { background: rgba(239,68,68,.1); }
.bg-warning-soft  { background: rgba(245,158,11,.1); }
.bg-info-soft     { background: rgba(6,182,212,.1); }
.bg-secondary-soft{ background: rgba(107,114,128,.1); }

/* ── Tables ───────────────────────────────────────────────────────── */
.rf-table { font-size: .82rem; }
.rf-table thead th {
    font-size: .72rem; font-weight: 600;
    color: var(--rf-text-muted);
    text-transform: uppercase; letter-spacing: .04em;
    background: #f9fafb; border-bottom: 1px solid var(--rf-card-border);
    padding: .65rem 1rem; white-space: nowrap;
}
.rf-table tbody td { padding: .8rem 1rem; vertical-align: middle; border-color: #f3f4f6; }
.rf-table tbody tr:hover { background: #f9fafb; }
.rf-table tbody tr:last-child td { border-bottom: none; }

/* ── Badge ────────────────────────────────────────────────────────── */
.rf-badge { font-size: .7rem; font-weight: 600; padding: .3em .65em; border-radius: .35rem; }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-label.required::after { content: ' *'; color: var(--bs-danger); }
.form-control, .form-select {
    font-size: .85rem;
    border-radius: var(--rf-radius-sm);
    border-color: var(--rf-card-border);
    transition: border-color var(--rf-transition), box-shadow var(--rf-transition);
}
.form-control:focus, .form-select:focus {
    border-color: var(--rf-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.input-group-text { background: #f9fafb; border-color: var(--rf-card-border); font-size: .85rem; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn { font-size: .82rem; font-weight: 500; border-radius: var(--rf-radius-sm); transition: all var(--rf-transition); }
.btn-primary { background: var(--rf-primary); border-color: var(--rf-primary); }
.btn-primary:hover { background: var(--rf-primary-hover); border-color: var(--rf-primary-hover); }
.btn-sm { font-size: .78rem; padding: .3rem .65rem; }

/* ── Empty state ──────────────────────────────────────────────────── */
.rf-empty-state {
    text-align: center; padding: 3rem 1rem; color: var(--rf-text-muted);
}
.rf-empty-state i { font-size: 3rem; display: block; margin-bottom: .75rem; opacity: .4; }
.rf-empty-state p { margin: 0 0 1rem; font-size: .9rem; }

/* ── Filter bar ───────────────────────────────────────────────────── */
.rf-filter-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ── Links ────────────────────────────────────────────────────────── */
.rf-link-muted { color: var(--rf-text-muted); text-decoration: none; font-size: .8rem; }
.rf-link-muted:hover { color: var(--rf-primary); }

/* ── Overlay (mobile) ────────────────────────────────────────────── */
.rf-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }

/* ── Auth Layout ──────────────────────────────────────────────────── */
.rf-auth-body {
    background: linear-gradient(135deg, #0f1117 0%, #1e2235 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.rf-auth-wrapper { width: 100%; max-width: 440px; }
.rf-auth-card {
    background: #fff;
    border-radius: 1.25rem;
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.rf-auth-brand { text-align: center; margin-bottom: 2rem; }
.rf-brand-icon {
    width: 56px; height: 56px; background: var(--rf-primary);
    border-radius: 1rem; margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; color: #fff;
}
.rf-brand-name     { font-size: 1.5rem; font-weight: 800; color: var(--rf-text); margin: 0; }
.rf-brand-tagline  { font-size: .82rem; color: var(--rf-text-muted); margin: .25rem 0 0; }
.rf-auth-title     { font-size: 1.2rem; font-weight: 700; margin-bottom: .35rem; }
.rf-auth-subtitle  { font-size: .83rem; color: var(--rf-text-muted); margin-bottom: 1.5rem; }
.rf-btn-login      { height: 44px; font-weight: 600; font-size: .9rem; background: var(--rf-primary); border-color: var(--rf-primary); }
.rf-btn-login:hover{ background: var(--rf-primary-hover); border-color: var(--rf-primary-hover); }
.rf-auth-footer    { text-align: center; color: rgba(255,255,255,.4); font-size: .75rem; margin-top: 1.25rem; }

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination { gap: .2rem; }
.page-link  { border-radius: var(--rf-radius-sm) !important; border-color: var(--rf-card-border); color: var(--rf-text); font-size: .8rem; padding: .35rem .65rem; }
.page-item.active .page-link { background: var(--rf-primary); border-color: var(--rf-primary); }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert { font-size: .83rem; border-radius: var(--rf-radius-sm); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .rf-sidebar { transform: translateX(-100%); }
    .rf-sidebar.open { transform: translateX(0); }
    .rf-overlay.open { display: block; }
    .rf-main { margin-left: 0; }
    .rf-sidebar-toggle { display: flex; }
    .rf-page { padding: 1rem; }
    .rf-topbar { padding: 0 1rem; }
}

@media (max-width: 575.98px) {
    .rf-kpi-card { padding: 1rem; }
    .rf-kpi-value { font-size: 1.2rem; }
    .rf-auth-card { padding: 1.75rem 1.5rem; }
    .rf-page-title { font-size: 1.2rem; }
}
