/**
 * Admin CSS - Metis Bootstrap 5 Admin Template style
 * Design tokens from: https://github.com/puikinsh/Bootstrap-Admin-Template
 * Keeps all admin pages consistent.
 */

/* Override Bootstrap theme colors for admin (Metis palette) */
body.admin-layout {
    --bs-primary: #6366f1;
    --bs-primary-rgb: 99, 102, 241;
    --bs-secondary: #64748b;
    --bs-success: #10b981;
    --bs-info: #06b6d4;
    --bs-warning: #f59e0b;
    --bs-danger: #ef4444;
}

/* ========== Design tokens (Metis variables) ========== */
:root {
    --om-primary: #6366f1;
    --om-primary-hover: #4f46e5;
    --om-secondary: #64748b;
    --om-success: #10b981;
    --om-info: #06b6d4;
    --om-warning: #f59e0b;
    --om-danger: #ef4444;
    --om-light: #f8fafc;
    --om-dark: #1e293b;
    --om-sidebar-width: 280px;
    --om-sidebar-mini-width: 70px;
    --om-header-height: 56px;
    --om-border-radius: 0.75rem;
    --om-border-radius-sm: 0.5rem;
    --om-box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --om-box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --om-border-color: #e2e8f0;
    --om-admin-bg: #f8fafc;
    --om-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --cui-table-bg: #fff;
}

/* ========== Base ========== */
body.admin-layout {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.9rem;
    line-height: 1.6;
    background: var(--om-admin-bg);
    color: #334155;
    min-height: 100vh;
}

.admin-wrapper {
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========== Header (Metis: fixed top) ========== */
.admin-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    height: var(--om-header-height);
}

.admin-header .navbar {
    height: 100%;
    border-bottom: 1px solid var(--om-border-color);
    background: #fff;
}

.admin-header .navbar .container-fluid {
    padding-left: 0.75rem;
    padding-right: 1rem;
}

.hamburger-menu {
    margin-right: 0.5rem;
}

.admin-header .navbar-nav .dropdown-menu {
    position: absolute;
}

.avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
    color: #fff;
    background: var(--om-secondary);
    border-radius: var(--om-border-radius-sm);
}

/* ========== Sidebar (Metis: fixed left, below header) ========== */
.admin-sidebar {
    position: fixed;
    top: var(--om-header-height);
    left: 0;
    width: var(--om-sidebar-width);
    height: calc(100vh - var(--om-header-height));
    background: #fff;
    border-right: 1px solid var(--om-border-color);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1025;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-content {
    padding: 0.75rem 0;
}

.sidebar-nav .nav {
    padding-left: 0;
    padding-right: 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    color: #475569;
    text-decoration: none;
    border-radius: 0;
    border-left: 3px solid transparent;
    transition: var(--om-transition);
}

.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 24px;
    margin-right: 0.75rem;
    flex-shrink: 0;
    opacity: 0.9;
}

.sidebar-nav .nav-link:hover {
    background: var(--om-light);
    color: var(--om-primary);
}

.sidebar-nav .nav-link.active {
    background: rgba(99, 102, 241, 0.08);
    color: var(--om-primary);
    border-left-color: var(--om-primary);
    font-weight: 500;
}

.sidebar-nav .nav-item small {
    font-size: 0.7rem;
    letter-spacing: 0.05em;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1020;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .admin-sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12);
    }
    body.sidebar-open {
        overflow: hidden;
    }
}

/* ========== Main content ========== */
.admin-main {
    margin-top: var(--om-header-height);
    margin-left: var(--om-sidebar-width);
    min-height: calc(100vh - var(--om-header-height));
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

@media (max-width: 991.98px) {
    .admin-main {
        margin-left: 0;
    }
}

.admin-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--om-border-color);
    background: #fff;
}

/* ========== Breadcrumb ========== */
.admin-main .breadcrumb {
    background: transparent;
    padding: 0;
    margin-bottom: 0;
}

.admin-main .breadcrumb-item + .breadcrumb-item::before {
    color: #94a3b8;
}

.admin-main .breadcrumb-item a {
    color: var(--om-primary);
    text-decoration: none;
}

.admin-main .breadcrumb-item.active {
    color: #64748b;
}

/* ========== Cards (Metis style) ========== */
.admin-main .card {
    border: 0;
    border-radius: var(--om-border-radius);
    box-shadow: var(--om-box-shadow);
    background: #fff;
    overflow: visible;
}

.admin-main .card-header {
    padding: 1rem 1.25rem;
    background: transparent;
    border-bottom: 1px solid var(--om-border-color);
    font-weight: 600;
    border-radius: var(--om-border-radius) var(--om-border-radius) 0 0;
}

.admin-main .card-body {
    padding: 1.25rem;
}

/* Stats / widget cards */
.card-widget,
.stats-card {
    border: 0;
    border-radius: var(--om-border-radius);
    box-shadow: var(--om-box-shadow);
}

.stats-card .card-body {
    padding: 1.25rem;
}

.stats-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--om-border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.widget-value {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.2;
}

.widget-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.widget-progress {
    height: 4px;
    margin-top: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.widget-progress-bar {
    height: 100%;
    background: currentColor;
    transition: width 0.3s ease;
}

/* ========== Buttons (Metis) ========== */
.admin-main .btn {
    border-radius: var(--om-border-radius-sm);
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: var(--om-transition);
}

.admin-main .btn-primary {
    background: var(--om-primary);
    border-color: var(--om-primary);
}

.admin-main .btn-primary:hover {
    background: var(--om-primary-hover);
    border-color: var(--om-primary-hover);
}

.admin-main .btn-success {
    background: var(--om-success);
    border-color: var(--om-success);
}

.admin-main .btn-danger {
    background: var(--om-danger);
    border-color: var(--om-danger);
}

.admin-main .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

/* ========== Forms ========== */
.admin-main .form-control,
.admin-main .form-select {
    border-radius: var(--om-border-radius-sm);
    border: 1px solid var(--om-border-color);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.admin-main .form-control:focus,
.admin-main .form-select:focus {
    border-color: var(--om-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.admin-main .form-label {
    font-weight: 500;
    color: #334155;
    margin-bottom: 0.375rem;
}

/* ========== Tables ========== */
.admin-main .table {
    color: #475569;
    vertical-align: middle;
    border-color: var(--om-border-color);
}

.admin-main .table thead th {
    font-weight: 600;
    color: #334155;
    border-bottom: 2px solid var(--om-border-color);
    padding: 0.75rem 1rem;
    background: transparent;
}

.admin-main .table tbody td {
    padding: 0.75rem 1rem;
}

.admin-main .table tbody tr:hover {
    background: rgba(99, 102, 241, 0.04);
}

.table-responsive {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    display: block !important;
}

.admin-main .table {
    min-width: 800px;
}

/* Sticky action column */
.table-responsive .table thead tr th:last-child,
.table-responsive .table tbody tr td:last-child {
    position: sticky !important;
    right: 0 !important;
    background: var(--om-admin-bg) !important;
    z-index: 10 !important;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.08) !important;
}

.admin-main .card .table-responsive .table thead tr th:last-child,
.admin-main .card .table-responsive .table tbody tr td:last-child {
    background: #fff !important;
}

.admin-main .card .table-responsive .table tbody tr:hover td:last-child {
    background: rgba(99, 102, 241, 0.04) !important;
}

.admin-main .card .table-responsive {
    margin: 0 !important;
    max-width: 100% !important;
}

/* ========== Admin list pages (table full width, aligned with header) ========== */
.admin-list-card.card {
    width: 100%;
}

.admin-list-card .card-header {
    padding: 1rem 1.25rem;
}

.admin-list-card .card-body {
    padding: 0 !important;
    overflow: visible;
}

/* Toolbar: search + entries dropdown — same horizontal padding as card header */
.admin-datatable-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--om-border-color);
}

.admin-datatable-toolbar .search-wrap {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

.admin-datatable-toolbar .search-wrap:empty {
    flex: none;
    min-width: 0;
    max-width: none;
}

.admin-datatable-toolbar .filters-wrap {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.admin-datatable-toolbar .filters-wrap .form-select {
    width: auto;
    min-width: 120px;
}

.admin-datatable-toolbar .entries-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.admin-datatable-toolbar .entries-wrap label {
    margin: 0;
    font-size: 0.9rem;
    color: #64748b;
    white-space: nowrap;
}

.admin-datatable-toolbar .entries-wrap .form-select {
    width: auto;
    min-width: 100px;
}

.admin-datatable-toolbar .entries-wrap > span {
    color: #64748b;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Table wrapper: same horizontal padding as card header so table aligns with "Add" button */
.admin-datatable-wrap {
    width: 100%;
    padding: 0 1.25rem 1rem;
    overflow: hidden;
}

.admin-datatable-wrap .table-responsive {
    width: 100% !important;
    max-width: 100% !important;
}

/* Table uses full available width; min-width only for horizontal scroll on small screens */
.admin-list-card .table-responsive .table {
    width: 100% !important;
    min-width: 800px;
}

/* Pagination / count bar below table — same horizontal padding */
.admin-datatable-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem 1rem;
    border-top: 1px solid var(--om-border-color);
    font-size: 0.875rem;
    color: #64748b;
}

.table-compact th,
.table-compact td {
    padding: 0.5rem;
    font-size: 0.8125rem;
}

/* ========== Badges ========== */
.admin-main .badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: var(--om-border-radius-sm);
}

/* ========== Alerts ========== */
.admin-main .alert {
    border-radius: var(--om-border-radius-sm);
    border: 0;
}

/* ========== Dropdown ========== */
.admin-main .dropdown-menu {
    border-radius: var(--om-border-radius-sm);
    border: 1px solid var(--om-border-color);
    box-shadow: var(--om-box-shadow-lg);
}

/* ========== Utilities ========== */
.text-high-emphasis {
    color: #1e293b !important;
}

/* Responsive */
@media (max-width: 1199.98px) {
    .admin-main .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .admin-main .table th,
    .admin-main .table td {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 767.98px) {
    .admin-main .container-fluid {
        padding: 0.75rem;
    }
    .admin-main .btn-group .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}
