/* =====================================================================
   Site-wide SaaS theme skin for the Django/Jazzmin admin.
   Pure CSS only - no template/behaviour changes. Loaded on every admin
   page (admin/base.html) and on the login page (registration/base.html),
   after Jazzmin's own CSS, so these rules win on specificity ties.
   Mirrors the design language already used on the dashboard and the
   settings page (indigo accent, soft shadows, rounded 12-16px cards).
   ===================================================================== */

:root {
    --th-ink-900: #0f172a;
    --th-ink-700: #334155;
    --th-ink-600: #475569;
    --th-ink-400: #94a3b8;
    --th-border: #e9edf3;
    --th-border-soft: #f1f5f9;
    --th-surface: #ffffff;
    --th-page: #f6f7fb;
    --th-accent: #4f46e5;
    --th-accent-ink: #4338ca;
    --th-accent-soft: #eef2ff;
    --th-radius-lg: 16px;
    --th-radius-md: 10px;
    --th-radius-sm: 8px;
    --th-shadow: 0 1px 2px rgba(15, 23, 42, .03), 0 10px 24px -16px rgba(15, 23, 42, .12);
}

body.jazzmin,
.content-wrapper {
    background: var(--th-page) !important;
}

/* ---------- Typography baseline ---------- */

body, .form-control, table, .card {
    color: var(--th-ink-900);
}

/* ---------- Sidebar ---------- */

.main-sidebar, .main-sidebar .sidebar {
    background: #11131f;
}

.brand-link {
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.nav-sidebar > .nav-item > .nav-link {
    border-radius: var(--th-radius-sm);
    margin: 2px 10px;
    width: auto;
    color: #c6c9d8;
    transition: background-color .12s ease, color .12s ease;
}

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

.nav-sidebar > .nav-item > .nav-link.active,
.nav-sidebar > .nav-item > .nav-link.active:hover {
    background: var(--th-accent);
    color: #fff;
    box-shadow: 0 4px 10px -4px rgba(79, 70, 229, .6);
}

.nav-sidebar .nav-header {
    color: #6b7084;
    font-weight: 700;
    letter-spacing: .04em;
    font-size: 11px;
}

.nav-sidebar .nav-icon {
    opacity: .85;
}

/* ---------- Navbar ---------- */

.main-header.navbar {
    background: var(--th-surface) !important;
    border-bottom: 1px solid var(--th-border);
    box-shadow: none;
}

/* ---------- Content header / breadcrumbs ---------- */

.content.border-bottom {
    background: var(--th-surface);
    border-bottom: 1px solid var(--th-border) !important;
}

.content h1.h4 {
    font-size: 17px;
    font-weight: 700;
    color: var(--th-ink-900);
    border-right-color: var(--th-border) !important;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 12.5px;
}

.breadcrumb-item a {
    color: var(--th-ink-400);
}

.breadcrumb-item.active {
    color: var(--th-ink-600);
}

/* ---------- Cards / boxes (changelist + changeform wrap everything in .card) ---------- */

.card {
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius-lg);
    box-shadow: var(--th-shadow);
}

.card-header {
    background: var(--th-surface);
    border-bottom: 1px solid var(--th-border-soft);
    border-top-left-radius: var(--th-radius-lg) !important;
    border-top-right-radius: var(--th-radius-lg) !important;
    font-weight: 700;
}

.card-body {
    padding: 24px;
}

/* ---------- Buttons ---------- */

.btn {
    border-radius: var(--th-radius-sm);
    font-weight: 600;
    font-size: 13.5px;
    padding: 8px 16px;
    box-shadow: none;
    height: auto !important;
    line-height: 1.4 !important;
    white-space: normal;
}

.btn-primary, .bg-primary {
    background-color: var(--th-accent) !important;
    border-color: var(--th-accent) !important;
    color: #fff !important;
}

.btn-primary:hover {
    background-color: var(--th-accent-ink) !important;
    border-color: var(--th-accent-ink) !important;
    color: #fff !important;
}

.btn-success {
    background-color: #059669 !important;
    border-color: #059669 !important;
    color: #fff !important;
}

.btn-success:hover {
    background-color: #047857 !important;
    border-color: #047857 !important;
    color: #fff !important;
}

.btn-danger {
    background-color: #e11d48 !important;
    border-color: #e11d48 !important;
    color: #fff !important;
}

.btn-danger:hover {
    background-color: #be123c !important;
    border-color: #be123c !important;
    color: #fff !important;
}

.btn-info {
    background-color: #0891b2 !important;
    border-color: #0891b2 !important;
    color: #fff !important;
}

.btn-secondary, .btn-dark {
    background-color: #334155 !important;
    border-color: #334155 !important;
    color: #fff !important;
}

.object-tools .btn,
.object-tools a.btn {
    border-radius: var(--th-radius-sm);
}

/* ---------- Forms (changeform rows use .form-group, not Django's classic .form-row) ---------- */

.form-control,
.vTextField,
.vLargeTextField,
.vURLField,
.vIntegerField,
.vDateField,
.vTimeField,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
    border: 1px solid var(--th-border) !important;
    border-radius: var(--th-radius-sm) !important;
    font-size: 13.5px;
}

.form-control:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--th-accent) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12) !important;
}

.form-group label {
    font-weight: 600;
    color: var(--th-ink-700);
    font-size: 13px;
}

.form-group .help,
.form-text,
.help-block {
    color: var(--th-ink-400);
    font-size: 12px;
}

.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--th-border) !important;
    border-radius: var(--th-radius-sm) !important;
}

/* select2 copies the bare <select>'s intrinsic width into an inline style, so a field with long
   option labels (the head-office picker) would otherwise overflow its form column. */
.form-group .select2-container {
    width: 100% !important;
}

.form-group .select2-selection__rendered {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Tables (changelist results) ---------- */

table.table {
    font-size: 13px;
}

table.table thead th {
    text-transform: uppercase;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--th-ink-400);
    border-bottom: 1px solid var(--th-border) !important;
    border-top: none !important;
    background: var(--th-surface);
}

table.table thead th a {
    color: var(--th-ink-400);
}

table.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--th-border-soft);
}

table.table tbody td, table.table tbody th {
    border-top: 1px solid var(--th-border-soft);
    vertical-align: middle;
}

table.table tbody tr:hover {
    background-color: var(--th-accent-soft);
}

/* ---------- Pagination ---------- */

.pagination .page-link {
    border-radius: var(--th-radius-sm);
    margin: 0 2px;
    border: 1px solid transparent;
    color: var(--th-ink-600);
}

.pagination .page-item.active .page-link {
    background-color: var(--th-accent);
    border-color: var(--th-accent);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    color: var(--th-ink-400);
}

/* ---------- Search / filters / actions bar ---------- */

#changelist-search .form-control,
#changelist-search .btn {
    border-radius: var(--th-radius-sm);
}

.actions {
    background: var(--th-surface);
    border: 1px solid var(--th-border);
    border-radius: var(--th-radius-md);
    padding: 10px 14px;
}

.content-filters .card,
#changelist-filter {
    border-radius: var(--th-radius-lg);
}

/* ---------- Alerts / messages ---------- */

.alert {
    border: none;
    border-radius: var(--th-radius-md);
    font-size: 13.5px;
}

.alert-success {
    background: #ecfdf5;
    color: #047857;
}

.alert-danger {
    background: #fff1f2;
    color: #be123c;
}

.alert-warning {
    background: #fffbeb;
    color: #b45309;
}

.alert-info {
    background: var(--th-accent-soft);
    color: var(--th-accent-ink);
}

/* ---------- Login page ---------- */

body.jazzmin-login-page {
    background: var(--th-page);
}

body.jazzmin-login-page .login-box .card {
    border-radius: var(--th-radius-lg);
}

body.jazzmin-login-page .login-logo h1 {
    color: var(--th-ink-900);
}

body.jazzmin-login-page .btn-primary {
    width: 100%;
}

/* ---------- Small screens ---------- */

@media (max-width: 575px) {
    #jazzy-actions,
    #jazzy-actions > .d-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    #jazzy-actions .form-group {
        margin: 0 !important;
        width: 100%;
    }

    #jazzy-actions .btn {
        width: 100%;
        white-space: normal;
        word-break: break-word;
    }

    .card-body {
        padding: 16px;
    }
}

/* ---------- Language switcher (flags instead of a globe icon) ---------- */

.lang-switcher-trigger {
    display: flex;
    align-items: center;
}

.lang-switcher-trigger .lang-flag {
    font-size: 19px;
    line-height: 1;
}

.lang-switcher-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-switcher-item .lang-flag {
    font-size: 16px;
    line-height: 1;
}

/* ---------- Select2 (every <select> on the site gets upgraded to this by
   Jazzmin/our own JS) - the trigger box is already covered above under
   "Forms"; this restyles the open dropdown panel, which otherwise keeps
   select2's own default blue instead of the site accent. ---------- */

.select2-container--default .select2-selection--single {
    height: 38px;
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: normal;
    color: var(--th-ink-900);
    padding-left: 12px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

.select2-container--default .select2-selection--multiple {
    min-height: 38px;
    border-radius: var(--th-radius-sm) !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background: var(--th-accent-soft) !important;
    border: 1px solid #c7d2fe !important;
    color: var(--th-accent-ink) !important;
    border-radius: 6px !important;
    padding: 1px 8px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__display {
    color: var(--th-accent-ink);
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--th-accent) !important;
    margin-right: 6px;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: var(--th-accent-ink) !important;
}

.select2-dropdown {
    border: 1px solid var(--th-border) !important;
    border-radius: var(--th-radius-md) !important;
    box-shadow: var(--th-shadow);
    overflow: hidden;
}

.select2-search--dropdown {
    padding: 8px;
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid var(--th-border) !important;
    border-radius: var(--th-radius-sm) !important;
    padding: 6px 10px;
}

.select2-search--dropdown .select2-search__field:focus {
    outline: none;
    border-color: var(--th-accent) !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.select2-results__option {
    padding: 8px 14px;
    font-size: 13.5px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--th-accent) !important;
    color: #fff !important;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: var(--th-accent-soft);
    color: var(--th-accent-ink);
}

.select2-results__group {
    color: var(--th-ink-400);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 700;
}

/* ---------- Changeform section tabs (#jazzy-tabs: "Devices" / "Services" / ... on
   any changeform with multiple fieldsets or inlines) - segmented pill control
   instead of Jazzmin's default underlined Bootstrap tabs. */

#jazzy-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    background: var(--th-border-soft);
    border: none;
    border-radius: var(--th-radius-md);
    padding: 4px;
    margin-bottom: 20px !important;
}

#jazzy-tabs .nav-link {
    border: none;
    border-radius: var(--th-radius-sm);
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--th-ink-600);
    background: transparent;
}

#jazzy-tabs .nav-link:hover {
    color: var(--th-ink-900);
}

#jazzy-tabs .nav-link.active {
    background: var(--th-surface);
    color: var(--th-accent-ink);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

/* ---------- Inline formset tables (any model's inlines) - wide multi-column
   tables (Devices, Transactions, ...) scroll within their own box instead of
   blowing out the page width on narrow screens. */

.tabular.inline-related {
    max-width: 100%;
    overflow-x: auto;
}

/* ---------- Flatpickr theme (global - any page that loads flatpickr gets this;
   dashboard.css has its own copy scoped to --dash-* tokens, kept separately so this
   doesn't risk touching the already-shipped dashboard look). ---------- */

.flatpickr-calendar {
    border-radius: 14px;
    box-shadow: var(--th-shadow);
    border: 1px solid var(--th-border);
    font-family: inherit;
}

.flatpickr-calendar.arrowTop:before,
.flatpickr-calendar.arrowTop:after {
    display: none;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month {
    color: var(--th-ink-900);
}

.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    font-weight: 600;
}

.flatpickr-weekday {
    color: var(--th-ink-400);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
}

.flatpickr-day {
    border-radius: 8px;
    color: var(--th-ink-900);
}

.flatpickr-day:hover,
.flatpickr-day:focus {
    background: var(--th-accent-soft);
    border-color: var(--th-accent-soft);
}

.flatpickr-day.today {
    border-color: var(--th-accent);
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: var(--th-accent);
    border-color: var(--th-accent);
    color: #fff;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--th-ink-400);
    opacity: .55;
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: var(--th-accent);
}

