/*
 * ATM Error Bot Admin - Light Theme
 * Mobile First & High Performance
 */

:root {
    /* Base Colors (Clean Light) */
    --bg-body: #f5f7fa;
    --bg-card: #ffffff;
    --bg-hover: #f0f2f5;
    --bg-input: #ffffff;

    /* Borders */
    --border-color: #e1e4e8;
    --border-light: rgba(0, 0, 0, 0.08);

    /* Text */
    --text-primary: #24292e;
    --text-secondary: #586069;
    --text-muted: #6a737d;

    /* Accents */
    --color-primary: #0d6efd;
    --color-success: #198754;
    --color-warning: #fd7e14;
    --color-danger: #dc3545;
    --color-info: #0dcaf0;

    /* Bootstrap overrides */
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-primary);
    --bs-card-bg: var(--bg-card);
    --bs-border-color: var(--border-color);
}

/* ============================================
   1. GLOBAL & TYPOGRAPHY
   ============================================ */

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 600;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
    color: #d63384;
    background-color: rgba(0, 0, 0, 0.04);
    padding: 0.1em 0.3em;
    border-radius: 3px;
}

/* ============================================
   2. LAYOUT & SIDEBAR
   ============================================ */

.sidebar {
    background-color: #212529;
    min-height: 100vh;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, .8);
    padding: 1rem 1.5rem;
    border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, .1);
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, .1);
    border-left-color: var(--color-primary);
}

.sidebar .nav-link i {
    margin-right: 10px;
}

.brand-title {
    padding: 1.5rem;
    color: #fff;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.user-info {
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, .6);
    font-size: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.main-content {
    padding: 2rem;
}

/* ============================================
   3. CARDS
   ============================================ */

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

/* Stat Cards */
.stat-card {
    border-left: 4px solid;
}

.stat-card.primary {
    border-left-color: var(--color-primary);
}

.stat-card.success {
    border-left-color: var(--color-success);
}

.stat-card.warning {
    border-left-color: var(--color-warning);
}

.stat-card.danger {
    border-left-color: var(--color-danger);
}

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

/* ============================================
   4. TABLES
   ============================================ */

.table {
    color: var(--text-primary);
    margin-bottom: 0;
}

.table> :not(caption)>*>* {
    background-color: transparent;
    border-bottom-color: var(--border-color);
    padding: 0.75rem 1rem;
}

.table thead th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: var(--bg-body);
}

.table-hover tbody tr:hover {
    background-color: var(--bg-hover);
}

/* Column widths */
.col-code {
    width: 120px;
}

.col-model {
    width: 100px;
}

.col-actions {
    width: 100px;
}

/* ============================================
   5. MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 767.98px) {

    /* Stacked Tables (Card View) */
    .table-responsive table,
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive th,
    .table-responsive td,
    .table-responsive tr {
        display: block;
    }

    .table-responsive thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .table-responsive tr {
        border: 1px solid var(--border-color);
        margin-bottom: 1rem;
        background-color: var(--bg-card);
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    }

    .table-responsive td {
        border: none;
        border-bottom: 1px solid var(--border-color);
        position: relative;
        padding-left: 50%;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
        text-align: right;
    }

    .table-responsive td:last-child {
        border-bottom: none;
    }

    .table-responsive td:before {
        position: absolute;
        top: 0.75rem;
        left: 1rem;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--text-secondary);
        content: attr(data-label);
    }

    /* Navigation */
    .sidebar {
        width: 280px;
        min-height: 100vh;
    }

    .sidebar .offcanvas-header {
        background-color: #212529;
        border-bottom: 1px solid rgba(255, 255, 255, .1);
        padding: 1rem 1.5rem;
    }

    .main-content {
        padding: 1rem;
        padding-top: 4rem;
    }

    .stat-card {
        margin-bottom: 1rem;
    }

    .table-responsive {
        font-size: 0.85rem;
    }

    .main-content h1.h2 {
        font-size: 1.5rem;
    }
}

/* Sidebar toggle button */
.sidebar-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1060;
    background: #212529;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle:hover {
    background: #343a40;
}

.brand-title-mobile {
    color: #fff;
    font-size: 1.1rem;
}

.sidebar.offcanvas-md {
    background-color: #212529 !important;
}

.sidebar .offcanvas-body {
    background-color: #212529;
}

@media (min-width: 768px) {
    .sidebar-toggle {
        display: none !important;
    }

    .sidebar.offcanvas-md {
        min-height: 100vh;
    }

    .sidebar .offcanvas-body {
        padding: 0;
    }
}

/* ============================================
   6. FORMS & BUTTONS
   ============================================ */

.form-control,
.form-select {
    border-color: var(--border-color);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

/* Filter card */
.filter-card .card-body {
    padding: 1rem;
}

/* ============================================
   7. EMPTY STATES & UTILITIES
   ============================================ */

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.avatar-placeholder {
    width: 24px;
    height: 24px;
    background-color: #e9ecef;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #6c757d;
}

/* Pagination */
.pagination-wrapper {
    padding: 1rem;
}

.pagination-wrapper .pagination {
    margin-bottom: 0;
}

/* ============================================
   8. TIMELINE
   ============================================ */

.timeline-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.timeline-chart {
    height: 120px;
    position: relative;
    background: linear-gradient(to bottom, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-top: 10px;
}

.timeline-axis {
    position: absolute;
    bottom: 30px;
    left: 30px;
    right: 30px;
    height: 2px;
    background: #adb5bd;
}

.timeline-item {
    position: absolute;
    transform: translateX(-50%);
    bottom: 35px;
    cursor: pointer;
    z-index: 10;
}

.timeline-item:hover {
    transform: translateX(-50%) scale(1.1);
    z-index: 20;
}

.timeline-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.timeline-cluster {
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    padding: 0 6px;
}

.color-critical {
    background: #dc3545;
}

.color-warning {
    background: #fd7e14;
}

.color-info {
    background: #0dcaf0;
}

.color-success {
    background: #198754;
}

.timeline-tooltip {
    position: absolute;
    bottom: 100%;
    background: #343a40;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.timeline-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #343a40;
}

.timeline-item:hover .timeline-tooltip {
    opacity: 1;
}

.timeline-tick {
    position: absolute;
    bottom: 10px;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-muted);
}

.timeline-point {
    position: absolute;
    transform: translateX(-50%);
    text-align: center;
    cursor: pointer;
}

.timeline-point:hover {
    transform: translateX(-50%) scale(1.2);
    z-index: 10;
}

.error-row {
    transition: background-color 0.3s;
}

.error-row.highlighted {
    background-color: #fff3cd !important;
}

/* ============================================
   9. LOG VIEWER
   ============================================ */

.log-viewer {
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.log-info {
    color: #0dcaf0;
}

.log-warning {
    color: #ffc107;
}

.log-error {
    color: #dc3545;
}

.log-debug {
    color: #6c757d;
}

/* ============================================
   10. LOGIN PAGE
   ============================================ */

.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    max-width: 400px;
    width: 100%;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-header {
    background: #212529;
    color: #fff;
    padding: 2rem;
    text-align: center;
    border-radius: 10px 10px 0 0;
}

.login-header i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.login-body {
    padding: 2rem;
}

.login-page .form-control:focus {
    border-color: #212529;
    box-shadow: 0 0 0 0.25rem rgba(33, 37, 41, 0.25);
}

.btn-login {
    background: #212529;
    border: none;
    padding: 0.75rem;
    width: 100%;
}

.btn-login:hover {
    background: #343a40;
}