/* ============================================================
   PG Management Platform — Global Stylesheet v3
   Font: Plus Jakarta Sans (professional LMS-grade)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --font:          'Plus Jakarta Sans', 'Segoe UI', sans-serif;
    --sidebar-w:     264px;
    --topbar-h:      62px;
    --bg:            #f4f6fb;
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --border:        #e4e9f0;
    --border-2:      #d1d9e6;
    --text-1:        #111827;
    --text-2:        #374151;
    --text-3:        #6b7280;
    --text-4:        #9ca3af;
    --sb-bg:         #111827;
    --sb-text:       #9ca3af;
    --sb-hover-bg:   rgba(255,255,255,.05);
    --sb-active-bg:  rgba(99,102,241,.15);
    --sb-active-txt: #c7d2fe;
    --sb-active-bar: #818cf8;
    /* Brand colours */
    --indigo:   #6366f1;
    --blue:     #3b82f6;
    --sky:      #0ea5e9;
    --green:    #22c55e;
    --emerald:  #10b981;
    --orange:   #f97316;
    --amber:    #f59e0b;
    --red:      #ef4444;
    --rose:     #f43f5e;
    --purple:   #a855f7;
    --teal:     #14b8a6;
    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow:    0 4px 16px rgba(0,0,0,.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.12);
}

html { font-size: 14px; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-2);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 { font-weight: 700; color: var(--text-1); line-height: 1.3; }
h5 { font-size: 15px; }
h6 { font-size: 13px; }
.fw-300 { font-weight: 300; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: #2563eb; }
small, .small { font-size: 12px; }
.text-xs { font-size: 11px; }

/* ── App Shell ────────────────────────────────────────────── */
body.app-body { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-w); height: 100vh;
    background: var(--sb-bg);
    display: flex; flex-direction: column;
    overflow-y: auto; overflow-x: hidden;
    z-index: 1000;
    transition: width .25s cubic-bezier(.4,0,.2,1), transform .25s;
    scrollbar-width: thin;
    scrollbar-color: #374151 transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #374151; border-radius: 4px; }

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.brand-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; flex-shrink: 0;
    background: rgba(99,102,241,.2); color: #a5b4fc;
}
.brand-icon.blue   { background: rgba(59,130,246,.2); color: #93c5fd; }
.brand-icon.green  { background: rgba(16,185,129,.2); color: #6ee7b7; }
.brand-name { font-size: 15px; font-weight: 700; color: #f9fafb; letter-spacing: -.2px; }
.brand-sub  { font-size: 11px; color: var(--sb-text); margin-top: 1px; }

.sidebar-nav { padding: 10px 0 24px; flex: 1; }
.nav-group-label {
    padding: 16px 20px 5px;
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 1.2px; color: #4b5563; font-weight: 700;
}
.nav-link-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px; margin: 1px 8px;
    color: var(--sb-text); text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-link-item:hover { background: var(--sb-hover-bg); color: #e5e7eb; }
.nav-link-item.active {
    background: var(--sb-active-bg); color: var(--sb-active-txt);
    border-left-color: var(--sb-active-bar); font-weight: 600;
}
.nav-link-item i { width: 17px; font-size: 13.5px; opacity: .9; flex-shrink: 0; }

/* Collapsed */
.sidebar.collapsed { width: 66px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-link-item span,
.sidebar.collapsed .nav-group-label { display: none; }
.sidebar.collapsed .nav-link-item { justify-content: center; padding: 11px; margin: 2px 8px; border-left: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 18px 14px; }
.sidebar.collapsed + .app-main { margin-left: 66px; }

/* ── Main Content ─────────────────────────────────────────── */
.app-main {
    margin-left: var(--sidebar-w); flex: 1;
    display: flex; flex-direction: column; min-height: 100vh;
    transition: margin-left .25s;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h); background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; gap: 12px;
    position: sticky; top: 0; z-index: 900;
    box-shadow: var(--shadow-sm);
}
.btn-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: 16px; padding: 6px 8px;
    border-radius: var(--radius-sm); line-height: 1; display: flex; align-items: center;
}
.btn-toggle:hover { background: var(--bg); color: var(--text-1); }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text-1); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.user-btn {
    background: none; border: none; cursor: pointer;
    display: flex; align-items: center; gap: 9px;
    color: var(--text-2); font-size: 13.5px; font-weight: 500;
    padding: 5px 9px; border-radius: var(--radius-sm);
    font-family: var(--font);
    transition: background .15s;
}
.user-btn:hover { background: var(--bg); }
.user-btn::after { display: none !important; }

.avatar {
    width: 32px; height: 32px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; flex-shrink: 0; color: #fff;
    background: var(--indigo);
}
.avatar.blue   { background: var(--blue); }
.avatar.green  { background: var(--emerald); }
.avatar.orange { background: var(--orange); }

.role-badge {
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; letter-spacing: .3px;
    font-family: var(--font);
}
.role-badge.admin  { background: #ede9fe; color: #7c3aed; }
.role-badge.owner  { background: #dbeafe; color: #1d4ed8; }
.role-badge.tenant { background: #dcfce7; color: #166534; }

.icon-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-3); font-size: 15px; padding: 6px 8px;
    border-radius: var(--radius-sm); position: relative;
    transition: background .15s; display: flex; align-items: center;
}
.icon-btn:hover { background: var(--bg); color: var(--text-1); }
.notif-badge {
    position: absolute; top: 2px; right: 2px;
    background: var(--red); color: #fff;
    border-radius: 50%; width: 16px; height: 16px;
    font-size: 9px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

/* ── Page Content ─────────────────────────────────────────── */
.page-main { padding: 28px 28px 40px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-header {
    background: transparent; border-bottom: 1px solid var(--border);
    padding: 14px 20px; border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-header h5 { font-size: 14px; font-weight: 700; color: var(--text-1); }
.card-header h6 { font-size: 13px; font-weight: 600; color: var(--text-1); }
.card-body { padding: 20px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
    border-radius: var(--radius-lg); padding: 20px 22px;
    color: #fff; display: flex; align-items: center; gap: 16px;
    border: none; box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s; cursor: default;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card.indigo  { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.stat-card.blue    { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-card.green   { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.orange  { background: linear-gradient(135deg, #f97316, #ea580c); }
.stat-card.red     { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card.teal    { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.stat-card.purple  { background: linear-gradient(135deg, #a855f7, #9333ea); }
.stat-card.amber   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon { font-size: 1.9rem; opacity: .85; flex-shrink: 0; }
.stat-val  { font-size: 1.7rem; font-weight: 800; line-height: 1; letter-spacing: -.5px; }
.stat-lbl  { font-size: 11.5px; opacity: .88; margin-top: 4px; font-weight: 500; }

/* ── Tables ───────────────────────────────────────────────── */
.table { color: var(--text-2); font-family: var(--font); }
.table thead th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
    color: var(--text-3); font-weight: 600; border-top: none;
    background: var(--surface-2); padding: 11px 16px;
    white-space: nowrap;
}
.table tbody td { padding: 12px 16px; vertical-align: middle; font-size: 13.5px; }
.table tbody tr:hover td { background: #fafbff; }
.table-borderless td, .table-borderless th { border: none; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label {
    font-size: 12.5px; font-weight: 600; color: var(--text-2);
    margin-bottom: 5px; display: block; font-family: var(--font);
}
.form-control, .form-select, .form-control-color {
    font-family: var(--font); font-size: 13.5px;
    border: 1.5px solid var(--border-2); border-radius: var(--radius-sm);
    padding: 9px 13px; color: var(--text-1); background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    line-height: 1.5;
}
.form-control:focus, .form-select:focus {
    border-color: var(--blue); outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
    background: var(--surface);
}
.form-control::placeholder { color: var(--text-4); font-size: 13px; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--red); }
.form-text { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.invalid-feedback { font-size: 11.5px; color: var(--red); margin-top: 3px; display: block; }
.input-group-text {
    font-family: var(--font); font-size: 13px; color: var(--text-3);
    border: 1.5px solid var(--border-2); background: var(--surface-2);
    padding: 9px 13px;
}
.input-group .form-control { border-left: none; }
.input-group .input-group-text:first-child { border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .form-control:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-check-input { cursor: pointer; }
.form-check-label { font-size: 13px; font-family: var(--font); cursor: pointer; }
.form-switch .form-check-input { width: 2.2em; }
hr { border-color: var(--border); opacity: 1; margin: 20px 0; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    font-family: var(--font); font-size: 13px; font-weight: 600;
    border-radius: var(--radius-sm); padding: 8px 16px;
    transition: all .15s; letter-spacing: .1px; display: inline-flex;
    align-items: center; gap: 6px; line-height: 1.4;
}
.btn:focus { box-shadow: none; outline: none; }
.btn-primary    { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }
.btn-success    { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.btn-success:hover { background: #059669; border-color: #059669; }
.btn-warning    { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn-danger     { background: var(--red); border-color: var(--red); color: #fff; }
.btn-outline-primary   { color: var(--blue); border-color: var(--blue); }
.btn-outline-primary:hover   { background: var(--blue); color: #fff; }
.btn-outline-secondary { color: var(--text-3); border-color: var(--border-2); }
.btn-outline-secondary:hover { background: var(--bg); color: var(--text-1); border-color: var(--border-2); }
.btn-outline-success   { color: var(--emerald); border-color: var(--emerald); }
.btn-outline-success:hover   { background: var(--emerald); color: #fff; }
.btn-outline-danger    { color: var(--red); border-color: var(--red); }
.btn-outline-danger:hover    { background: var(--red); color: #fff; }
.btn-outline-warning   { color: var(--amber); border-color: var(--amber); }
.btn-outline-warning:hover   { background: var(--amber); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    font-family: var(--font); font-weight: 600; font-size: 11px;
    padding: 3.5px 9px; border-radius: 6px; letter-spacing: .1px;
}
.bg-success-subtle { background: #dcfce7; color: #166534; }
.bg-danger-subtle  { background: #fee2e2; color: #991b1b; }
.bg-warning-subtle { background: #fef9c3; color: #854d0e; }
.bg-primary-subtle { background: #dbeafe; color: #1e40af; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { border: none; border-radius: var(--radius); font-size: 13px; font-family: var(--font); }
.alert-success { background: #f0fdf4; color: #166534; border-left: 3px solid var(--emerald); }
.alert-danger  { background: #fff1f2; color: #9f1239; border-left: 3px solid var(--red); }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid var(--amber); }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 3px solid var(--blue); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-content { border: none; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-family: var(--font); }
.modal-header  { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.modal-body    { padding: 20px 24px; }
.modal-footer  { padding: 16px 24px 20px; border-top: 1px solid var(--border); }
.modal-title   { font-size: 15px; font-weight: 700; color: var(--text-1); }
.btn-close     { opacity: .5; }

/* ── Dropdowns ────────────────────────────────────────────── */
.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-family: var(--font); padding: 6px; }
.dropdown-item { font-size: 13px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 500; }
.dropdown-item:hover { background: var(--surface-2); color: var(--text-1); }
.dropdown-item i { width: 16px; }

/* ── Page breadcrumb ──────────────────────────────────────── */
.breadcrumb { font-size: 12px; color: var(--text-3); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-4); }
.breadcrumb-item.active { color: var(--text-3); }

/* ── Responsive sidebar ───────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-main { margin-left: 0 !important; }
    .page-main { padding: 16px; }
    .stat-card { padding: 16px; }
}

/* ── Login Page ───────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh; padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #0f172a 100%);
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.login-wrapper::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse 60% 60% at 70% 30%, rgba(99,102,241,.15) 0%, transparent 60%),
                radial-gradient(ellipse 40% 40% at 20% 80%, rgba(59,130,246,.1) 0%, transparent 60%);
}
.login-card {
    background: var(--surface); border-radius: 20px;
    padding: 44px 40px; width: 100%; max-width: 420px;
    box-shadow: 0 30px 80px rgba(0,0,0,.4);
    position: relative; z-index: 1;
    border: 1px solid rgba(255,255,255,.08);
}
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo .logo-icon {
    width: 58px; height: 58px;
    background: linear-gradient(135deg, var(--blue), var(--indigo));
    border-radius: 16px; display: inline-flex; align-items: center;
    justify-content: center; color: #fff; font-size: 24px; margin-bottom: 14px;
    box-shadow: 0 8px 24px rgba(99,102,241,.35);
}
.login-logo h4 { font-size: 22px; font-weight: 800; color: var(--text-1); letter-spacing: -.3px; }
.login-logo p  { color: var(--text-3); font-size: 13px; margin-top: 4px; }

/* ── List group ───────────────────────────────────────────── */
.list-group-item { padding: 12px 20px; border-color: var(--border); font-family: var(--font); font-size: 13.5px; }

/* ── Progress ─────────────────────────────────────────────── */
.progress { background: var(--surface-2); border-radius: 20px; }
.progress-bar { background: var(--blue); border-radius: 20px; }

/* ── Feature toggle cards (Flat create) ──────────────────── */
.feature-label {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    padding: 12px 8px; border: 1.5px solid var(--border-2); border-radius: var(--radius);
    cursor: pointer; text-align: center; font-size: 11.5px; font-weight: 500;
    color: var(--text-3); transition: all .15s; user-select: none; font-family: var(--font);
}
.feature-label i { font-size: 1.2rem; color: var(--text-4); transition: color .15s; }
.feature-label:hover { border-color: var(--blue); background: #eff6ff; color: var(--blue); }
.feature-label:hover i { color: var(--blue); }
.feature-cb:checked + .feature-label { border-color: var(--blue); background: #dbeafe; color: var(--blue); font-weight: 600; }
.feature-cb:checked + .feature-label i { color: var(--blue); }

/* ── Stat summary row ─────────────────────────────────────── */
.summary-box {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 18px;
    display: flex; align-items: center; gap: 12px;
}
.summary-box .s-icon { font-size: 1.4rem; opacity: .7; }
.summary-box .s-val  { font-size: 1.2rem; font-weight: 800; color: var(--text-1); }
.summary-box .s-lbl  { font-size: 11px; color: var(--text-3); font-weight: 500; }

/* ── Print (rent slip) ────────────────────────────────────── */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; font-family: var(--font); }
}
