/* Custom Variables */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 60px;
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --dark-color: #5a5c69;
    --sidebar-bg: #4e73df;
    --sidebar-dark-bg: #2e59d9;
}

/* Body */
body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fc;
    min-height: 100vh;
}

/* Wrapper */
#wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg) 10%, var(--sidebar-dark-bg) 100%);
    transition: width 0.3s ease-in-out;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    padding: 0;
    list-style: none;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-heading {
    display: none;
}

.sidebar.collapsed .nav-link {
    text-align: center;
    padding: 1rem;
}

.sidebar.collapsed .nav-link i {
    margin-right: 0;
    font-size: 1.2rem;
}

.sidebar-brand {
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    text-decoration: none;
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-brand-icon {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

hr.sidebar-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin: 0 1rem 1rem;
}

.sidebar-heading {
    padding: 0 1rem;
    font-weight: 800;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.13rem;
    margin-bottom: 0.5rem;
}

.sidebar .nav-item .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s ease-in-out;
}

.sidebar .nav-item .nav-link i {
    margin-right: 0.5rem;
    font-size: 0.85rem;
}

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

.sidebar .nav-item .nav-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.2);
}

.sidebar-toggle {
    width: 100%;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    background: transparent;
    border: none;
    cursor: pointer;
}

.sidebar-toggle:hover {
    color: #fff;
}

/* Content wrapper */
#content-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease-in-out;
}

#content-wrapper.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* Main Content */
#content {
    flex: 1;
    padding: 1.5rem;
}

/* Top Navbar */
.topbar {
    height: var(--navbar-height);
    background-color: #fff;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.topbar .navbar-search {
    width: 25rem;
}

.topbar .navbar-search .input-group {
    border-radius: 0.35rem;
    overflow: hidden;
}

.topbar .navbar-search input {
    font-size: 0.85rem;
    border: 0;
    background-color: #f8f9fc;
}

.topbar .navbar-search input:focus {
    background-color: #fff;
}

.topbar .navbar-search .btn {
    background-color: var(--primary-color);
    color: #fff;
    border: 0;
}

.topbar-divider {
    width: 0;
    border-right: 1px solid #e3e6f0;
    height: 2rem;
    margin: auto 1rem;
}

.topbar .nav-item .nav-link {
    color: var(--secondary-color);
    position: relative;
}

.topbar .nav-item .nav-link .badge-counter {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.25em 0.4em;
}

.topbar .nav-item .nav-link .img-profile {
    height: 2rem;
    width: 2rem;
}

.topbar .nav-item.dropdown .dropdown-menu {
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    border: 1px solid #e3e6f0;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
    margin-bottom: 1.5rem;
}

.card .card-header {
    background-color: #f8f9fc;
    border-bottom: 1px solid #e3e6f0;
    padding: 0.75rem 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.card .card-header[data-bs-toggle="collapse"] {
    cursor: pointer;
}

/* Border left utilities */
.border-left-primary { border-left: 0.25rem solid var(--primary-color) !important; }
.border-left-secondary { border-left: 0.25rem solid var(--secondary-color) !important; }
.border-left-success { border-left: 0.25rem solid var(--success-color) !important; }
.border-left-info { border-left: 0.25rem solid var(--info-color) !important; }
.border-left-warning { border-left: 0.25rem solid var(--warning-color) !important; }
.border-left-danger { border-left: 0.25rem solid var(--danger-color) !important; }

/* Stat Cards */
.stat-card .card-body {
    padding: 1.25rem;
}

.stat-card .stat-title {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-color);
}

.stat-card .stat-icon {
    font-size: 2rem;
    color: #dddfeb;
}

/* Tables */
.table thead th {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    color: var(--dark-color);
    border-bottom-width: 1px;
}

.table td, .table th {
    vertical-align: middle;
}

/* Status Badges */
.badge-status {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    font-weight: 600;
}

/* Action Types */
.action-type.speed { background-color: #36b9cc; color: #fff; }
.action-type.cancel { background-color: #e74a3b; color: #fff; }
.action-type.refill { background-color: #f6c23e; color: #212529; }
.action-type.partial { background-color: #6f42c1; color: #fff; }

/* Process Status */
.process-status.pending { background-color: #858796; color: #fff; }
.process-status.processing { background-color: #4e73df; color: #fff; }
.process-status.solved { background-color: #1cc88a; color: #fff; }
.process-status.rejected { background-color: #e74a3b; color: #fff; }

/* Provider Status */
.provider-status.active { background-color: #1cc88a; color: #fff; }
.provider-status.inactive { background-color: #e74a3b; color: #fff; }

/* Buttons */
.btn-icon-split {
    padding: 0;
    overflow: hidden;
    display: inline-flex;
    align-items: stretch;
}

.btn-icon-split .icon {
    background-color: rgba(0, 0, 0, 0.15);
    display: inline-block;
    padding: 0.375rem 0.75rem;
}

.btn-icon-split .text {
    display: inline-block;
    padding: 0.375rem 0.75rem;
}

/* Modal improvements */
.modal-header {
    background-color: var(--primary-color);
    color: #fff;
}

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

/* Footer */
.footer {
    background-color: #fff;
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    color: var(--secondary-color);
    border-top: 1px solid #e3e6f0;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 0.5rem;
    height: 0.5rem;
}

::-webkit-scrollbar-track {
    background-color: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
    border-radius: 0.25rem;
}

::-webkit-scrollbar-thumb:hover {
    background-color: #a1a1a1;
}

/* KPI Cards */
.kpi-card .card-body {
    padding: 1rem;
}

.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
}

.kpi-card .kpi-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}

.kpi-card .kpi-sub {
    font-size: 0.75rem;
    color: var(--secondary-color);
}

/* Provider ranking list */
.provider-rank-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e3e6f0;
}

.provider-rank-item:last-child {
    border-bottom: none;
}

.provider-rank-position {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.provider-rank-bar {
    height: 6px;
    border-radius: 3px;
    background-color: #e9ecef;
    flex: 1;
    overflow: hidden;
}

.provider-rank-bar .bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* Sidebar backdrop for mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-backdrop.show {
    display: block;
}

/* Responsive table wrapper */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .sidebar .sidebar-brand-text,
    .sidebar .nav-link span,
    .sidebar .sidebar-heading {
        display: none;
    }

    .sidebar .nav-link {
        text-align: center;
        padding: 1rem;
    }

    .sidebar .nav-link i {
        margin-right: 0;
        font-size: 1.2rem;
    }

    .sidebar.show {
        width: var(--sidebar-width);
        overflow: visible;
    }

    .sidebar.show .sidebar-brand-text,
    .sidebar.show .nav-link span,
    .sidebar.show .sidebar-heading {
        display: inline;
    }

    .sidebar.show .nav-link {
        text-align: left;
        padding: 0.75rem 1rem;
    }

    .sidebar.show .nav-link i {
        margin-right: 0.5rem;
        font-size: 0.85rem;
    }

    #content-wrapper {
        margin-left: 0;
    }

    #content-wrapper.sidebar-collapsed {
        margin-left: 0;
    }

    #content {
        padding: 1rem;
    }

    .topbar .navbar-search {
        width: 100%;
    }

    /* Stack stat cards */
    .stat-card .stat-value {
        font-size: 1.25rem;
    }

    .stat-card .stat-icon {
        font-size: 1.5rem;
    }

    /* Page header stacking */
    .d-sm-flex.align-items-center.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    /* Chart containers */
    canvas {
        max-height: 250px;
    }

    /* KPI cards responsive */
    .kpi-card .kpi-value {
        font-size: 1.35rem;
    }

    /* Table cells - prevent wrapping on key columns */
    .table td, .table th {
        white-space: nowrap;
    }

    /* Allow message columns to wrap */
    .table .wrap-cell {
        white-space: normal;
        min-width: 120px;
    }

    /* Bulk actions bar */
    .bulk-actions-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .bulk-actions-bar .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* Pagination */
    .pagination-wrapper {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center !important;
    }

    /* Filter rows */
    .filter-row .col-md-2,
    .filter-row .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Card header flex items */
    .card-header.d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Modal dialogs */
    .modal-lg, .modal-xl {
        max-width: calc(100% - 1rem);
        margin: 0.5rem;
    }

    /* Settings system info table */
    .table-sm th {
        font-size: 0.75rem;
        padding-right: 0.5rem;
    }

    .table-sm td {
        font-size: 0.75rem;
    }
}

@media (max-width: 576px) {
    #content {
        padding: 0.75rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .card .card-header {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }

    .card .card-body {
        padding: 0.75rem;
    }

    /* Full-width buttons on mobile */
    .quick-actions .btn {
        display: block;
        width: 100%;
        margin-right: 0;
    }

    /* Table font size */
    .table {
        font-size: 0.8rem;
    }

    .table thead th {
        font-size: 0.65rem;
    }

    /* Filter rows - single column on xs */
    .filter-row .col-md-2,
    .filter-row .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Action buttons in table - stack vertically */
    .btn-group-sm .btn {
        padding: 0.2rem 0.35rem;
        font-size: 0.7rem;
    }

    /* Badge sizing */
    .badge {
        font-size: 0.65rem;
    }

    /* Form buttons full width */
    .form-actions-mobile .btn {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Stat cards compact */
    .stat-card .stat-value {
        font-size: 1.1rem;
    }

    .stat-card .stat-title {
        font-size: 0.6rem;
    }

    .stat-card .stat-icon {
        font-size: 1.25rem;
    }

    /* KPI compact */
    .kpi-card .kpi-value {
        font-size: 1.15rem;
    }

    .kpi-card .kpi-label {
        font-size: 0.6rem;
    }

    .kpi-card .kpi-sub {
        font-size: 0.65rem;
    }
}

/* Login/Register pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--sidebar-bg) 10%, var(--sidebar-dark-bg) 100%);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    background: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.auth-card .auth-header {
    background-color: var(--primary-color);
    color: #fff;
    text-align: center;
    padding: 2rem;
    border-radius: 0.5rem 0.5rem 0 0;
}

.auth-card .auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.auth-card .auth-header p {
    margin-bottom: 0;
    opacity: 0.9;
}

.auth-card .auth-body {
    padding: 2rem;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.hidden {
    display: none;
}

/* Bulk input textarea */
.bulk-input {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 150px;
}

/* Quick action buttons */
.quick-actions .btn {
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Activity timeline */
.activity-timeline {
    position: relative;
    padding-left: 2rem;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: #e3e6f0;
}

.activity-timeline .activity-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.activity-timeline .activity-item::before {
    content: '';
    position: absolute;
    left: -1.75rem;
    top: 0.25rem;
    width: 0.75rem;
    height: 0.75rem;
    background-color: var(--primary-color);
    border-radius: 50%;
}

.activity-timeline .activity-item.success::before { background-color: var(--success-color); }
.activity-timeline .activity-item.warning::before { background-color: var(--warning-color); }
.activity-timeline .activity-item.danger::before { background-color: var(--danger-color); }
.activity-timeline .activity-item.info::before { background-color: var(--info-color); }

.activity-timeline .activity-item .activity-time {
    font-size: 0.75rem;
    color: var(--secondary-color);
}

.activity-timeline .activity-item .activity-content {
    font-size: 0.9rem;
}
