/* ==========================================================================
   PLADECOF Backoffice — sigma/GECOS style
   ========================================================================== */

:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1D3341;
    --sidebar-accent: #2B84A2;

    /* Bootstrap primary/link overrides */
    --bs-primary: #1D3341;
    --bs-primary-rgb: 29,51,65;
    --bs-link-color: #2B84A2;
    --bs-link-hover-color: #1D3341;
}

.btn-primary {
    --bs-btn-bg: #1D3341;
    --bs-btn-border-color: #1D3341;
    --bs-btn-hover-bg: #152736;
    --bs-btn-hover-border-color: #152736;
    --bs-btn-active-bg: #152736;
}

.btn-outline-primary {
    --bs-btn-color: #1D3341;
    --bs-btn-border-color: #1D3341;
    --bs-btn-hover-bg: #1D3341;
    --bs-btn-hover-border-color: #1D3341;
    --bs-btn-active-bg: #1D3341;
}

.text-primary   { color: #1D3341 !important; }
.border-primary { border-color: #1D3341 !important; }

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.925rem;
    background-color: #f8f9fa;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: #fff;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar .logo {
    padding: 1.25rem 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.sidebar .nav-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 0.5rem;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 0.55rem 1rem;
    border-left: 3px solid transparent;
    border-radius: 0;
    font-size: 0.875rem;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.sidebar .nav-link:hover {
    color: #fff;
    background-color: rgba(255,255,255,0.06);
    border-left-color: var(--sidebar-accent);
}

.sidebar .nav-link.active {
    color: #fff;
    background-color: rgba(43,132,162,0.2);
    border-left-color: var(--sidebar-accent);
}

.sidebar .nav-link i {
    width: 16px;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.sidebar .nav-section {
    padding: 0.9rem 1rem 0.2rem;
}

.sidebar .nav-section small {
    color: rgba(255,255,255,0.4);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.sidebar .user-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 0.875rem 1rem;
}

/* ── Main content ─────────────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 0.75rem 1.5rem;
    flex-shrink: 0;
}

/* ── Content area ─────────────────────────────────────────────────────────── */
.content-area {
    flex: 1;
    padding: 1.5rem;
}

/* ── Page titles ──────────────────────────────────────────────────────────── */
.page-title,
.content-area h3,
.content-area h4 {
    font-size: 1.35rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 1.25rem;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    border: none !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #fff !important;
    border-bottom: 1px solid #e9ecef !important;
    padding: 0.7rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table {
    font-size: 0.875rem;
    --bs-table-border-color: #e9ecef;
    --bs-table-hover-bg: #f8fafc;
}

.table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280;
    background-color: #f8fafc;
    border-bottom: 2px solid #e9ecef;
    border-top: none;
    padding: 0.65rem 0.75rem;
    white-space: nowrap;
}

/* Override Bootstrap's table-light/table-dark so they use our brand style */
.table thead.table-light th,
.table thead.table-dark th {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7280 !important;
    background-color: #f8fafc !important;
    border-bottom: 2px solid #e9ecef !important;
}

.table tbody tr {
    transition: background-color 0.1s;
}

.table tbody tr:hover > * {
    --bs-table-color-state: inherit;
    background-color: #f0f7fb;
}

.table tbody td {
    vertical-align: middle;
    border-bottom-color: #f1f5f9;
    padding: 0.6rem 0.75rem;
    color: #374151;
}

.table-sm tbody td {
    padding: 0.4rem 0.75rem;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.nav-tabs {
    border-bottom: 2px solid #e9ecef;
    gap: 0.125rem;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: 0;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.6rem 1rem;
    transition: color 0.15s ease, border-color 0.15s ease;
    background: none !important;
}

.nav-tabs .nav-link:hover {
    color: var(--sidebar-bg);
    border-bottom-color: #cbd5e1;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    color: var(--sidebar-accent);
    border-bottom-color: var(--sidebar-accent);
    font-weight: 600;
}

.nav-tabs .nav-link i {
    opacity: 0.75;
}

.nav-tabs .nav-link.active i {
    opacity: 1;
}

/* ── Flash messages ───────────────────────────────────────────────────────── */
.messages-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    max-width: 420px;
    width: calc(100vw - 2rem);
}

.messages-container .alert {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.backoffice-footer {
    padding: 0.75rem 1.5rem;
    text-align: center;
    background-color: var(--sidebar-bg);
    color: rgba(255,255,255,0.45);
    font-size: 0.8rem;
}

/* ── Misc utilities ───────────────────────────────────────────────────────── */
.form-label { font-weight: 500; font-size: 0.875rem; }
.btn { font-size: 0.875rem; }

/* ── Auto-style Django-rendered form widgets ──────────────────────────────── */
.content-area input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not(.form-control):not(.form-select):not(.btn),
.content-area select:not(.form-select):not(.form-control),
.content-area textarea:not(.form-control),
.card-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not(.form-control):not(.form-select):not(.btn),
.card-body select:not(.form-select):not(.form-control),
.card-body textarea:not(.form-control) {
    display: block;
    width: 100%;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.content-area input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not(.form-control):not(.form-select):not(.btn):focus,
.content-area select:not(.form-select):not(.form-control):focus,
.content-area textarea:not(.form-control):focus,
.card-body input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not(.form-control):not(.form-select):not(.btn):focus,
.card-body select:not(.form-select):not(.form-control):focus,
.card-body textarea:not(.form-control):focus {
    border-color: var(--sidebar-accent, #2B84A2);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(43,132,162,0.2);
}

.content-area select:not(.form-select):not(.form-control),
.card-body select:not(.form-select):not(.form-control) {
    appearance: auto;
}

/* Field error lists */
.content-area ul.errorlist,
.card-body ul.errorlist {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: #dc3545;
}

/* Input-group: fix width/flex for auto-styled inputs */
.content-area .input-group input:not(.form-control),
.card-body .input-group input:not(.form-control) {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}
.content-area .input-group input:not(.form-control):not(:last-child),
.card-body .input-group input:not(.form-control):not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
.content-area .input-group input:not(.form-control):not(:first-child),
.card-body .input-group input:not(.form-control):not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Checkbox/radio alignment */
.form-check { display: flex; align-items: center; gap: 0.5rem; padding-left: 0; }
.form-check input[type="checkbox"],
.form-check input[type="radio"] { margin: 0; flex-shrink: 0; }

/* ── Loader ───────────────────────────────────────────────────────────────── */
.loader {
    position: fixed; inset: 0;
    background: rgba(255,255,255,0.9);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 0.75rem;
    color: var(--sidebar-accent); font-size: 1rem;
}

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    background-color: var(--sidebar-bg);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 1.5rem;
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-backdrop { z-index: 1040; }
.modal { z-index: 1050; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.step-links { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; justify-content: center; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
}
