/* =============================================
   Interparking LPR Dashboard - Main Stylesheet
   ============================================= */

:root {
    --ip-blue:       #1B4880;
    --ip-blue-dark:  #143761;
    --ip-blue-light: #2560A4;
    --ip-blue-pale:  #EBF0F8;
    --ip-yellow:     #F6A800;
    --ip-yellow-dark:#D98F00;
    --ip-yellow-pale:#FFF8E6;
    --bg:            #F0F3F8;
    --sidebar-width: 240px;
    --card-radius:   12px;
    --shadow:        0 2px 8px rgba(27, 72, 128, 0.10);
    --shadow-hover:  0 4px 16px rgba(27, 72, 128, 0.18);
}

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

body {
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #1a2a3a;
    margin: 0;
    padding: 0;
}

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

/* ── Sidebar ────────────────────────────────────────────────────── */
.ip-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--ip-blue);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease, transform 0.25s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.ip-sidebar::-webkit-scrollbar { width: 4px; }
.ip-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
    text-decoration: none;
}

.sidebar-logo-img {
    max-height: 52px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* Nav area */
.sidebar-nav {
    flex: 1;
    padding: 10px 0 6px;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.35);
    padding: 14px 16px 5px;
}

/* Nav link */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: rgba(255,255,255,0.78);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    cursor: pointer;
    position: relative;
}

.sidebar-link i:first-child {
    font-size: 15px;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.sidebar-link:hover {
    color: var(--ip-yellow);
    background: rgba(246,168,0,0.07);
    border-left-color: rgba(246,168,0,0.4);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--ip-yellow);
    background: rgba(246,168,0,0.10);
    border-left-color: var(--ip-yellow);
    font-weight: 600;
}

/* Collapse toggle chevron */
.sidebar-chevron {
    font-size: 11px;
    transition: transform 0.2s;
    color: rgba(255,255,255,0.4);
    margin-left: auto;
}

.sidebar-chevron.rotated { transform: rotate(-180deg); }

/* Submenu */
.sidebar-submenu {
    padding: 2px 0 4px;
    background: rgba(0,0,0,0.12);
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px 7px 42px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 12.5px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-sublink:hover {
    color: var(--ip-yellow);
    background: rgba(246,168,0,0.07);
    border-left-color: rgba(246,168,0,0.3);
    text-decoration: none;
}

.sidebar-sublink.active {
    color: var(--ip-yellow);
    border-left-color: var(--ip-yellow);
    font-weight: 600;
}

/* Error badge in sidebar */
.sidebar-badge {
    background: #dc3545;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 20px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
    margin-left: auto;
    line-height: 16px;
}

/* User section */
.sidebar-user {
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 12px 14px;
    background: rgba(0,0,0,0.12);
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: rgba(246,168,0,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ip-yellow);
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

.sidebar-user-actions {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-user-link {
    display: block;
    color: rgba(255,255,255,0.55);
    font-size: 12px;
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 5px;
    transition: all 0.15s;
    background: none;
    border: none;
    cursor: pointer;
}

.sidebar-user-link:hover {
    color: var(--ip-yellow);
    background: rgba(246,168,0,0.08);
}

/* ── Main content ───────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    transition: margin-left 0.25s ease;
}

/* ── Sidebar colapsado (desktop) ────────────────────────────────── */
.ip-sidebar.collapsed {
    width: 56px;
    min-width: 56px;
}
.main-content.sidebar-collapsed {
    margin-left: 56px;
}
.ip-sidebar.collapsed .sidebar-section-label { display: none; }
.ip-sidebar.collapsed .sidebar-link span,
.ip-sidebar.collapsed .sidebar-link .sidebar-chevron,
.ip-sidebar.collapsed .sidebar-badge { display: none !important; }
.ip-sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 10px 0;
    border-radius: 0;
}
.ip-sidebar.collapsed .sidebar-link i:first-child { margin: 0; font-size: 18px; }
.ip-sidebar.collapsed #blacklistsMenu { display: none !important; }
.ip-sidebar.collapsed .sidebar-user { display: none; }
.ip-sidebar.collapsed .sidebar-logo-img { display: none; }
.ip-sidebar.collapsed .sidebar-brand { justify-content: center; padding: 14px 0; }

/* Botón colapsar sidebar (visible solo en desktop) */
.sidebar-collapse-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    padding: 4px 6px;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.ip-sidebar.collapsed .sidebar-collapse-btn {
    margin: 0 auto;
}

/* ── Mobile topbar (hamburger) ──────────────────────────────────── */
.mobile-topbar {
    background: var(--ip-blue);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.mobile-topbar-title {
    color: #fff;
    font-weight: 700;
    font-size: 15px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1029;
}

.sidebar-overlay.active { display: block; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 991px) {
    .ip-sidebar {
        transform: translateX(-100%);
    }
    .ip-sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

/* ── Page header ────────────────────────────────────────────────── */
.ip-page-header .container-fluid {
    padding-right: 24px;
}

.ip-page-header {
    background: linear-gradient(135deg, var(--ip-blue) 0%, var(--ip-blue-light) 100%);
    color: white;
    padding: 20px 0;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(27, 72, 128, 0.2);
}

.ip-page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ip-page-header .breadcrumb {
    margin: 0;
    padding: 0;
    background: none;
    font-size: 12px;
    opacity: 0.75;
}

.ip-page-header .breadcrumb-item + .breadcrumb-item::before {
    color: rgba(255,255,255,0.5);
}

/* ── Stat Cards ─────────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.stat-accent { height: 4px; width: 100%; }
.stat-accent.blue   { background: var(--ip-blue); }
.stat-accent.yellow { background: var(--ip-yellow); }
.stat-accent.green  { background: #28a745; }
.stat-accent.red    { background: #dc3545; }
.stat-accent.purple { background: #5A4B8A; }
.stat-accent.teal   { background: #20c997; }

.stat-card-body {
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: var(--ip-blue-pale); color: var(--ip-blue); }
.stat-icon.yellow { background: var(--ip-yellow-pale); color: var(--ip-yellow-dark); }
.stat-icon.green  { background: #d4edda; color: #28a745; }
.stat-icon.red    { background: #f8d7da; color: #dc3545; }
.stat-icon.purple { background: #ede9f5; color: #5A4B8A; }
.stat-icon.teal   { background: #d2f4ea; color: #20c997; }

.stat-info  { flex: 1; min-width: 0; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--ip-blue-dark); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: #6c757d; }
.stat-sub   { font-size: 12px; color: #6c757d; margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
}

.card-header {
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 14px 20px;
}

.ip-card-header {
    background: #fff;
    border-bottom: 3px solid var(--ip-yellow);
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ip-card-header h5,
.ip-card-header h6 {
    color: var(--ip-blue);
    font-weight: 700;
    margin: 0;
    font-size: 15px;
}

.header-icon {
    width: 32px;
    height: 32px;
    background: var(--ip-blue-pale);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ip-blue);
    font-size: 16px;
    flex-shrink: 0;
}

.card-body { padding: 20px; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-responsive {
    border-radius: 0 0 var(--card-radius) var(--card-radius);
}

.ip-table { margin-bottom: 0; font-size: 13px; }

.ip-table thead th {
    background: var(--ip-blue);
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 12px 14px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.ip-table tbody tr {
    transition: background 0.12s;
    border-bottom: 1px solid #f0f3f8;
}

.ip-table tbody tr:hover { background: var(--ip-blue-pale) !important; }

.ip-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    border-color: #f0f3f8;
}

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

/* ── DataTables overrides ───────────────────────────────────────── */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 10px 16px 4px;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding: 6px 16px 12px;
}

div.dataTables_wrapper div.dataTables_length select {
    width: 40% !important;
    display: inline-block;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #d0d7e2;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--ip-blue-dark);
}

.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--ip-blue-light);
    box-shadow: 0 0 0 2px rgba(37,96,164,0.15);
}

.dataTables_wrapper .dataTables_info {
    font-size: 12px;
    color: #6c757d;
    padding-top: 10px;
}

.dataTables_wrapper .dataTables_paginate { padding-top: 8px; }

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    border: none !important;
    padding: 4px 10px !important;
    font-size: 13px;
    color: var(--ip-blue) !important;
    background: transparent !important;
    margin: 0 2px;
    transition: all 0.15s;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--ip-blue-pale) !important;
    color: var(--ip-blue) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--ip-blue) !important;
    color: #fff !important;
    font-weight: 600;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    color: #adb5bd !important;
    cursor: not-allowed;
}

/* ── Badges ─────────────────────────────────────────────────────── */
.badge-quercus     { background: var(--ip-blue); color: #fff; }
.badge-siram       { background: var(--ip-blue-light); color: #fff; }
.badge-lectorvision{ background: #5A4B8A; color: #fff; }
.badge-transit     { background: var(--ip-yellow); color: var(--ip-blue-dark); }

.badge-ok    { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.badge-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.badge-retry { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-ip {
    background: var(--ip-yellow);
    color: var(--ip-blue-dark);
    border: none;
    font-weight: 600;
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 13px;
    transition: all 0.18s;
    box-shadow: 0 2px 6px rgba(246,168,0,0.25);
}

.btn-ip:hover, .btn-ip:focus {
    background: var(--ip-yellow-dark);
    color: var(--ip-blue-dark);
    box-shadow: 0 4px 10px rgba(246,168,0,0.35);
    transform: translateY(-1px);
}

.btn-ip:active { transform: translateY(0); box-shadow: none; }

.btn-ip-outline {
    background: transparent;
    color: var(--ip-blue);
    border: 2px solid var(--ip-blue);
    font-weight: 600;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 13px;
    transition: all 0.18s;
}

.btn-ip-outline:hover, .btn-ip-outline:focus {
    background: var(--ip-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(27,72,128,0.2);
}

.btn-sm.btn-ip        { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-sm.btn-ip-outline{ padding: 3px 9px; font-size: 12px; border-radius: 6px; }

/* ── Filter form ────────────────────────────────────────────────── */
.filter-form {
    background: #fff;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.filter-form label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--ip-blue);
    margin-bottom: 4px;
}

.filter-form .form-control,
.filter-form .form-select {
    border-radius: 7px;
    border-color: #d0d7e2;
    font-size: 13px;
    color: #1a2a3a;
    padding: 7px 12px;
}

/* ── Forms ──────────────────────────────────────────────────────── */
.form-control, .form-select {
    border-radius: 7px;
    border-color: #d0d7e2;
    font-size: 13px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--ip-blue-light);
    box-shadow: 0 0 0 3px rgba(37,96,164,0.12);
}

.form-label {
    font-weight: 600;
    font-size: 13px;
    color: #2a3f5f;
    margin-bottom: 5px;
}

/* ── Alert banners ──────────────────────────────────────────────── */
.alert-devices-down {
    background: linear-gradient(90deg, #fff3cd 0%, #fff8e6 100%);
    border-left: 4px solid var(--ip-yellow);
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    color: #856404;
    margin-bottom: 20px;
}

.alert-danger-banner {
    background: linear-gradient(90deg, #f8d7da 0%, #fff5f5 100%);
    border-left: 4px solid #dc3545;
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    color: #721c24;
    margin-bottom: 20px;
}

/* ── Charts ─────────────────────────────────────────────────────── */
.chart-container {
    position: relative;
    min-height: 260px;
    padding: 10px;
}

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-header {
    background: var(--ip-blue);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header .btn-close { filter: invert(1); }

.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* ── Photo preview ──────────────────────────────────────────────── */
.photo-container {
    background: #f8f9fa;
    border: 2px dashed #d0d7e2;
    border-radius: 8px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.photo-container img {
    max-width: 100%;
    max-height: 280px;
    border-radius: 6px;
    object-fit: contain;
}

.photo-placeholder {
    color: #adb5bd;
    font-size: 13px;
    text-align: center;
}

/* ── Footer ─────────────────────────────────────────────────────── */
.ip-footer {
    background: var(--ip-blue-dark);
    color: rgba(255,255,255,0.6);
    text-align: center;
    padding: 14px 0;
    font-size: 12px;
    margin-top: auto;
}

.ip-footer strong { color: var(--ip-yellow); }

/* ── Misc ───────────────────────────────────────────────────────── */
.text-ip-blue   { color: var(--ip-blue) !important; }
.text-ip-yellow { color: var(--ip-yellow) !important; }
.bg-ip-blue     { background: var(--ip-blue) !important; }
.bg-ip-yellow   { background: var(--ip-yellow) !important; }
.bg-ip-pale     { background: var(--ip-blue-pale) !important; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
    display: block;
}

/* ── Toastr ─────────────────────────────────────────────────────── */
#toast-container > .toast {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* ── Device status ──────────────────────────────────────────────── */
.device-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.device-status-dot.ok    { background: #28a745; }
.device-status-dot.error { background: #dc3545; }
.device-status-dot.down  { background: #fd7e14; }

/* ── Pagination ─────────────────────────────────────────────────── */
.pagination .page-item.active .page-link {
    background-color: var(--ip-blue);
    border-color: var(--ip-blue);
    color: #fff;
}

.pagination .page-link {
    color: var(--ip-blue);
    border-radius: 6px;
    margin: 0 2px;
    font-size: 13px;
}

.pagination .page-link:hover {
    background: var(--ip-blue-pale);
    border-color: var(--ip-blue-pale);
    color: var(--ip-blue);
}

/* ── Loading overlay ────────────────────────────────────────────── */
.loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--card-radius);
    z-index: 10;
}

/* ── Responsive tweaks ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .ip-page-header h1 { font-size: 18px; }
    .stat-value { font-size: 22px; }
    .ip-table { font-size: 12px; }
    .ip-table td, .ip-table th { padding: 8px 10px; }
    .main-content { margin-left: 0; }
}
