/**
 * Index Patrol — Portal design system
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --ip-primary: #1d4ed8;
    --ip-primary-dark: #1e3a8a;
    --ip-primary-light: #3b82f6;
    --ip-accent: #0ea5e9;
    --ip-success: #059669;
    --ip-warning: #d97706;
    --ip-danger: #dc2626;
    --ip-sidebar: #0f172a;
    --ip-sidebar-hover: #1e293b;
    --ip-sidebar-active: rgba(59, 130, 246, 0.18);
    --ip-bg: #f1f5f9;
    --ip-surface: #ffffff;
    --ip-border: #e2e8f0;
    --ip-text: #0f172a;
    --ip-text-muted: #64748b;
    --ip-radius: 12px;
    --ip-radius-sm: 8px;
    --ip-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
    --ip-shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.08);
    --ip-sidebar-width: 260px;
    --ip-header-height: 64px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.9375rem;
    color: var(--ip-text);
    background: var(--ip-bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* ── Loader ── */
.loader-bg {
    position: fixed;
    inset: 0;
    background: var(--ip-surface);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loader-track {
    width: 120px;
    height: 3px;
    background: var(--ip-border);
    border-radius: 3px;
    overflow: hidden;
}
.loader-fill {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--ip-primary), var(--ip-accent));
    border-radius: 3px;
    animation: ip-loader 1s ease-in-out infinite;
}
@keyframes ip-loader {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ── Sidebar ── */
.pcoded-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--ip-sidebar-width);
    height: 100vh;
    background: var(--ip-sidebar);
    z-index: 1029;
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}
.pcoded-navbar .navbar-brand.header-logo {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 72px;
}
.pcoded-navbar .navbar-brand .mobile-menu {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}
.pcoded-navbar .b-brand.sidebar-brand-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}
.pcoded-navbar .b-brand .logo-product {
    max-height: 52px;
    max-width: 100%;
    width: auto;
    flex-shrink: 0;
    border-radius: 6px;
    object-fit: contain;
}
.pcoded-navbar .b-brand .logo-tenant {
    max-height: 40px;
    width: auto;
    max-width: calc(100% - 120px);
    object-fit: contain;
    flex-shrink: 1;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 6px;
    padding: 4px 8px;
}
.pcoded-navbar .navbar-content {
    height: calc(100vh - 72px);
    overflow-y: auto;
    padding: 0.5rem 0 2rem;
}
.pcoded-navbar .navbar-content::-webkit-scrollbar { width: 4px; }
.pcoded-navbar .navbar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.pcoded-inner-navbar { list-style: none; padding: 0; margin: 0; }
.pcoded-menu-caption {
    padding: 1.25rem 1.25rem 0.35rem;
}
.pcoded-menu-caption label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.9);
    margin: 0;
}
.pcoded-inner-navbar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1.25rem;
    margin: 2px 0.75rem;
    border-radius: var(--ip-radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
}
.pcoded-inner-navbar .nav-link:hover {
    background: var(--ip-sidebar-hover);
    color: #f8fafc;
    text-decoration: none;
}
.pcoded-inner-navbar .nav-link.active {
    background: var(--ip-sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--ip-primary-light);
}
.pcoded-micon {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.9;
}
.pcoded-mtext { flex: 1; }

.mobile-menu {
    display: none;
    width: 36px;
    height: 36px;
    position: relative;
    cursor: pointer;
}
.mobile-menu span,
.mobile-menu span::before,
.mobile-menu span::after {
    display: block;
    width: 20px;
    height: 2px;
    background: #94a3b8;
    position: absolute;
    left: 8px;
    top: 17px;
    transition: 0.2s;
}
.mobile-menu span::before,
.mobile-menu span::after { content: ''; }
.mobile-menu span::before { top: -6px; }
.mobile-menu span::after { top: 6px; }

/* ── Header ── */
.pcoded-header {
    position: fixed;
    top: 0;
    left: var(--ip-sidebar-width);
    right: 0;
    height: var(--ip-header-height);
    background: var(--ip-surface);
    border-bottom: 1px solid var(--ip-border);
    z-index: 1028;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}
.pcoded-header .navbar-nav { list-style: none; padding: 0; margin: 0; display: flex; }
.pcoded-header .btn-outline-danger {
    border-radius: var(--ip-radius-sm);
    font-weight: 500;
    font-size: 0.8125rem;
}

/* ── Main layout ── */
.pcoded-main-container {
    margin-left: var(--ip-sidebar-width);
    margin-top: var(--ip-header-height);
    min-height: calc(100vh - var(--ip-header-height));
    padding: 1.75rem 1.5rem 2.5rem;
}
.page-wrapper { max-width: 1400px; margin: 0 auto; }
.page-header { margin-bottom: 1.5rem; }
.page-header h5 {
    font-weight: 700;
    font-size: 1.375rem;
    color: var(--ip-text);
    margin-bottom: 0.25rem;
}
.page-header .text-muted { font-size: 0.875rem; }

/* ── Cards ── */
.card {
    border: 1px solid var(--ip-border);
    border-radius: var(--ip-radius);
    box-shadow: var(--ip-shadow);
    background: var(--ip-surface);
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.card-header {
    background: var(--ip-surface);
    border-bottom: 1px solid var(--ip-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}
.card-header h5, .card-header h6 { margin: 0; font-weight: 600; font-size: 0.9375rem; }
.card-body { padding: 1.25rem; }

/* ── Dashboard KPI cards ── */
.order-card {
    border: none;
    border-radius: var(--ip-radius);
    overflow: hidden;
    position: relative;
    box-shadow: var(--ip-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.order-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ip-shadow-lg);
}
.order-card .card-body { padding: 1.35rem 1.25rem; position: relative; z-index: 1; }
.order-card h6 { font-size: 0.8125rem; font-weight: 500; opacity: 0.92; margin-bottom: 0.35rem; }
.order-card h2 { font-size: 2rem; font-weight: 700; margin: 0; }
.order-card .card-icon {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    font-size: 3rem;
    opacity: 0.15;
}
.bg-c-blue { background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%); }
.bg-c-green { background: linear-gradient(135deg, #047857 0%, #10b981 100%); }
.bg-c-yellow { background: linear-gradient(135deg, #b45309 0%, #f59e0b 100%); }
.bg-c-red { background: linear-gradient(135deg, #b91c1c 0%, #ef4444 100%); }

/* ── Tables ── */
.table { font-size: 0.875rem; }
.table thead th {
    border-top: none;
    border-bottom: 2px solid var(--ip-border);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ip-text-muted);
    padding: 0.75rem 1rem;
}
.table td { padding: 0.85rem 1rem; vertical-align: middle; border-color: var(--ip-border); }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ── Forms & buttons ── */
.form-control {
    border-radius: var(--ip-radius-sm);
    border-color: var(--ip-border);
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    border-color: var(--ip-primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
label { font-weight: 500; font-size: 0.8125rem; color: var(--ip-text-muted); margin-bottom: 0.35rem; }
.btn {
    border-radius: var(--ip-radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    transition: all 0.15s;
}
.btn-primary {
    background: var(--ip-primary);
    border-color: var(--ip-primary);
}
.btn-primary:hover {
    background: var(--ip-primary-dark);
    border-color: var(--ip-primary-dark);
}
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8125rem; }

.badge {
    font-weight: 500;
    font-size: 0.6875rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

/* ── Alerts & messages ── */
.alert { border-radius: var(--ip-radius-sm); border: none; font-size: 0.875rem; }
.alert-danger { background: #fef2f2; color: #991b1b; }

/* ── Auth page (legacy — see portal-auth.css) ── */
/* ── Tenant selector ── */
.pcoded-navbar form.px-3 select {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    border-radius: var(--ip-radius-sm);
}
.pcoded-navbar form.px-3 label { color: #94a3b8; }

/* ── Messages toast area ── */
.ip-messages {
    position: fixed;
    top: calc(var(--ip-header-height) + 12px);
    right: 1.5rem;
    z-index: 1030;
    max-width: 420px;
    width: calc(100% - 2rem);
}
.ip-messages .alert {
    box-shadow: var(--ip-shadow-lg);
    margin-bottom: 0.5rem;
}
.font-weight-500 { font-weight: 500 !important; }

/* ── Mobile ── */
@media (max-width: 991px) {
    .pcoded-navbar { transform: translateX(-100%); }
    .pcoded-navbar.mob-open { transform: translateX(0); }
    .pcoded-main-container,
    .pcoded-header { margin-left: 0; left: 0; }
    .mobile-menu { display: block; }
    .pcoded-header .mobile-menu span,
    .pcoded-header .mobile-menu span::before,
    .pcoded-header .mobile-menu span::after { background: var(--ip-text-muted); }
    .ip-messages { right: 1rem; left: 1rem; max-width: none; width: auto; }
}
