/* ============================================================
   IT Company CRM — AdminLTE-themed design system
   ============================================================ */
:root {
    --primary: #d60127;
    --primary-rgb: 214, 1, 39;
    --primary-dark: #ab011f;
    --primary-soft: #fde7eb;
    --ink: #212529;
    --muted: #6c757d;
    --line: #dee2e6;
    --bg: #f4f6f9;
    --sidebar-bg: #383838;
    --sidebar-bg-2: #2e2e2e;
    --sidebar-link: #c7c7c7;
    --sidebar-w: 250px;
    --radius: .25rem;
    --shadow-sm: 0 0 1px rgba(0, 0, 0, .125), 0 1px 3px rgba(0, 0, 0, .2);
    --shadow: 0 0 1px rgba(0, 0, 0, .125), 0 1px 3px rgba(0, 0, 0, .2);
    --shadow-lg: 0 6px 20px rgba(0, 0, 0, .25);
}

* { -webkit-font-smoothing: antialiased; }

body {
    font-family: "Source Sans 3", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: .95rem;
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
code { color: #e83e8c; background: #f8f9fa; padding: .1rem .4rem; border-radius: var(--radius); font-size: .85em; }

/* ---------- Sidebar (AdminLTE sidebar-dark) ---------- */
#sidebar {
    width: var(--sidebar-w); position: fixed; inset: 0 auto 0 0; z-index: 1030;
    background: var(--sidebar-bg);
    color: var(--sidebar-link); overflow-y: auto; padding-bottom: 1.5rem;
    box-shadow: 0 0 1px rgba(0, 0, 0, .125);
}
#sidebar::-webkit-scrollbar { width: 6px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 3px; }

#sidebar .brand {
    background: #fff; padding: .8rem 1rem; display: flex; align-items: center; justify-content: center;
    text-decoration: none; border-bottom: 1px solid #2e2e2e; margin-bottom: .4rem;
}
#sidebar .brand-logo { max-height: 42px; width: auto; max-width: 100%; display: block; }
#sidebar .nav { padding: 0 .5rem; }
#sidebar a.nav-link {
    color: var(--sidebar-link); padding: .55rem .85rem; border-radius: var(--radius); margin-bottom: 1px;
    display: flex; align-items: center; gap: .65rem; font-weight: 400; font-size: .95rem;
    transition: background .12s ease, color .12s ease;
}
#sidebar a.nav-link i { font-size: 1rem; width: 22px; text-align: center; }
#sidebar a.nav-link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
#sidebar a.nav-link.active {
    background: var(--primary); color: #fff;
    box-shadow: 0 0 1px rgba(0, 0, 0, .125), 0 1px 3px rgba(0, 0, 0, .2);
}
#sidebar .nav-section {
    font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; font-weight: 400;
    color: #c2c7d0; opacity: .7; padding: .9rem .95rem .35rem;
}

/* ---------- Content / topbar (AdminLTE main-header) ---------- */
#content { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line); padding: .5rem 1rem !important; min-height: 56px;
    box-shadow: var(--shadow-sm);
}
.topbar .page-title { font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.topbar .user-chip {
    display: flex; align-items: center; gap: .55rem; padding: .3rem .55rem; border-radius: var(--radius);
    text-decoration: none; color: var(--ink); transition: background .12s;
}
.topbar .user-chip:hover { background: #f2f4f6; }
.topbar .avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: var(--primary); color: #fff; font-weight: 600; font-size: .9rem;
}
main { width: 100%; flex: 1 0 auto; }

/* ---------- Footer (AdminLTE main-footer) ---------- */
.main-footer {
    background: #fff; border-top: 1px solid var(--line); color: var(--muted);
    padding: 1rem 1.5rem; font-size: .9rem;
}
.main-footer a { color: var(--primary); text-decoration: none; }
.main-footer a:hover { color: var(--primary-dark); }
.main-footer .footer-right { float: right; }

/* ---------- Content header / breadcrumbs (AdminLTE) ---------- */
.content-header { padding: .9rem 1.5rem .35rem; }
.content-header .breadcrumb { background: transparent; padding: 0; margin: 0; font-size: .9rem; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--primary-dark); }
.breadcrumb-item a i { font-size: .85em; }
.breadcrumb-item.active { color: var(--muted); }
.breadcrumb-item + .breadcrumb-item::before { color: #adb5bd; }

/* ---------- Small boxes (AdminLTE dashboard widgets) ---------- */
.small-box {
    position: relative; display: block; border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin-bottom: 1rem; color: #fff; overflow: hidden;
    transition: box-shadow .15s ease;
}
.small-box:hover { box-shadow: var(--shadow-lg); color: #fff; }
.small-box > .inner { padding: 1rem; }
.small-box h3 {
    font-size: 1.9rem; font-weight: 700; margin: 0 0 .25rem; color: inherit;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.small-box p { font-size: .95rem; margin: 0; color: inherit; }
.small-box .icon {
    position: absolute; top: .35rem; right: .9rem; z-index: 0;
    font-size: 3.8rem; line-height: 1; color: rgba(0, 0, 0, .15);
    transition: transform .25s linear;
}
.small-box:hover .icon { transform: scale(1.12) rotate(-3deg); }
.small-box .small-box-footer {
    position: relative; z-index: 1; display: block; text-align: center; padding: .35rem 0;
    color: rgba(255, 255, 255, .85); background: rgba(0, 0, 0, .1);
    text-decoration: none; font-size: .85rem;
}
.small-box .small-box-footer:hover { color: #fff; background: rgba(0, 0, 0, .18); }
.small-box.bg-primary   { background: #d60127 !important; }
.small-box.bg-info      { background: #17a2b8 !important; }
.small-box.bg-success   { background: #28a745 !important; }
.small-box.bg-danger    { background: #dc3545 !important; }
.small-box.bg-secondary { background: #6c757d !important; }
.small-box.bg-warning   { background: #ffc107 !important; color: #1f2d3d; }
.small-box.bg-warning .small-box-footer { color: rgba(31, 45, 61, .8); }
.small-box.bg-warning .small-box-footer:hover { color: #1f2d3d; }

/* ---------- Cards (AdminLTE box) ---------- */
.card {
    border: 1px solid rgba(0, 0, 0, .125); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    background: #fff;
}
.card-header {
    background: #fff !important; border-bottom: 1px solid rgba(0, 0, 0, .125);
    padding: .75rem 1.25rem; font-weight: 400;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-header .card-title, .card-title { font-size: 1.1rem; font-weight: 400; margin: 0; }
.card-body { padding: 1.25rem; }

/* ---------- Stat / info boxes ---------- */
.stat-card { transition: box-shadow .15s ease; height: 100%; }
.stat-card:hover { box-shadow: var(--shadow-lg); }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius); display: grid; place-items: center; font-size: 1.35rem;
}
.stat-card .stat-label { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.stat-card .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.soft-primary { background: var(--primary); color: #fff; }
.soft-success { background: #28a745; color: #fff; }
.soft-info    { background: #17a2b8; color: #fff; }
.soft-warning { background: #ffc107; color: #1f2d3d; }
.soft-danger  { background: #dc3545; color: #fff; }
.soft-secondary { background: #6c757d; color: #fff; }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius); font-weight: 400; padding: .375rem .75rem; font-size: .95rem; }
.btn-sm { border-radius: var(--radius); padding: .25rem .5rem; font-size: .825rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: #005cbf; }
.btn-light { background: #f8f9fa; border-color: #ddd; color: #444; }
.btn-light:hover { background: #e2e6ea; border-color: #ccc; }
.btn-outline-secondary { border-color: #ced4da; color: #6c757d; }
.btn-outline-secondary:hover { background: #6c757d; border-color: #6c757d; color: #fff; }
.btn-outline-danger { border-color: #dc3545; color: #dc3545; }
.btn-outline-danger:hover { background: #dc3545; border-color: #dc3545; color: #fff; }

/* ---------- Tables (AdminLTE) ---------- */
.table { margin-bottom: 0; color: var(--ink); }
.table > thead th {
    background: #fff; color: var(--ink); font-weight: 600; font-size: .9rem;
    border-bottom: 2px solid var(--line); border-top: 0;
    padding: .75rem 1.25rem; white-space: nowrap;
}
.table > tbody td { padding: .75rem 1.25rem; border-top: 1px solid var(--line); border-bottom: 0; vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: #f2f4f6; }

/* ---------- Badges (solid, AdminLTE) ---------- */
.badge { font-weight: 600; padding: .35em .6em; border-radius: var(--radius); font-size: .75rem; }
.badge.bg-primary   { background: var(--primary) !important; color: #fff; }
.badge.bg-success   { background: #28a745 !important; color: #fff; }
.badge.bg-info      { background: #17a2b8 !important; color: #fff; }
.badge.bg-warning   { background: #ffc107 !important; color: #1f2d3d; }
.badge.bg-danger    { background: #dc3545 !important; color: #fff; }
.badge.bg-secondary { background: #6c757d !important; color: #fff; }
.badge.bg-light     { background: #f8f9fa !important; color: #495057; }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: .9rem; color: var(--ink); margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: var(--radius); border: 1px solid #ced4da; padding: .375rem .75rem; font-size: .95rem;
    background-color: #fff; transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    border-color: #80bdff; box-shadow: 0 0 0 .2rem rgba(var(--primary-rgb), .25);
}
.form-control-sm, .form-select-sm { border-radius: var(--radius); }
.input-group-text { border-radius: var(--radius); border-color: #ced4da; background: #e9ecef; color: #495057; }

/* ---------- Progress ---------- */
.progress { background: #e9ecef; border-radius: var(--radius); height: .75rem; }
.progress-bar { background: var(--primary); font-size: .65rem; }

/* ---------- List groups ---------- */
.list-group-item { border-color: var(--line); padding: .75rem 1.25rem; }

/* ---------- Pagination ---------- */
.pagination { margin-bottom: 0; }
.page-link { border: 1px solid var(--line); color: var(--primary); padding: .375rem .75rem; font-size: .9rem; }
.page-link:hover { background: #e9ecef; color: var(--primary-dark); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- DataTables (v2) ---------- */
.dt-container { width: 100%; }
/* The bootstrap5 renderer makes each layout row a .row with mt-2 + col gutters.
   Neutralise those so everything aligns to a single 1.25rem edge. */
.dt-container > .dt-layout-row { margin: 0; align-items: center; }
.dt-container > .dt-layout-row > [class*="col"] { padding-left: 0; padding-right: 0; }
/* Top band (length + search) and bottom band (info + paging) read like a card header/footer */
.dt-container > .dt-layout-row:first-child { padding: .85rem 1.25rem; border-bottom: 1px solid var(--line); }
.dt-container > .dt-layout-row:last-child  { padding: .85rem 1.25rem; border-top: 1px solid var(--line); }
/* Table flush between the bands; its own cells carry the 1.25rem padding */
.dt-container > .dt-layout-table { margin: 0; }
.dt-container table.dataTable { margin: 0 !important; width: 100% !important; }
/* Compact length select + right-aligned search, never full-width */
.dt-container .dt-length select.form-select { width: auto; display: inline-block; }
.dt-container .dt-search input.form-control { width: auto; min-width: 230px; display: inline-block; }
.dt-container .dt-length label,
.dt-container .dt-search label { display: inline-flex; align-items: center; gap: .5rem; margin: 0; color: var(--muted); font-size: .9rem; font-weight: 400; }
.dt-container .dt-info { color: var(--muted); font-size: .85rem; padding: 0; }
.dt-container .dt-paging .pagination { justify-content: flex-end; margin: 0; }
/* Sort affordance on sortable headers */
table.dataTable thead th.dt-orderable-asc,
table.dataTable thead th.dt-orderable-desc { cursor: pointer; }
table.dataTable thead .dt-column-order::before,
table.dataTable thead .dt-column-order::after { opacity: .45; }

/* Let the Responsive extension collapse columns instead of scrolling horizontally */
.table-responsive:has(> .dt-container) { overflow: visible; }

/* Responsive expand/collapse control (the round +/- button).
   Only shown when the table is actually collapsing columns (narrow screens). */
table.dataTable.collapsed td.dtr-control { cursor: pointer; }
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before {
    content: "+"; font-weight: 700; border: 0; background: var(--primary);
    color: #fff; box-shadow: none; border-radius: var(--radius); width: 1.4rem; height: 1.4rem;
    line-height: 1.3rem; text-align: center; font-size: 1rem; margin-top: 0; top: auto;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.dtr-expanded > td.dtr-control::before { content: "\2212"; background: var(--primary-dark); color: #fff; }
/* Child row holding the collapsed columns */
table.dataTable > tbody > tr.child:hover { background: transparent !important; }
ul.dtr-details { width: 100%; }
ul.dtr-details > li {
    border-bottom: 1px solid var(--line); padding: .55rem .25rem; display: flex; gap: .75rem;
}
ul.dtr-details > li:last-child { border-bottom: none; }
ul.dtr-details > li .dtr-title { min-width: 38%; font-weight: 600; color: var(--muted); text-transform: uppercase; font-size: .72rem; letter-spacing: .02em; }
ul.dtr-details > li .dtr-data { flex: 1; }

/* ---------- DataTables on small screens ---------- */
@media (max-width: 767.98px) {
    .dt-container > .dt-layout-row { flex-direction: column; gap: .6rem; text-align: center; }
    .dt-container .dt-length, .dt-container .dt-search,
    .dt-container .dt-info, .dt-container .dt-paging { width: 100%; justify-content: center !important; }
    .dt-container .dt-search input.form-control { width: 100%; min-width: 0; }
    .dt-container .dt-paging .pagination { justify-content: center; flex-wrap: wrap; }
}

/* ---------- Alerts ---------- */
.alert { border-radius: var(--radius); font-size: .95rem; }
.alert-success { background: #d4edda; border-color: #c3e6cb; color: #155724; }
.alert-danger  { background: #f8d7da; border-color: #f5c6cb; color: #721c24; }

/* ---------- Chat bubbles (tickets) ---------- */
.bubble { max-width: 78%; padding: .8rem 1rem; border-radius: var(--radius); font-size: .95rem; }
.bubble.theirs { background: #f2f4f6; border-bottom-left-radius: 2px; }
.bubble.mine   { background: var(--primary-soft); border-bottom-right-radius: 2px; }

/* ---------- Auth / login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-brand {
    background: linear-gradient(150deg, #2b2b2b 0%, #383838 45%, #8c0118 135%);
    color: #fff; padding: 3.5rem; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-brand::after {
    content: ""; position: absolute; width: 460px; height: 460px; border-radius: 50%;
    background: radial-gradient(circle, rgba(214, 1, 39, .4), transparent 70%);
    right: -140px; top: -120px;
}
.auth-logo-chip {
    display: inline-flex; align-items: center; padding: .6rem .9rem; background: #fff;
    border-radius: .5rem; box-shadow: var(--shadow);
}
.auth-logo-chip img { height: 38px; width: auto; display: block; }
.auth-logo { height: 44px; width: auto; display: block; }
.auth-brand h1 { font-size: 2.1rem; line-height: 1.2; }
.auth-brand .feature { display: flex; gap: .75rem; align-items: flex-start; margin-bottom: 1rem; color: #d6d6d6; }
.auth-brand .feature i { color: #ff8b9c; font-size: 1.15rem; margin-top: .1rem; }
.auth-panel { display: grid; place-items: center; padding: 2rem; background: #fff; }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 900px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
}

/* ---------- Responsive sidebar ---------- */
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 1029;
    opacity: 0; visibility: hidden; transition: opacity .25s ease;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }
@media (min-width: 992px) { .sidebar-backdrop { display: none; } }
@media (max-width: 991.98px) {
    #sidebar { left: calc(-1 * var(--sidebar-w)); transition: left .25s ease; box-shadow: var(--shadow-lg); }
    #sidebar.show { left: 0; }
    #content { margin-left: 0; }
}

.empty-state { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { font-size: 2.5rem; opacity: .35; display: block; margin-bottom: .5rem; }

/* ---------- Utilities ---------- */
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }

/* ---------- Page header (AdminLTE content-header) ---------- */
.page-head { margin-bottom: 1.25rem; }
.page-head h4 { margin-bottom: .15rem; font-weight: 600; font-size: 1.6rem; }
.page-head .sub { color: var(--muted); font-size: .95rem; }

/* Toolbar inside card headers */
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.toolbar .form-control, .toolbar .form-select { min-width: 0; }
.search-box { position: relative; }
.search-box i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: .9rem; }
.search-box input { padding-left: 2rem; }
