/* ============================================
   TenantFlow - Main Application Styles
   ============================================ */

:root {
    --primary: #0d6efd;
    --primary-dark: #0a58ca;
    --secondary: #6610f2;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --dark: #111827;
    --light: #f8fafc;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background-color: var(--gray-50);
    color: var(--gray-800);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--dark);
    color: #fff;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
}

.sidebar-brand i { font-size: 24px; }

.sidebar-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.sidebar-business {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.business-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.business-info { min-width: 0; }
.business-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.business-role { font-size: 12px; color: var(--gray-400); }

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.sidebar-nav .nav-section {
    padding: 16px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.06);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(13, 110, 253, 0.15);
    border-left-color: var(--primary);
}

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

/* ============================================
   Main Content
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.top-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.sidebar-toggle {
    color: var(--gray-600);
    font-size: 20px;
    padding: 4px 8px;
    text-decoration: none;
}

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin-left: 8px;
}

.content-wrapper {
    padding: 24px;
}

.top-navbar .btn-link {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 14px;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
}

/* ============================================
   KPI Cards
   ============================================ */
.kpi-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid var(--gray-200);
    transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.kpi-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-800);
}

.kpi-change {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
}

.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ============================================
   Cards & Panels
   ============================================ */
.card {
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0 !important;
}

.card-body { padding: 20px; }
.card-table { padding: 0 !important; }
.card-table .table-responsive,
.card-table > table { margin: 0; }
.card-table .dt-controls {
    padding: 12px 16px;
    background: var(--gray-50);
}

/* ============================================
   Tables
   ============================================ */
.table { font-size: 14px; }
.table thead th {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--gray-600);
    padding: 12px 16px;
}
.table td { padding: 12px 16px; vertical-align: middle; }

/* ============================================
   Status Badges
   ============================================ */
.badge-vacant { background-color: #dcfce7; color: #166534; }
.badge-occupied { background-color: #dbeafe; color: #1e40af; }
.badge-maintenance { background-color: #fef3c7; color: #92400e; }
.badge-reserved { background-color: #f3e8ff; color: #6b21a8; }
.badge-active { background-color: #dcfce7; color: #166534; }
.badge-expired { background-color: #fee2e2; color: #991b1b; }
.badge-pending { background-color: #fef3c7; color: #92400e; }
.badge-paid { background-color: #dcfce7; color: #166534; }
.badge-partial { background-color: #fff7ed; color: #9a3412; }
.badge-overdue { background-color: #fee2e2; color: #991b1b; }

/* ============================================
   Forms
   ============================================ */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--gray-300);
    padding: 10px 14px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

/* ============================================
   Buttons
   ============================================ */
.btn { border-radius: 8px; font-weight: 500; font-size: 14px; padding: 10px 20px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ============================================
   Auth Pages
   ============================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.auth-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 32px;
    text-align: center;
    color: #fff;
}

.auth-header h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.auth-header p { font-size: 14px; opacity: 0.85; margin: 0; }

.auth-body { padding: 32px; }

.auth-footer {
    text-align: center;
    padding: 0 32px 32px;
    font-size: 14px;
}

.auth-footer a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

/* ============================================
   Landing Page
   ============================================ */
.hero {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 80px 0;
}

.hero h1 { font-size: clamp(2rem, 5vw, 3.5rem); font-weight: 800; line-height: 1.15; }
.hero .lead { font-size: clamp(1rem, 2vw, 1.25rem); color: #94a3b8; max-width: 540px; }

.feature-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid var(--gray-200);
    text-align: center;
    transition: transform 0.3s;
    height: 100%;
}

.feature-card:hover { transform: translateY(-4px); }

.feature-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state i { font-size: 48px; margin-bottom: 16px; }
.empty-state h5 { color: var(--gray-600); }

/* ============================================
   Sidebar Overlay (mobile)
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
}

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar.open + .main-content .sidebar-overlay,
    body.sidebar-open .sidebar-overlay {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .content-wrapper { padding: 16px; }
    .top-navbar { padding: 0 16px; }
    .kpi-value { font-size: 20px; }
}

@media (max-width: 575.98px) {
    .auth-card { border-radius: 12px; }
    .auth-header { padding: 24px; }
    .auth-body { padding: 24px; }
    .hero { padding: 40px 0; }
    .hero h1 { font-size: 1.75rem; }
}

/* ============================================
   Utilities
   ============================================ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer { cursor: pointer; }

/* Chart container */
.chart-container { position: relative; width: 100%; }

/* DataTables overrides — v2 uses div.dt-container with Bootstrap .row */
div.dt-container { padding: 0; }

/* Top and bottom control rows: DT v2 BS5 uses .row inside dt-container */
div.dt-container > .row { 
    margin: 0 !important; 
    padding: 10px 16px !important; 
    align-items: center; 
}
div.dt-container > .row:first-child { 
    border-bottom: 1px solid var(--gray-200); 
    background: var(--gray-50); 
    border-radius: 8px 8px 0 0;
}
div.dt-container > .row:last-child { 
    border-top: 1px solid var(--gray-200); 
    background: var(--gray-50); 
    border-radius: 0 0 8px 8px;
}

/* Override library stripping padding inside .table-responsive */
div.table-responsive > div.dt-container > div.row > div[class^="col-"]:first-child { padding-left: 12px !important; }
div.table-responsive > div.dt-container > div.row > div[class^="col-"]:last-child { padding-right: 12px !important; }

/* Length (entries per page) */
div.dt-length { font-size: 13px; }
div.dt-length label { font-weight: normal; white-space: nowrap; margin-bottom: 0; }
div.dt-length select { padding: 4px 8px; font-size: 13px; border-radius: 6px; border: 1px solid var(--gray-300); margin: 0 6px; width: unset !important; }

/* Search box */
div.dt-search { font-size: 13px; }
div.dt-search label { font-weight: normal; white-space: nowrap; margin-bottom: 0; }
div.dt-search input { padding: 6px 12px; font-size: 13px; border-radius: 6px; border: 1px solid var(--gray-300); outline: none; min-width: 200px; margin-left: 6px; }
div.dt-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,110,253,.15); }

/* Info (Showing X of Y) */
div.dt-info { font-size: 12px; color: var(--gray-500); padding-top: 8px; }

/* Pagination */
div.dt-paging { font-size: 13px; }
div.dt-paging ul.pagination { margin: 0; gap: 2px; }
div.dt-paging .page-link { padding: 4px 10px; font-size: 12px; border-radius: 6px; border: 1px solid var(--gray-200); color: var(--gray-700); }
div.dt-paging .page-item.active .page-link { background: var(--primary); color: #fff; border-color: var(--primary); }
div.dt-paging .page-item:not(.active):not(.disabled) .page-link:hover { background: var(--gray-100); color: var(--gray-800); }
div.dt-paging .page-item.disabled .page-link { opacity: 0.4; }

/* Empty & processing */
td.dt-empty { padding: 40px !important; text-align: center; color: var(--gray-400); }
table.dataTable thead th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-500); font-weight: 600; padding: 10px 16px !important; white-space: nowrap; }
table.dataTable tbody td { padding: 10px 16px !important; vertical-align: middle; font-size: 13px; }
table.dataTable.table-hover tbody tr:hover { background-color: rgba(13,110,253,.03) !important; }
div.dt-processing { background: rgba(255,255,255,.9) !important; border: none !important; font-size: 13px; color: var(--gray-500); }

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
