/* ==========================================================================
   SoftXMD v2.1 — Modern design system
   Light, colorful dashboard look on Bootstrap 4 + custom shell
   ========================================================================== */

:root {
    --sx-primary: #4f46e5;
    --sx-primary-dark: #4338ca;
    --sx-primary-soft: #eef2ff;
    --sx-sidebar-bg: #111827;
    --sx-sidebar-bg-2: #1f2937;
    --sx-sidebar-text: #cbd5e1;
    --sx-sidebar-active: rgba(99, 102, 241, .16);
    --sx-content-bg: #f4f6fb;
    --sx-card-radius: 14px;
    --sx-primary-foreground: #ffffff;
    --sx-success: #10b981;
    --sx-warning: #f59e0b;
    --sx-danger: #ef4444;
    --sx-info: #0ea5e9;
    --sx-text: #1f2937;
    --sx-text-muted: #6b7280;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --radius: 12px;
}

.sx-admin {
    font-family: var(--font-sans);
    background: #eceff7;
    color: var(--sx-text);
    font-size: 14.5px;
    min-height: 100vh;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sx-sidebar {
    background: linear-gradient(180deg, var(--sx-sidebar-bg) 0%, var(--sx-sidebar-bg-2) 100%);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 250px;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform .22s ease, width .22s ease;
    box-shadow: 0 0 30px rgba(17, 24, 39, .28);
}
html[dir="rtl"] .sx-sidebar { left: auto; right: 0; }

.sx-brand {
    padding: 18px 18px 10px;
    flex-shrink: 0;
}
.sx-brand-link { display: flex; align-items: center; gap: 10px; }
.sx-brand-logo { max-height: 58px; max-width: 100%; }
.sx-brand-title { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .2px; white-space: nowrap; }

.sx-nav {
    padding: 6px 12px 18px;
    flex: 1 1 auto;
}
.sx-nav-search { padding: 4px 6px 10px; }

.sx-nav-label {
    color: #64748b;
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: .12em;
    font-weight: 700;
    padding: 14px 12px 6px;
}
.sx-nav-link {
    color: var(--sx-sidebar-text);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    margin-bottom: 2px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    border: 0;
    background: transparent;
    width: 100%;
    transition: background .15s ease, color .15s ease;
}
.sx-nav-link i { width: 20px; text-align: center; font-size: 14px; color: #94a3b8; }
.sx-nav-link:hover { color: #fff; background: rgba(148, 163, 184, .12); text-decoration: none; }
.sx-nav-link:hover i { color: #e2e8f0; }
.sx-nav-link.active {
    background: var(--sx-sidebar-active);
    color: #fff;
    border-inline-start: 3px solid var(--sx-primary);
    border-left: 3px solid #6366f1;
    border-right: 0;
    padding-left: 9px;
}
html[dir="rtl"] .sx-nav-link.active {
    border-left: 0;
    border-right: 3px solid #6366f1;
    padding-left: 12px;
    padding-right: 9px;
}
.sx-nav-link.active i { color: #a5b4fc; }
.sx-nav-count {
    background: var(--sx-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
}
.sx-nav-link .chevron { transition: transform .2s ease; color: #64748b; }

.sx-nav-group > .sx-nav-toggle { cursor: pointer; }
.sx-nav-group.open > .sx-nav-toggle .chevron { transform: rotate(-90deg); }
.sx-nav-submenu { display: none; padding: 2px 0 4px 24px; }
.sx-nav-group.open .sx-nav-submenu { display: block; }
.sx-nav-submenu .sx-nav-link { font-size: 13px; padding: 7px 10px; }

.sx-sidebar-footer { flex-shrink: 0; padding: 8px 14px 16px; text-align: center; }
.sx-softx-logo { max-width: 140px; opacity: .8; }

/* Sidebar collapsed (desktop) & hidden (mobile) */
@media (min-width: 992px) {
    .sx-admin.sx-collapsed .sx-sidebar { width: 74px; }
    .sx-admin.sx-collapsed .sx-brand-title,
    .sx-admin.sx-collapsed .sx-nav-label,
    .sx-admin.sx-collapsed .sx-nav-link span,
    .sx-admin.sx-collapsed .sx-nav-count,
    .sx-admin.sx-collapsed .sx-softx-logo { display: none; }
    .sx-admin.sx-collapsed .sx-nav-link { justify-content: center; }
    .sx-admin.sx-collapsed .sx-main-wrapper { margin-inline-start: 74px; }
    .sx-admin.sx-collapsed .sx-topbar-search { display: none; }
}
@media (max-width: 991.98px) {
    .sx-sidebar { transform: translateX(-102%); }
    html[dir="rtl"] .sx-sidebar { transform: translateX(102%); }
    .sx-admin.sx-show .sx-sidebar { transform: translateX(0); }
    .sx-admin.sx-show::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .5);
        z-index: 1030;
    }
    .sx-main-wrapper { margin-inline-start: 0; }
    /* Higher specificity than the base rule further down the file, which
       would otherwise win and keep the 250px sidebar margin on mobile. */
    .sx-admin .sx-main-wrapper { margin-inline-start: 0; }
}

/* --------------------------------------------------------------------------
   Main wrapper & topbar
   -------------------------------------------------------------------------- */
.sx-main-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin-inline-start: 250px;
    transition: margin .22s ease;
}

.sx-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: #fff;
    border-bottom: 1px solid #e5e9f2;
    display: flex;
    align-items: center;
    padding: 0 18px;
    height: 62px;
}
.sx-burger {
    background: transparent;
    border: 0;
    color: #475569;
    font-size: 17px;
    padding: 8px 10px;
    margin-inline-end: 8px;
    border-radius: 8px;
}
.sx-burger:hover { background: #f1f5f9; }
.sx-topbar-brand { font-weight: 700; color: var(--sx-text); text-decoration: none; margin-inline-end: 14px; }
.sx-topbar-brand:hover { color: var(--sx-text); }

.sx-topbar-search .select2-container { vertical-align: middle; }

.sx-topbar-nav { list-style: none; display: flex; align-items: center; gap: 4px; margin: 0 0 0 auto; padding: 0; }
.sx-topbar-link {
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    position: relative;
}
.sx-topbar-link:hover { background: #f1f5f9; color: var(--sx-text); }
.sx-topbar-link i { font-size: 16px; }

.sx-badge-dot {
    position: absolute;
    top: 0;
    inset-inline-end: 0;
    background: var(--sx-danger);
    color: #fff;
    border-radius: 9px;
    min-width: 18px;
    height: 18px;
    font-size: 10.5px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.sx-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sx-primary), #7c3aed);
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
}
.sx-user-name { font-size: 13.5px; color: var(--sx-text); }

.sx-alerts-menu { min-width: 320px; max-height: 380px; overflow-y: auto; }
.sx-alerts-head {
    font-weight: 700;
    font-size: 13px;
    color: var(--sx-text);
    padding: 10px 16px 6px;
    border-bottom: 1px solid #eef0f5;
    margin-bottom: 4px;
}
.sx-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13.5px;
    color: var(--sx-text-muted);
    text-decoration: none;
}
.sx-alert-item:hover { background: #f8fafc; color: var(--sx-text); }
.sx-alert-item.unread { color: var(--sx-text); font-weight: 600; }
.sx-alert-item.unread i { color: var(--sx-primary); }
.sx-alert-empty { padding: 16px; text-align: center; color: var(--sx-text-muted); font-size: 13px; }

#logoutform { display: none; }

/* --------------------------------------------------------------------------
   Content
   -------------------------------------------------------------------------- */
.sx-content {
    flex: 1 1 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.sx-content > .container-fluid { flex: 1 1 auto; width: 100%; }

.sx-alert {
    border: 0;
    border-radius: var(--sx-card-radius);
    padding: 14px 18px;
    font-weight: 500;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
}
.alert-success.sx-alert { background: #ecfdf5; color: #065f46; }
.alert-danger.sx-alert { background: #fef2f2; color: #991b1b; }

/* Page action bar (new-style) */
.page-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

/* Cards */
.card {
    border: 0;
    border-radius: var(--sx-card-radius);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
    margin-bottom: 24px;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #f0f1f6;
    font-weight: 700;
    font-size: 15px;
    padding: 16px 20px;
    border-radius: var(--sx-card-radius) var(--sx-card-radius) 0 0 !important;
    color: var(--sx-text);
}
.card-body { padding: 20px; }

/* Forms */
.sx-admin .form-group { margin-bottom: 1.25rem; }
.sx-admin label { font-weight: 600; color: #374151; font-size: 13px; margin-bottom: 6px; }
label.required::after { content: " *"; color: var(--sx-danger); font-weight: 700; }
.form-control {
    border-radius: 10px;
    border: 1px solid #dfe3ec;
    padding: 8px 14px;
    font-size: 14px;
    min-height: 40px;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus {
    border-color: var(--sx-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
textarea.form-control { min-height: 110px; }
.help-block { color: var(--sx-text-muted); font-size: 12px; margin-top: 4px; display: block; }
.form-check-label { font-size: 13.5px !important; font-weight: 500 !important; }
.form-check-inline { margin-inline-end: 16px; }

.select2-container .select2-selection--single {
    height: 40px;
    border: 1px solid #dfe3ec;
    border-radius: 10px;
    padding-top: 6px;
    padding-bottom: 6px;
}
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: var(--sx-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
/* Select2 measures its width once at init; on reflowed/mobile layouts that
   measurement can end up wider than the form column and cause horizontal
   scrolling. Pin in-content select2s to their own column. */
.sx-content .select2-container { width: 100% !important; max-width: 100%; }

/* Dropzone */
.dropzone {
    border: 2px dashed #dbe0ec;
    border-radius: var(--sx-card-radius);
    background: #fafbff;
}
.dropzone.dz-drag-hover { border-color: var(--sx-primary); background: var(--sx-primary-soft); }

/* Buttons */
.btn {
    border-radius: 10px;
    font-weight: 600;
    font-size: 13.5px;
    padding: 8px 16px;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:focus { box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.btn-primary { background: var(--sx-primary); border-color: var(--sx-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--sx-primary-dark); border-color: var(--sx-primary-dark); }
.btn-success { background: var(--sx-success); border-color: var(--sx-success); }
.btn-success:hover { background: #059669; border-color: #059669; }
.btn-info { background: var(--sx-info); border-color: var(--sx-info); }
.btn-info:hover { background: #0284c7; border-color: #0284c7; }
.btn-danger { background: var(--sx-danger); border-color: var(--sx-danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-warning { background: var(--sx-warning); border-color: var(--sx-warning); color: #fff; }
.btn-outline-secondary { border-color: #dfe3ec; color: #475569; }
.btn-outline-secondary:hover { background: #f1f5f9; border-color: #dfe3ec; color: #334155; }
.btn-outline-primary { color: var(--sx-primary); border-color: #c7d2fe; background: var(--sx-primary-soft); }
.btn-outline-primary:hover { background: #e0e7ff; border-color: #6366f1; color: var(--sx-primary-dark); }
.btn-xs, .btn-group-xs > .btn { padding: 3px 10px; font-size: 12px; border-radius: 8px; }
.btn-default { background: #f1f5f9; border-color: #e2e8f0; color: #334155; }
.btn-default:hover { background: #e2e8f0; color: #1f2937; }

/* Tables */
.table { font-size: 13.5px; color: var(--sx-text); }
.table thead th {
    border-top: 0;
    border-bottom: 1px solid #eef0f6;
    color: #64748b;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .06em;
    font-weight: 700;
    background: #f8fafc;
}
.table td, .table th { padding: 10px 14px; vertical-align: middle; }
.table-striped tbody tr:nth-of-type(odd) { background: #fbfcff; }
.table-hover tbody tr:hover { background: var(--sx-primary-soft); }
.table-bordered, .table-bordered td, .table-bordered th { border-color: #eef0f6; }

thead tr.search-row td input.search,
thead tr.search-row td select.search { border-radius: 8px; font-size: 12px; padding: 3px 8px; }

/* Data tables */
.dataTables_wrapper { padding-top: 4px; }
.dataTables_wrapper .dt-buttons { margin-bottom: 12px; }
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid #dfe3ec;
    padding: 6px 10px;
    outline: none;
}
div.dataTables_wrapper div.dataTables_length select {
    border-radius: 8px;
    border: 1px solid #dfe3ec;
    padding: 4px 8px;
}
.datatablesActions .btn, table .btn { margin-bottom: 2px; }

/* Badges */
.badge { font-weight: 600; border-radius: 7px; padding: 5px 9px; font-size: 11.5px; }
.badge-light { background: #f1f5f9; color: #475569; }
.badge-secondary { background: #64748b; color: #fff; }

/* Footer */
.sx-footer {
    border-top: 1px solid #e8ebf3;
    padding: 18px 12px;
    color: var(--sx-text-muted);
    font-size: 12.5px;
}
.sx-footer a { color: var(--sx-primary); }

/* Pagination */
.pagination { gap: 4px; }
.page-item .page-link {
    border: 0;
    border-radius: 8px;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
}
.page-item.active .page-link { background: var(--sx-primary); color: #fff; }
.page-item.disabled .page-link { color: #cbd5e1; }

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */
.sx-hero {
    background: linear-gradient(120deg, var(--sx-primary) 0%, #6d28d9 60%, #8b5cf6 100%);
    border-radius: var(--sx-card-radius);
    color: #fff;
    padding: 26px 30px;
    margin-bottom: 24px;
    box-shadow: 0 14px 34px rgba(79, 70, 229, .35);
}
.sx-hero h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.sx-hero p { margin: 0; opacity: .85; font-size: 13.5px; }
.sx-hero .btn { background: rgba(255,255,255,.16); border: 0; color: #fff; font-weight: 600; }
.sx-hero .btn:hover { background: rgba(255,255,255,.28); }

.sx-kpi-card {
    border: 0;
    border-radius: var(--sx-card-radius);
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 100%;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .12s ease;
}
.sx-kpi-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(15, 23, 42, .08); text-decoration: none; }
.sx-kpi-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
}
.sx-kpi-value { font-size: 24px; font-weight: 800; color: var(--sx-text); line-height: 1.1; }
.sx-kpi-label { font-size: 12.5px; color: var(--sx-text-muted); font-weight: 600; }
.sx-kpi-card .badge-pill { margin-top: 2px; }

.sx-kpi-primary .sx-kpi-icon, .sx-kpi-icon.bg-primary { background: linear-gradient(135deg, #6366f1, #4338ca); }
.sx-kpi-icon.bg-success { background: linear-gradient(135deg, #34d399, #059669); }
.sx-kpi-icon.bg-warning { background: linear-gradient(135deg, #fbbf24, #d97706); }
.sx-kpi-icon.bg-danger { background: linear-gradient(135deg, #f87171, #dc2626); }
.sx-kpi-icon.bg-info { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.sx-kpi-icon.bg-violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); }

/* --------------------------------------------------------------------------
   Traceability report
   -------------------------------------------------------------------------- */
.traceability-card .trace-summary {
    background: #f8fafc;
    border: 1px solid #eef0f6;
    border-radius: var(--sx-card-radius);
    padding: 18px 22px;
}
.trace-summary h4 { font-weight: 800; margin-bottom: 14px; color: var(--sx-text); }
.trace-summary dt { color: var(--sx-text-muted); font-size: 12.5px; font-weight: 600; }
.trace-summary dd { color: var(--sx-text); font-weight: 600; font-size: 13.5px; }
.trace-sheet h5 { font-weight: 700; font-size: 15px; margin: 22px 0 10px; }
.trace-table thead th { font-size: 10.5px; }
.card.traceability-card .card-header { position: static; }
@media print {
    .sx-sidebar, .sx-topbar, .sx-footer, .page-actions, .dataTables_wrapper, .alert { display: none !important; }
    .sx-main-wrapper { margin: 0 !important; }
    .sx-content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #e5e7eb; }
    body { background: #fff; }
}

/* --------------------------------------------------------------------------
   Misc / old-view compat
   -------------------------------------------------------------------------- */
.sx-admin .table-responsive { margin-bottom: 0; }
div.dataTables_wrapper div.actions { min-height: 24px; }
.searchable-results, .searchable-link, .searchable-title, .searchable-fields {
    z-index: 100;
}
.select2-dropdown .searchable-title {
    font-weight: 700; color: var(--sx-primary-dark); font-size: 12px;
}
.select2-dropdown .searchable-fields { color: #374151; font-size: 12.5px; }
.select2-dropdown .searchable-link { padding: 6px 12px; cursor: pointer; background: #fff; }
.select2-dropdown .searchable-link:hover { background: var(--sx-primary-soft); }
div.dataTables_wrapper div.dataTables_info { font-size: 12.5px; color: var(--sx-text-muted); }
.messenger-sublist { list-style: none; }
.treeview .submenu {}

/* login */
.sx-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(120deg, #eef2ff 0%, #f4f6fb 60%, #e0e7ff 100%);
    padding: 24px;
}
.sx-login-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(79, 70, 229, .14);
    width: 100%;
    max-width: 420px;
    padding: 34px 30px;
}
.sx-login-logo { text-align: center; margin-bottom: 22px; }
.sx-login-logo img { max-height: 100px; }
.sx-login h1 { font-size: 19px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.sx-login .sub { text-align: center; color: var(--sx-text-muted); font-size: 13px; margin-bottom: 22px; }
.sx-login .btn-primary { width: 100%; margin-top: 6px; }
.sx-login .form-control:focus { border-color: var(--sx-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
