/**
 * PatrolIQ 2.0 Security Management Platform Stylesheet
 * Modern Command-and-Control Theme
 */

:root {
    --piq-navy: #0f172a;
    --piq-sidebar: #1e293b;
    --piq-card-bg: #ffffff;
    --piq-accent: #2563eb;
    --piq-accent-hover: #1d4ed8;
    --piq-success: #10b981;
    --piq-warning: #f59e0b;
    --piq-danger: #ef4444;
    --piq-critical: #dc2626;
    --piq-text-muted: #64748b;
    --piq-border: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    margin: 0;
    padding: 0;
}

/* Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 260px;
    background-color: var(--piq-sidebar);
    color: #f8fafc;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease-in-out;
}

.app-sidebar .brand-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo-badge {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.3);
}

.sidebar-nav {
    padding: 1rem 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    padding: 0.75rem 1.5rem 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover, .sidebar-link.active {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-left: 3px solid #3b82f6;
}

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

/* Expandable Dropdown Sidebar Styles */
.sidebar-menu-group {
    margin-bottom: 2px;
}

.sidebar-dropdown-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.sidebar-dropdown-toggle:hover,
.sidebar-menu-group.is-open > .sidebar-dropdown-toggle {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.sidebar-dropdown-toggle i:first-child {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}

.menu-chevron {
    font-size: 0.75rem;
    color: #64748b;
    transition: transform 0.25s ease, color 0.15s ease;
}

.sidebar-menu-group.is-open .menu-chevron {
    transform: rotate(90deg);
    color: #38bdf8;
}

.sidebar-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s cubic-bezier(0, 1, 0, 1);
    background: rgba(15, 23, 42, 0.4);
}

.sidebar-menu-group.is-open > .sidebar-submenu {
    max-height: 600px;
    transition: max-height 0.3s ease-in-out;
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 1.25rem 0.45rem 2.6rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, padding-left 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-sublink:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.04);
    padding-left: 2.85rem;
}

.sidebar-sublink.active {
    color: #ffffff;
    background: rgba(37, 99, 235, 0.18);
    border-left: 3px solid #3b82f6;
    font-weight: 600;
}

.sidebar-sublink .dot-indicator {
    font-size: 0.38rem;
    color: #475569;
    transition: color 0.15s;
}

.sidebar-sublink:hover .dot-indicator,
.sidebar-sublink.active .dot-indicator {
    color: #38bdf8;
}

.sidebar-action-badge {
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 12px;
}

.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-navbar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--piq-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-content {
    padding: 1.75rem;
    flex-grow: 1;
}

/* Card metrics */
a.kpi-link {
    text-decoration: none !important;
    color: inherit !important;
    display: block;
}

.kpi-card {
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}

.kpi-card:hover, a.kpi-link:hover .kpi-card {
    transform: translateY(-3px);
    border-color: #0d6efd;
    box-shadow: 0 8px 16px -2px rgba(13, 110, 253, 0.12), 0 3px 6px -2px rgba(0, 0, 0, 0.06);
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.clickable-row:hover {
    background-color: rgba(13, 110, 253, 0.05) !important;
}

.kpi-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Operating profile pill */
.profile-pill {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.profile-pill.mining_industrial {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.profile-pill.residential {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.profile-pill.small_business {
    background-color: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Status Badges */
.badge-status-on_duty, .badge-status-active, .badge-status-online {
    background-color: #dcfce7;
    color: #166534;
}

.badge-status-off_duty, .badge-status-offline {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-status-warning, .badge-status-investigating {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-status-critical, .badge-status-triggered {
    background-color: #ef4444;
    color: #ffffff;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Mobile Guard Interface */
.guard-app-shell {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: #ffffff;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.guard-topbar {
    background-color: #0f172a;
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.guard-action-btn {
    border-radius: 12px;
    padding: 1.2rem;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    transition: transform 0.1s;
}

.guard-action-btn:active {
    transform: scale(0.98);
}

.btn-sos-panic {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: white;
    border: 3px solid #fca5a5;
    animation: sosGlow 2s infinite;
}

@keyframes sosGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 25px rgba(239, 68, 68, 0.8); }
}

/* Maps */
@media (max-width: 575.98px) {
    .app-navbar { padding: .75rem; gap: .5rem; flex-wrap: wrap; }
    .app-navbar > .gap-3 { gap: .5rem !important; }
    .app-navbar .profile-pill > span, .app-navbar .piq-account-role { display: none; }
    .app-navbar .piq-account-name { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .app-navbar #headerAlertText { display: none; }
    .app-content { padding: 1rem .5rem; }
}
.leaflet-map-container {
    height: 480px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--piq-border);
}

/* Responsive */
@media (max-width: 992px) {
    .app-sidebar {
        margin-left: -260px;
        position: fixed;
        z-index: 1050;
        height: 100vh;
    }
    .app-sidebar.show {
        margin-left: 0;
    }
}
