/* =========================
   DASHBOARD BASE
   ========================= */
body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f0ed; /* Warm Cream from logo */
}

/* =========================
   SIDEBAR COLORS (SURAXON BRAND)
   ========================= */
:root {
    --sidebar-bg: #051931;        /* Navy from logo */
    --sidebar-text: #ffffff;
    --sidebar-hover-text: #c38258; /* Light Copper from logo */
    --sidebar-muted: #d7cdc9;      /* Warm Beige from logo */
    --sidebar-active-bg: #0a2647;   /* Slightly lighter navy */
    --sidebar-border: #904d26;      /* Dark Copper accent */
}

/* =========================
   SIDEBAR BASE
   ========================= */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
}

/* =========================
   ACTIVE DEVICE STRIP
   ========================= */
.sidebar-active-device {
    background: #904d26;           /* Dark Copper from logo */
    color: #ffffff;
    min-height: 60px;
    position: sticky;
    top: 0;
    z-index: 20;
    margin-top: -18px;
    border-bottom: 1px solid rgba(144, 77, 38, 0.3);
}

/* =========================
   SCROLLABLE MENU AREA
   ========================= */
.sidebar-menu-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}

/* Scrollbar */
.sidebar-menu-scroll::-webkit-scrollbar {
    width: 6px;
}
.sidebar-menu-scroll::-webkit-scrollbar-thumb {
    background: rgba(195, 130, 88, 0.4); /* Light Copper tint */
    border-radius: 3px;
}
.sidebar-menu-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(195, 130, 88, 0.7);
}

/* =========================
   NAV LINKS
   ========================= */
#sidebarMenu .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    background-color: transparent !important;
    color: var(--sidebar-text) !important;
    text-decoration: none;
    transition: color 0.15s ease;
}

#sidebarMenu .nav-link:hover {
    color: var(--sidebar-hover-text) !important;
    background: rgba(144, 77, 38, 0.15) !important; /* Dark Copper tint */
}

#sidebarMenu .nav-link.active,
#sidebarMenu .nav-link[aria-expanded="true"] {
    color: var(--sidebar-hover-text) !important;
    font-weight: 600;
    background: rgba(144, 77, 38, 0.2) !important;
    border-left: 3px solid #904d26; /* Dark Copper */
}

#sidebarMenu .nav-link i {
    color: inherit;
}

/* =========================
   NESTED MENUS
   ========================= */
#sidebarMenu .nav .nav {
    padding-left: 1rem;
}

#sidebarMenu .nav .nav .nav-link {
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--sidebar-muted) !important;
}

#sidebarMenu .nav .nav .nav-link:hover {
    color: var(--sidebar-hover-text) !important;
    background: rgba(195, 130, 88, 0.1) !important;
}

/* =========================
   CHEVRON ROTATION
   ========================= */
#sidebarMenu .nav-link.collapsed .bi-chevron-down {
    transition: transform 0.25s ease;
    color: #d7cdc9;
}
#sidebarMenu .nav-link:not(.collapsed) .bi-chevron-down {
    transform: rotate(180deg);
    color: #c38258; /* Light Copper */
}

/* =========================
   CONNECTED DEVICES
   ========================= */
.connected-device {
    display: block;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--sidebar-text);
    text-decoration: none;
}

.connected-device:hover,
.connected-device.active {
    color: var(--sidebar-hover-text);
    background: rgba(144, 77, 38, 0.15);
    font-weight: 600;
    border-left: 2px solid #904d26;
}

/* ================================
   DEVICE ACTIVITY TIMELINE
   (SCROLL SAFE)
================================ */

.activity-scroll {
    height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Wrapper that grows with content */
.timeline-wrapper {
    position: relative;
}

/* Vertical dotted center line */
.timeline-wrapper::before {
    content: "";
    position: absolute;
    left: 128px;
    top: 0;
    bottom: 0;
    width: 2px;
    border-left: 2px dashed #d7cdc9; /* Warm Beige */
}

/* Row */
.activity-row, .notification-row {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 16px 0;
    position: relative;
}

/* Time column */
.activity-time, .notification-time {
    width: 90px;
    font-size: 13px;
    color: #697685; /* Slate */
    text-align: right;
    padding-right: 10px;
}

/* Icon wrapper */
.activity-icon, .notification-icon {
    width: 40px;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 2;
}

/* Icon background */
.activity-icon span, .notification-icon span {
    width: 40px;
    height: 40px;
    background: #f5f0ed; /* Warm Cream */
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 6px rgba(5, 25, 49, 0.06); /* Navy shadow */
}

/* Text */
.activity-text, .notification-text {
    font-size: 15px;
    font-weight: 500;
    color: #051931; /* Navy */
    flex: 1;
    padding-top: 5px;
}

/* Subtle row hover */
.activity-row:hover, .notification-row:hover {
    background: #faf8f7;
    transition: 0.2s ease;
}


/* Prevent full page freeze */
.call-logs-wrapper {
    display: block;
    width: 100%;
}

/* Inner scroll area */
.call-inner-scroll {
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
}

/* Ensure sticky header works correctly */
.call-scroll-body thead th {
    position: sticky;
    top: 0;
    background: #f5f0ed; /* Warm Cream */
    z-index: 2;
    color: #051931; /* Navy */
    border-bottom: 2px solid #d7cdc9;
}

/* Prevent table overflow breaking layout */
.table-responsive {
    overflow-x: auto;
}

/* ===== Leaflet Map FIX ===== */
#map {
    height: 300px !important;
    width: 100%;
    min-height: 300px;
}

.leaflet-container {
    height: 100%;
    width: 100%;
}

/* =========================================
   MOBILE (< 992px)
   ========================================= */
@media (max-width: 991.98px) {

    /* IMPORTANT: remove fixed vh layout on mobile */
    #app-shell {
        height: auto;
        display: block;
        padding-top: 48px;
    }

    .app-content {
        height: auto;
        overflow: visible;
    }

    body {
        overflow: auto;
        background: #f5f0ed;
    }

    /* Sidebar */
    #sidebarMenu {
        position: fixed;
        top: 48px;
        left: 0;
        width: 260px;
        height: calc(100dvh - 48px);
        z-index: 1050;
        background: #051931 !important; /* Navy */
    }

    #sidebarMenu .offcanvas-body {
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-menu-scroll {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Content */
    #main-content,
    .content-wrapper {
        margin-left: 0;
        width: 100%;
        padding-bottom: 1rem;
    }
}

/* =========================================
   FINAL SIDEBAR | TOPBAR STRUCTURE (STABLE)
   ========================================= */

html, body {
    height: 100%;
    margin: 0;
    overflow: auto;
    background: #f5f0ed; /* Warm Cream */
}

#app-shell {
    height: 100vh;
    display: flex;
    padding-top: 62px;
}

#main-content {
    flex: 1;
    min-height: 0;
}

.app-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: #f5f0ed; /* Warm Cream */
}

/* ================================
   DESKTOP SIDEBAR
   ================================ */
@media (min-width: 992px) {

    #sidebarMenu {
        position: fixed !important;
        top: 62px;
        left: 0;
        width: 260px;
        height: calc(100vh - 62px);
        transform: none !important;
        visibility: visible !important;
        z-index: 2000;
        background: #051931 !important; /* Navy */
    }

    /* Make offcanvas-body full height flex container */
    #sidebarMenu .offcanvas-body {
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden !important;
        padding: 0;
        background: #051931; /* Navy */
    }

    /* Fixed top sections */
    .sidebar-active-device,
    .device-switcher-panel {
        flex-shrink: 0;
    }

    /* ONLY this should scroll */
    .sidebar-menu-scroll {
        flex: 1 1 auto;
        overflow-y: auto !important;
        overflow-x: hidden;
        min-height: 0;
    }

    .app-content {
        margin-left: 260px;
    }
}

.modal {
    z-index: 3000 !important;
}

.modal-backdrop {
    z-index: 2990 !important;
}

/* ================================
   TOPBAR (RIGHT AREA ONLY)
   ================================ */
.topbar {
    height: 60px;
    min-height: 60px;
    background-color: #ffffff;
    border-bottom: 1px solid #d7cdc9; /* Warm Beige */
    display: flex;
    align-items: center;
    padding: 0 1rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 1020;
}

/* Topbar buttons & links */
.topbar .btn-outline-secondary {
    border-color: #d7cdc9;
    color: #697685;
}
.topbar .btn-outline-secondary:hover {
    background: #f5f0ed;
    color: #051931;
    border-color: #c38258;
}

.latest-keylog_item:hover {
    background-color: #f5f0ed;
    border-radius: 8px;
    transition: 0.2s ease;
}

/* ===== Single Box Modules Layout ===== */

.module-item {
    padding: 10px 0;
}

.module-circle {
    width: 60px;
    height: 60px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: #f5f0ed; /* Warm Cream */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s ease;
    border: 2px solid #d7cdc9;
}

.module-circle i {
    font-size: 22px;
    color: #904d26; /* Dark Copper */
}

.module-item:hover .module-circle {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(5, 25, 49, 0.08); /* Navy shadow */
    border-color: #c38258; /* Light Copper */
    background: #faf8f7;
}

.module-label {
    font-size: 13px;
    font-weight: 600;
    color: #051931; /* Navy */
}

.module-badge {
    position: absolute;
    top: -2px;
    right: 18px;
    background: #904d26; /* Dark Copper */
    color: #fff;
    font-size: 10px;
    padding: 4px 6px;
    border-radius: 20px;
}

/* Inner scroll smooth */
.table-hover tbody tr:hover {
    background-color: #f5f0ed; /* Warm Cream */
}

/* Sticky header */
thead.sticky-top {
    top: 0;
    z-index: 5;
    background: #f5f0ed;
}

/* Card radius */
.card {
    border-radius: 12px;
    border: 1px solid #d7cdc9; /* Warm Beige */
    background: #ffffff;
}

.card-header {
    background: #faf8f7;
    border-bottom: 1px solid #d7cdc9;
    color: #051931; /* Navy */
    font-weight: 600;
}

/* Smooth scrollbar */
div[style*="overflow-y"]::-webkit-scrollbar {
    width: 6px;
}

div[style*="overflow-y"]::-webkit-scrollbar-thumb {
    background: #c38258; /* Light Copper */
    border-radius: 6px;
}

div[style*="overflow-y"]::-webkit-scrollbar-thumb:hover {
    background: #904d26; /* Dark Copper */
}

.page-container {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(5, 25, 49, 0.05); /* Navy shadow */
    padding: 1rem;
    border: 1px solid #d7cdc9;
}

/* ================================
   FIX MODAL OVERLAY ISSUE (IMPORTANT)
   ================================ */

body {
    overflow: visible !important;
}

#app-shell,
.app-content {
    overflow: visible !important;
    transform: none !important;
}

/* Force modal to escape all stacking contexts */
.modal,
.fixed,
[wire\:ignore] {
    transform: none !important;
}

#app-shell {
    position: relative;
    /* NOTE: No z-index here — adding z-index would create a stacking context
       that traps modal dialogs behind the Bootstrap backdrop */
}

/* ================================
   BUTTONS & FORM ELEMENTS
   ================================ */
.btn-primary {
    background: #904d26 !important; /* Dark Copper */
    border-color: #904d26 !important;
    color: #fff !important;
}
.btn-primary:hover {
    background: #7a3f1f !important;
    border-color: #7a3f1f !important;
}

.btn-info {
    background: #051931 !important; /* Navy */
    border-color: #051931 !important;
    color: #fff !important;
}
.btn-info:hover {
    background: #0a2647 !important;
    border-color: #0a2647 !important;
}

.btn-outline-info {
    color: #904d26 !important;
    border-color: #904d26 !important;
}
.btn-outline-info:hover {
    background: #904d26 !important;
    color: #fff !important;
}

.btn-success {
    background: #904d26 !important; /* Dark Copper */
    border-color: #904d26 !important;
}
.btn-success:hover {
    background: #7a3f1f !important;
}

.badge.bg-primary {
    background: #904d26 !important; /* Dark Copper */
}

.badge.bg-info {
    background: #051931 !important; /* Navy */
}

/* Form controls */
.form-control:focus {
    border-color: #c38258; /* Light Copper */
    box-shadow: 0 0 0 0.2rem rgba(195, 130, 88, 0.25);
}

.form-select:focus {
    border-color: #c38258;
    box-shadow: 0 0 0 0.2rem rgba(195, 130, 88, 0.25);
}

/* Links */
a {
    color: #904d26; /* Dark Copper */
}
a:hover {
    color: #c38258; /* Light Copper */
}

/* Text colors */
.text-primary {
    color: #051931 !important; /* Navy */
}
.text-info {
    color: #904d26 !important; /* Dark Copper */
}
.text-muted {
    color: #697685 !important; /* Slate */
}