/* UPGOLITE PMS - Main Stylesheet */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1a1f36;
    --sidebar-hover: #2d3352;
    --primary: #4e73df;
    --primary-dark: #3a5fc8;
    --success: #1cc88a;
    --info: #36b9cc;
    --warning: #f6c23e;
    --danger: #e74a3b;
    --dark: #5a5c69;
    --sidebar-text: #a3a8c2;
    --sidebar-active: #4e73df;
    --header-height: 60px;
    --safe-inset-top: 0px;
    --safe-inset-bottom: 0px;
    --safe-inset-left: 0px;
    --safe-inset-right: 0px;
}

@supports (padding-top: env(safe-area-inset-top)) {
    :root {
        --safe-inset-top: env(safe-area-inset-top);
        --safe-inset-bottom: env(safe-area-inset-bottom);
        --safe-inset-left: env(safe-area-inset-left);
        --safe-inset-right: env(safe-area-inset-right);
    }
}

/* Auth */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 10px;
}

.auth-icon {
    width: 80px;
    height: 80px;
    background: rgba(78,115,223,0.1);
    border: 2px solid #bbb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1040;
    transition: width 0.3s ease, transform 0.3s ease;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    min-height: 60px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border: 2px solid #bbb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    flex-shrink: 0;
}

.brand-text {
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar-body .nav-link {
    color: var(--sidebar-text);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    border-radius: 0;
    transition: all 0.2s;
    text-decoration: none;
}

.sidebar-body .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-body .nav-link.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-body .nav-link i {
    font-size: 18px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.sidebar-footer .nav-link {
    color: var(--sidebar-text);
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    background: #f8f9fc;
}

/* Sidebar collapsed */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-body .nav-link span,
.sidebar.collapsed .sidebar-footer .nav-link span {
    display: none;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Navbar */
.navbar {
    min-height: var(--header-height);
}

.navbar.sticky-top {
    background: #fff !important;
}

.sidebar-toggler {
    color: var(--dark);
    padding: 4px 8px;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58,59,69,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 2rem 0 rgba(58,59,69,0.12);
}

.stat-card {
    border-left: 4px solid;
    border-radius: 12px;
    overflow: hidden;
}

.stat-card .card-body {
    padding: 1.25rem;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: #858796;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table thead th {
    border-top: none;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #858796;
    font-weight: 700;
    background: #f8f9fc;
}

.table-hover tbody tr:hover {
    background: rgba(78,115,223,0.03);
}

/* Progress */
.progress {
    background: #eaecf4;
    border-radius: 100px;
    overflow: hidden;
}

.progress-sm { height: 8px; }
.progress-lg { height: 20px; }

.progress-bar {
    transition: width 0.6s ease;
}

/* Badge */
.badge {
    font-weight: 600;
    padding: 0.35em 0.65em;
    font-size: 0.75rem;
}

/* Avatar */
.avatar {
    font-weight: 600;
    flex-shrink: 0;
}

/* Notification dropdown */
.notification-dropdown {
    max-height: 400px;
    overflow-y: auto;
}

.notification-dropdown .dropdown-item {
    white-space: normal;
    padding: 10px 15px;
}

.notification-dropdown .dropdown-item:hover {
    background: #f8f9fc;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
}

.page-header h4 {
    font-weight: 700;
    margin: 0;
}

/* Filters */
.filters-bar {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58,59,69,0.08);
    margin-bottom: 20px;
}

/* ======================== MOBILE RESPONSIVE ======================== */
@media (max-width: 991.98px) {
    /* Sidebar off-canvas */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1039;
        animation: fadeIn 0.2s;
    }
    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
    
    /* Content padding */
    .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    .main-content {
        padding-top: 0;
        padding-bottom: 20px;
    }
    
    /* Push content below sticky navbar */
    .main-content > .container-fluid:first-child,
    .main-content > div:first-of-type {
        padding-top: 8px !important;
    }
    .main-content > .container-fluid {
        padding-top: 8px !important;
    }
    /* Ensure headings are visible */
    .container-fluid h4, .container-fluid h5, .container-fluid h6 {
        margin-top: 0;
        line-height: 1.3;
    }

    /* Top navbar */
    .navbar.sticky-top {
        padding: 6px 10px;
        min-height: 48px;
    }
    /* Push content below fixed navbar */
    .main-content > div:not(nav) {
        padding-top: 10px;
    }
    .navbar .container-fluid {
        padding: 0;
    }
    
    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 16px;
    }
    .page-header h4 {
        font-size: 1.1rem;
        white-space: normal;
        word-break: break-word;
    }
    .page-header .btn {
        width: 100%;
    }
    .page-header p, .page-header .text-muted {
        font-size: 0.8rem;
    }
    
    /* Cards */
    .card {
        border-radius: 8px;
    }
    .card-body {
        padding: 12px !important;
    }
    .card-header {
        padding: 10px 12px !important;
    }
    .card:hover {
        transform: none;
    }
    
    /* Columns - full width */
    .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9,
    .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9,
    .col-md-3, .col-md-4, .col-md-6, .col-md-8, .col-md-9,
    .col-sm-6 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 12px;
    }
    .row.g-3, .row.g-4 {
        row-gap: 8px !important;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0;
        width: 100%;
    }
    .table {
        font-size: 0.8rem;
    }
    .table thead th {
        font-size: 0.7rem;
        padding: 8px 6px;
    }
    .table td {
        padding: 8px 6px;
    }
    
    /* Forms & filters */
    .filters-bar {
        padding: 10px;
        margin-bottom: 12px;
        border-radius: 8px;
    }
    .filters-bar .row {
        flex-direction: column;
        gap: 8px;
    }
    .filters-bar .col-md-3, .filters-bar .col-md-4, .filters-bar .col-md-6,
    .filters-bar .col-sm-6, .filters-bar .col-lg-3 {
        width: 100% !important;
    }
    .form-control, .form-select {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    
    /* Buttons */
    .btn {
        font-size: 0.85rem;
        padding: 7px 14px;
    }
    .btn-lg {
        font-size: 0.9rem;
        padding: 10px 18px;
    }
    
    /* Flex layouts */
    .d-flex.gap-2, .d-flex.gap-3, .d-flex.gap-4 {
        flex-wrap: wrap;
        gap: 6px !important;
    }
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 8px;
    }
    .d-flex.justify-content-between.align-items-center {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    /* Stats */
    .stat-card .card-body {
        padding: 12px !important;
    }
    .stat-card .stat-value {
        font-size: 1.2rem;
    }
    .stat-card .stat-icon {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    .stat-card .stat-label {
        font-size: 0.7rem;
    }
    
    /* Typography */
    h3 { font-size: 1.2rem; }
    h4 { font-size: 1.1rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.9rem; }
    .fs-3 { font-size: 1.1rem !important; }
    .fs-4 { font-size: 1rem !important; }
    .fs-1 { font-size: 1.4rem !important; }
    
    /* Badges */
    .badge {
        font-size: 0.65rem;
        padding: 0.25em 0.5em;
    }
    
    /* Modals */
    .modal-dialog {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }
    .modal-body {
        padding: 12px;
    }
    
    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.75rem;
    }
    
    /* Dropdowns */
    .dropdown-menu {
        max-width: 90vw;
        font-size: 0.85rem;
    }
}

/* Small phones */
@media (max-width: 575.98px) {
    body {
        font-size: 13px;
    }
    .px-4 {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    .auth-wrapper {
        padding: 10px;
    }
    .auth-container .card-body {
        padding: 16px !important;
    }
    #sendOtpBtn, #verifyOtpBtn {
        font-size: 0.85rem;
        padding: 10px;
    }
    #otpInput {
        font-size: 1.2rem !important;
        letter-spacing: 4px !important;
    }
    .navbar .btn-link.sidebar-toggler i {
        font-size: 1.3rem !important;
    }
}

/* ============ FORCE FULL-WIDTH ON ALL COLUMNS AT MOBILE/TABLET ============ */
@media (max-width: 991.98px) {
    [class*="col-lg-"], [class*="col-xl-"] {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 12px;
    }
    /* Prevent horizontal overflow */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    .main-content {
        max-width: 100vw;
        overflow-x: hidden;
    }
    /* Dropdowns on mobile */
    .dropdown-menu {
        max-width: 90vw !important;
        min-width: auto !important;
    }
    .notification-dropdown {
        max-width: calc(100vw - 20px) !important;
        max-height: 60vh !important;
    }
    /* Fix table min-width to not force page width */
    .table {
        min-width: 0;
    }
    /* Allow tables to scroll within their container only */
    .table-responsive {
        max-width: 100%;
        margin: 0;
        width: 100%;
    }
    /* Scale down charts/canvas */
    canvas, .chart-container {
        max-width: 100% !important;
        height: auto !important;
    }
    /* Prevent any element from breaking layout */
    img, video, iframe, object, embed {
        max-width: 100%;
        height: auto;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* Sorting */
.sortable {
    cursor: pointer;
}
.sortable:hover {
    color: var(--primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #858796;
}
.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 20px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e3e6f0;
}
.timeline-item {
    position: relative;
    padding-bottom: 20px;
    padding-left: 20px;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -16px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
}

/* Safe area insets for notched devices (iOS, Android gesture nav) */
.sidebar {
    padding-top: var(--safe-inset-top);
    padding-bottom: var(--safe-inset-bottom);
}

.navbar.sticky-top {
    top: var(--safe-inset-top);
}

.main-content {
    padding-top: var(--safe-inset-top);
    padding-bottom: var(--safe-inset-bottom);
}

.footer {
    padding-bottom: var(--safe-inset-bottom);
}

.auth-wrapper {
    padding-top: calc(20px + var(--safe-inset-top)) !important;
    padding-bottom: calc(20px + var(--safe-inset-bottom)) !important;
}

/* Print */
@media print {
    .sidebar, .navbar, .sidebar-toggler, .btn, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
}

/* Custom Alert & Confirm Modal */
.pms-modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.45); z-index:9999; display:flex; align-items:center; justify-content:center; animation:fadeIn .15s; }
.pms-modal { background:#fff; border-radius:12px; padding:28px 24px 20px; max-width:380px; width:90%; box-shadow:0 15px 50px rgba(0,0,0,0.2); text-align:center; animation:scaleIn .2s; }
.pms-modal-icon { font-size:42px; margin-bottom:10px; }
.pms-modal-msg { font-size:14px; color:#444; margin-bottom:20px; line-height:1.5; word-break:break-word; }
.pms-modal-btns { display:flex; gap:10px; justify-content:center; }
.pms-modal-btns button { padding:8px 22px; border-radius:20px; border:none; font-size:14px; font-weight:600; cursor:pointer; transition:all .15s; }
.pms-btn-primary { background:#4e73df; color:#fff; } .pms-btn-primary:hover { background:#3a5fc8; }
.pms-btn-danger { background:#e74a3b; color:#fff; } .pms-btn-danger:hover { background:#c0392b; }
.pms-btn-secondary { background:#e9ecef; color:#333; } .pms-btn-secondary:hover { background:#dde1e5; }
@keyframes scaleIn { from { transform:scale(.85); opacity:0; } to { transform:scale(1); opacity:1; } }
