/* =========================================================
   WHEEL SLIDE PROTECTION SYSTEM (WSPS) - CORE STYLESHEET
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --wsps-primary: #0B4F8A;
    --wsps-primary-hover: #083c6b;
    --wsps-secondary: #2F6DA6;
    --wsps-secondary-light: #e6f0fa;
    --wsps-success: #198754;
    --wsps-success-bg: #d1e7dd;
    --wsps-success-text: #0f5132;
    --wsps-warning: #FFC107;
    --wsps-warning-bg: #fff3cd;
    --wsps-warning-text: #664d03;
    --wsps-danger: #DC3545;
    --wsps-danger-bg: #f8d7da;
    --wsps-danger-text: #842029;
    --wsps-bg: #F4F6F9;
    --wsps-card-bg: #ffffff;
    --wsps-border: #E2E8F0;
    --wsps-text-main: #1E293B;
    --wsps-text-muted: #64748B;
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 56px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    padding-top: var(--navbar-height);
    overflow-x: hidden;
    background-color: var(--wsps-bg);
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--wsps-text-main);
    letter-spacing: -0.01em;
}

/* =========================================================
   NAVBAR (TOP BAR)
   ========================================================= */
.navbar-custom {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 999;
    height: var(--navbar-height);
    background: var(--wsps-primary);
    border-bottom: 2px solid var(--wsps-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: left 0.3s ease;
}

body.sidebar-collapsed .navbar-custom {
    left: var(--sidebar-collapsed-width);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-brand {
    color: #fff !important;
    text-decoration: none;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.05em;
}

.navbar-brand img.logo {
    height: 32px;
    filter: brightness(0) invert(1);
}

.toggle-sidebar-btn {
    width: 36px;
    height: 36px;
    border: none;
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.2s;
}

.toggle-sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
    color: #fff;
}

.system-time-ticker {
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.user-profile i {
    font-size: 16px;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-details strong {
    font-size: 12px;
}

.user-details small {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
}

/* =========================================================
   SIDEBAR
   ========================================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 998;
    width: var(--sidebar-width);
    height: 100vh;
    background: #1E293B; /* Modern Slate color */
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logo {
    min-height: 86px;
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    gap: 12px;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--wsps-primary), var(--wsps-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.sidebar-logo-text strong {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #F8FAFC;
}

.sidebar-logo-text small {
    font-size: 9.5px;
    font-weight: 600;
    color: #94A3B8;
}

.sidebar-menu {
    flex: 1;
    margin: 0;
    padding: 15px 12px;
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu li a {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    border-radius: 6px;
    text-decoration: none;
    color: #94A3B8;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-menu li a i {
    font-size: 15px;
    width: 20px;
    text-align: center;
}

.sidebar-menu li a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #F8FAFC;
}

.sidebar-menu li a.active {
    background: var(--wsps-primary);
    color: #ffffff;
    font-weight: 600;
}

/* Collapsed Sidebar overrides */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .sidebar-menu li a span {
    display: none;
}

body.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    padding: 15px 0;
}

body.sidebar-collapsed .sidebar-menu {
    padding: 15px 8px;
}

body.sidebar-collapsed .sidebar-menu li a {
    justify-content: center;
    padding: 0;
    gap: 0;
}

body.sidebar-collapsed .sidebar-menu li a i {
    font-size: 18px;
}

/* =========================================================
   MAIN CONTENT AREA
   ========================================================= */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: all 0.3s ease;
    min-height: calc(100vh - var(--navbar-height) - 60px);
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* =========================================================
   PAGE HEADER & BREADCRUMBS
   ========================================================= */
.page-header {
    background: var(--wsps-card-bg);
    border: 1px solid var(--wsps-border);
    border-left: 4px solid var(--wsps-primary);
    border-radius: 6px;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.page-header-title-area h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--wsps-primary);
}

.breadcrumb {
    margin: 4px 0 0 0;
    padding: 0;
    background: transparent;
    font-size: 11px;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: " / ";
    color: var(--wsps-text-muted);
}

.breadcrumb-item a {
    color: var(--wsps-secondary);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--wsps-text-muted);
}

.page-header-actions {
    display: flex;
    gap: 8px;
}

/* =========================================================
   CARDS & WIDGETS
   ========================================================= */
.content-card {
    background: var(--wsps-card-bg);
    border: 1px solid var(--wsps-border);
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.content-card .card-header {
    background: #FAFBFD;
    border-bottom: 1px solid var(--wsps-border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-card .card-header h5 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--wsps-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.content-card .card-body {
    padding: 16px;
}

/* =========================================================
   STATS GRID (HIGH DENSITY)
   ========================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--wsps-card-bg);
    border: 1px solid var(--wsps-border);
    border-top: 3px solid var(--wsps-primary);
    border-radius: 6px;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.stat-card.success { border-top-color: var(--wsps-success); }
.stat-card.warning { border-top-color: var(--wsps-warning); }
.stat-card.danger { border-top-color: var(--wsps-danger); }
.stat-card.secondary { border-top-color: var(--wsps-secondary); }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--wsps-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--wsps-text-main);
    line-height: 1.1;
}

.stat-desc {
    font-size: 10px;
    color: var(--wsps-text-muted);
    margin-top: 4px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--wsps-secondary-light);
    color: var(--wsps-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-card.success .stat-icon { background: #d1e7dd; color: #198754; }
.stat-card.warning .stat-icon { background: #fff3cd; color: #ffc107; }
.stat-card.danger .stat-icon { background: #f8d7da; color: #dc3545; }

/* =========================================================
   TABLES (DATA-DENSE & CLEAN)
   ========================================================= */
.table-responsive-custom {
    overflow-x: auto;
    border: 1px solid var(--wsps-border);
    border-radius: 6px;
}

.table-custom {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
    margin-bottom: 0;
    background: #fff;
}

.table-custom thead th {
    background: #F1F5F9;
    color: #334155;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--wsps-border);
    border-right: 1px solid var(--wsps-border);
    padding: 10px 12px;
    text-align: left;
}

.table-custom thead th:last-child {
    border-right: none;
}

.table-custom tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--wsps-border);
    border-right: 1px solid var(--wsps-border);
    color: var(--wsps-text-main);
    vertical-align: middle;
}

.table-custom tbody td:last-child {
    border-right: none;
}

.table-custom tbody tr:last-child td {
    border-bottom: none;
}

.table-custom tbody tr:hover {
    background-color: #F8FAFC;
}

.table-custom tbody tr.table-row-alert {
    background-color: rgba(220, 53, 69, 0.03);
}

.table-custom tbody tr.table-row-alert:hover {
    background-color: rgba(220, 53, 69, 0.06);
}

/* =========================================================
   BADGES & LABELS
   ========================================================= */
.badge-custom {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

.badge-success { background-color: var(--wsps-success-bg); color: var(--wsps-success-text); }
.badge-warning { background-color: var(--wsps-warning-bg); color: var(--wsps-warning-text); }
.badge-danger { background-color: var(--wsps-danger-bg); color: var(--wsps-danger-text); }
.badge-primary { background-color: var(--wsps-secondary-light); color: var(--wsps-primary); }
.badge-secondary { background-color: #E2E8F0; color: #475569; }

/* =========================================================
   FORM CONTROLS (COMPACT)
   ========================================================= */
.form-group-custom {
    margin-bottom: 12px;
}

.form-label-custom {
    font-size: 11px;
    font-weight: 700;
    color: var(--wsps-text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.form-control-custom {
    height: 32px;
    font-size: 12px;
    border: 1px solid var(--wsps-border);
    border-radius: 4px;
    padding: 0 10px;
    color: var(--wsps-text-main);
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.form-control-custom:focus {
    border-color: var(--wsps-secondary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(47, 109, 166, 0.15);
}

select.form-control-custom {
    padding-right: 20px;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 10px;
    appearance: none;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn-wsps {
    height: 32px;
    padding: 0 12px;
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.btn-wsps-primary {
    background-color: var(--wsps-primary);
    color: #fff;
    border-color: var(--wsps-primary);
}

.btn-wsps-primary:hover {
    background-color: var(--wsps-primary-hover);
    border-color: var(--wsps-primary-hover);
}

.btn-wsps-secondary {
    background-color: #fff;
    color: var(--wsps-text-main);
    border-color: var(--wsps-border);
}

.btn-wsps-secondary:hover {
    background-color: #F8FAFC;
    border-color: #CBD5E1;
}

.btn-wsps-success {
    background-color: var(--wsps-success);
    color: #fff;
    border-color: var(--wsps-success);
}

.btn-wsps-success:hover {
    background-color: #146c43;
    border-color: #146c43;
}

.btn-wsps-danger {
    background-color: var(--wsps-danger);
    color: #fff;
    border-color: var(--wsps-danger);
}

.btn-wsps-danger:hover {
    background-color: #b02a37;
    border-color: #b02a37;
}

.btn-wsps-xs {
    height: 24px;
    padding: 0 6px;
    font-size: 10px;
    border-radius: 3px;
}

/* =========================================================
   PAGINATION
   ========================================================= */
.pagination-custom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    font-size: 11.5px;
    color: var(--wsps-text-muted);
}

.pagination-buttons {
    display: flex;
    gap: 4px;
}

.pagination-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--wsps-border);
    border-radius: 4px;
    background: #fff;
    color: var(--wsps-text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 500;
}

.pagination-btn:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
}

.pagination-btn.active {
    background: var(--wsps-primary);
    color: #fff;
    border-color: var(--wsps-primary);
}

.pagination-btn.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* =========================================================
   VISUAL AXLE GRID (COACH & MONITORING DETAIL)
   ========================================================= */
.axle-layout {
    border: 2px solid #CBD5E1;
    border-radius: 8px;
    background: #F8FAFC;
    padding: 15px;
    margin: 10px 0;
    position: relative;
}

.axle-shaft {
    height: 6px;
    background: #94A3B8;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    margin: 0 40px;
}

.wheel-node {
    width: 36px;
    height: 54px;
    background: #475569;
    border-radius: 4px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
}

.wheel-left { left: 10px; }
.wheel-right { right: 10px; }

.axle-layout.slide-active .wheel-node {
    background: var(--wsps-danger);
    animation: pulse-danger 1.5s infinite;
}

.axle-layout.warning-active .wheel-node {
    background: var(--wsps-warning);
    color: #000;
}

@keyframes pulse-danger {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* =========================================================
   REAL TIME MONITORING GRAPHICAL VIEW
   ========================================================= */
.monitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.monitor-card {
    background: #fff;
    border: 1px solid var(--wsps-border);
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.monitor-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--wsps-border);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.monitor-card-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--wsps-primary);
}

.monitor-wheels-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.monitor-wheel-indicator {
    background: #F8FAFC;
    border: 1px solid var(--wsps-border);
    border-radius: 4px;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.monitor-wheel-indicator.sliding {
    background: var(--wsps-danger-bg);
    border-color: var(--wsps-danger);
    color: var(--wsps-danger-text);
}

.monitor-wheel-indicator.sliding .wheel-icon {
    color: var(--wsps-danger);
    animation: rotate-slip 0.5s linear infinite;
}

.wheel-icon {
    font-size: 16px;
    color: var(--wsps-text-muted);
}

/* =========================================================
   FOOTER (APP FOOTER)
   ========================================================= */
.app-footer {
    margin-left: var(--sidebar-width);
    padding: 15px 20px;
    transition: all 0.3s ease;
    border-top: 1px solid var(--wsps-border);
    background: var(--wsps-card-bg);
}

body.sidebar-collapsed .app-footer {
    margin-left: var(--sidebar-collapsed-width);
}

.app-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--wsps-text-muted);
}

.system-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--wsps-success);
}

.status-dot.pulse {
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0% { transform: scale(0.9); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.5; }
    100% { transform: scale(0.9); opacity: 1; }
}

/* =========================================================
   RESPONSIVE OVERRIDES
   ========================================================= */
@media (max-width: 1400px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .navbar-custom {
        left: 0 !important;
    }
    .sidebar {
        left: -var(--sidebar-width);
        top: var(--navbar-height);
        height: calc(100vh - var(--navbar-height));
    }
    body.sidebar-collapsed .sidebar {
        left: 0;
        width: var(--sidebar-width);
    }
    body.sidebar-collapsed .sidebar-logo-text,
    body.sidebar-collapsed .sidebar-menu li a span {
        display: block;
    }
    body.sidebar-collapsed .sidebar-menu li a {
        justify-content: flex-start;
        padding: 0 14px;
        gap: 12px;
    }
    .main-content, .app-footer {
        margin-left: 0 !important;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}
