/**
 * CyberLaw Tracker - UNCTAD Branding
 * Matches unctad.org design system (UN Trade and Development)
 * Font: Inter | Primary: #009EDB
 */

/* ========== UNCTAD Header (unctad.org style) ========== */
.unctad-header {
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1035;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.unctad-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.unctad-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #009EDB;
    font-weight: 700;
    font-size: 1.1rem;
}

.unctad-logo-img {
    height: 40px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
}

.unctad-logo-fallback {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    color: #009EDB;
}

.unctad-top-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.unctad-top-nav a {
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.unctad-top-nav a:hover {
    color: #009EDB;
}

/* ========== UNCTAD Footer (unctad.org style) ========== */
.unctad-footer {
    background: #1a365d;
    color: rgba(255,255,255,0.9);
    padding: 2.5rem 24px 1.5rem;
    margin-top: auto;
}

.unctad-footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
}

.unctad-footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem 2rem;
    margin-bottom: 1rem;
}

.unctad-footer-links a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.unctad-footer-links a:hover {
    color: #fff;
    text-decoration: underline;
}

.unctad-footer-social {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.unctad-footer-social a {
    color: rgba(255,255,255,0.8);
    font-size: 1.2rem;
    transition: color 0.2s;
}

.unctad-footer-social a:hover {
    color: #fff;
}

.unctad-footer-address {
    font-size: 0.85rem;
    line-height: 1.5;
    opacity: 0.9;
    margin-bottom: 0.75rem;
}

.unctad-footer-copy {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* ========== CSS Variables ========== */
:root {
    --unctad-blue: #009EDB;
    --unctad-blue-dark: #0077A8;
    --unctad-blue-light: #E6F4FB;
    --unctad-footer-bg: #1a365d;
    --sidebar-bg: #1a365d;
    --sidebar-hover: #234876;
    --sidebar-active: #2c5282;
    --sidebar-width: 260px;
    --sidebar-text: #a4a6b3;
    --sidebar-text-active: #ffffff;
    --body-bg: #f4f6f9;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.12);
    --transition-speed: 0.25s;
    --border-radius: 10px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ========== Base ========== */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--body-bg);
    color: #333;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.unctad-page-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--unctad-blue);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--unctad-blue-dark);
}

/* ========== Sidebar ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1040;
    overflow-y: auto;
    transition: transform var(--transition-speed);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.sidebar-brand .brand-icon {
    font-size: 2rem;
    color: var(--unctad-blue);
    margin-bottom: 8px;
    display: block;
}

.sidebar-brand .brand-logo {
    color: #fff;
}

.sidebar-brand .unctad-brand-img {
    max-height: 48px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.sidebar-brand .brand-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.sidebar-brand .brand-subtitle {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
}

.sidebar-nav .nav-section {
    padding: 8px 20px 4px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(164, 166, 179, 0.6);
    font-weight: 600;
    margin-top: 8px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 11px 20px;
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-speed);
    border-left: 3px solid transparent;
    margin: 1px 0;
}

.sidebar-nav .nav-link i {
    width: 22px;
    margin-right: 12px;
    font-size: 1rem;
    text-align: center;
    opacity: 0.7;
    transition: opacity var(--transition-speed);
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    border-left-color: rgba(0, 158, 219, 0.3);
}

.sidebar-nav .nav-link:hover i {
    opacity: 1;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--unctad-blue);
}

.sidebar-nav .nav-link.active i {
    opacity: 1;
    color: var(--unctad-blue);
}

/* ========== Grouped Nav Submenus (Data / Management / Tools) ==========
   These expand inline (accordion-style) within the vertical sidebar via
   Bootstrap's Collapse component - no floating/popup menus. */
#sidebarGroupNav {
    display: contents;
}

.sidebar-nav .nav-group-toggle .nav-group-caret {
    width: auto;
    margin-left: auto;
    margin-right: 0;
    opacity: 0.55;
    font-size: 0.72rem;
    transition: transform var(--transition-speed);
}

.sidebar-nav .nav-group-toggle[aria-expanded="true"] .nav-group-caret {
    transform: rotate(180deg);
}

.sidebar-nav .nav-submenu {
    list-style: none;
    margin: 0;
    padding: 2px 0 4px;
}

.sidebar-nav .nav-submenu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px 9px 48px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
    transition: all var(--transition-speed);
}

.sidebar-nav .nav-submenu-item i {
    width: 16px;
    text-align: center;
    opacity: 0.7;
    font-size: 0.85rem;
}

.sidebar-nav .nav-submenu-item:hover,
.sidebar-nav .nav-submenu-item:focus {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav .nav-submenu-item:hover i,
.sidebar-nav .nav-submenu-item:focus i {
    opacity: 1;
}

.sidebar-nav .nav-submenu-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--unctad-blue);
}

.sidebar-nav .nav-submenu-item.active i {
    color: var(--unctad-blue);
    opacity: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-server-info {
    display: flex;
    align-items: center;
    padding: 10px 20px 2px;
    font-size: 0.72rem;
    color: rgba(164, 166, 179, 0.75);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-server-info i {
    width: 22px;
    margin-right: 12px;
    font-size: 0.85rem;
    text-align: center;
    opacity: 0.7;
    flex-shrink: 0;
}

.sidebar-server-info .link-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== Main Content ========== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-speed);
}

.top-navbar {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.top-navbar .page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1d29;
    margin: 0;
}

.top-navbar .navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-navbar .user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-navbar .user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
}

.top-navbar .role-badge {
    font-size: 0.7rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.admin {
    background: rgba(0, 158, 219, 0.12);
    color: var(--unctad-blue);
}

.role-badge.system_admin {
    background: rgba(26, 54, 93, 0.15);
    color: #1a365d;
}

.role-badge.editor {
    background: rgba(111, 66, 193, 0.12);
    color: #6f42c1;
}

/* ========== Nav Layout & Theme Toggle Buttons ========== */
.theme-toggle {
    color: #6c757d;
    font-size: 1rem;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all var(--transition-speed);
}

.theme-toggle:hover {
    color: var(--unctad-blue);
    background: var(--unctad-blue-light);
}

/* Grouped "segmented control" styling for the two independent nav-layout
   controls, so they read as a single tidy toolbar instead of two floating,
   widely-spaced boxes. */
.nav-layout-toggles {
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.02);
}

.sidebar-collapse-toggle,
.nav-orientation-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    color: #6c757d;
    font-size: 0.9rem;
    border: none;
    border-radius: 7px;
    background: transparent;
    transition: all var(--transition-speed);
}

.sidebar-collapse-toggle:hover,
.nav-orientation-toggle:hover {
    color: var(--unctad-blue);
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sidebar-collapse-toggle i {
    transition: transform var(--transition-speed);
}

/* The orientation icon (table-columns) rotates 90deg in horizontal mode so it
   visually reads as rows instead of columns, without swapping icon glyphs. */
.nav-orientation-toggle i {
    transition: transform var(--transition-speed);
}

html[data-nav-layout="horizontal"] .nav-orientation-toggle i {
    transform: rotate(90deg);
}

/* ========== Language Switcher ========== */
.lang-switcher .btn {
    font-size: 0.8rem;
    padding: 4px 10px;
    font-weight: 600;
    border-radius: 6px;
}

.lang-switcher .btn.active-lang {
    background: var(--unctad-blue);
    color: #fff;
    border-color: var(--unctad-blue);
}

/* ========== Cards ========== */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-speed);
    margin-bottom: 24px;
}

.card:hover {
    box-shadow: var(--card-shadow-hover);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 700;
    padding: 16px 20px;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
}

.card-body {
    padding: 20px;
}

/* ========== Stat Cards ========== */
.stat-card {
    border-radius: var(--border-radius);
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
    min-height: 120px;
}

.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.2;
}

.stat-card .stat-number {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== Status Badges ========== */
.badge-status {
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-draft {
    background: #e9ecef;
    color: #6c757d;
}

.badge-pending {
    background: #fff3cd;
    color: #856404;
}

.badge-approved {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-published {
    background: #d4edda;
    color: #155724;
}

/* ========== Value Badges ========== */
.badge-value {
    font-size: 0.8rem;
    padding: 5px 14px;
    border-radius: 20px;
    font-weight: 600;
}

.badge-yes {
    background: #d4edda;
    color: #155724;
}

.badge-no {
    background: #f8d7da;
    color: #721c24;
}

.badge-partial {
    background: #fff3cd;
    color: #856404;
}

.badge-draft-value {
    background: #e9ecef;
    color: #6c757d;
}

/* ========== Tables ========== */
.table {
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 2px solid #e9ecef;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    font-weight: 700;
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 0.9rem;
    border-bottom: 1px solid #f4f4f4;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 158, 219, 0.03);
}

/* ========== Country data accordion (Dashboard: All Data) ========== */
.country-group-header {
    cursor: pointer;
}

.country-group-header .group-caret {
    transition: transform var(--transition-speed);
    color: #6c757d;
    font-size: 0.8rem;
}

.country-group-header[aria-expanded="true"] .group-caret {
    transform: rotate(90deg);
}

.country-group-detail-row > td {
    padding: 0 !important;
}

.country-group-detail-table {
    background-color: #fafbfc;
}

.country-group-detail-table th {
    font-size: 0.75rem;
    padding: 8px 16px 8px 40px;
}

.country-group-detail-table td {
    font-size: 0.85rem;
    padding: 10px 16px;
}

.country-group-detail-table td:first-child {
    padding-left: 40px;
}

/* ========== Forms ========== */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-control:focus, .form-select:focus {
    border-color: var(--unctad-blue);
    box-shadow: 0 0 0 3px rgba(0, 158, 219, 0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #495057;
    margin-bottom: 6px;
}

/* ========== Searchable dropdowns (Tom Select) ========== */
.ts-wrapper {
    width: 100%;
}

.ts-wrapper.form-select-sm .ts-control {
    padding: 5px 10px;
    font-size: 0.85rem;
    min-height: calc(1.5em + 0.5rem + 2px);
}

.ts-control {
    border-radius: 8px !important;
    border-color: #dee2e6 !important;
    padding: 8px 12px !important;
}

.ts-wrapper.focus .ts-control {
    border-color: var(--unctad-blue) !important;
    box-shadow: 0 0 0 3px rgba(0, 158, 219, 0.15) !important;
}

.ts-dropdown {
    border-radius: 8px;
    border-color: #dee2e6;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1071;
}

.ts-dropdown .active {
    background-color: rgba(0, 158, 219, 0.1);
    color: inherit;
}

.ts-control > .item {
    background: var(--unctad-blue-light, rgba(0, 158, 219, 0.12));
    border-radius: 6px;
}

html[data-theme="dark"] .ts-control,
html[data-theme="dark"] .ts-dropdown,
html[data-theme="dark"] .ts-dropdown .ts-dropdown-content {
    background-color: #1e2130;
    color: #e4e6eb;
    border-color: #3a3d4d !important;
}

html[data-theme="dark"] .ts-control input {
    color: #e4e6eb;
}

html[data-theme="dark"] .ts-dropdown .option.active,
html[data-theme="dark"] .ts-dropdown .active {
    background-color: rgba(0, 158, 219, 0.18);
    color: #f0f1f5;
}

html[data-theme="dark"] .ts-control > .item {
    background: rgba(0, 158, 219, 0.2);
    color: #e4e6eb;
}

html[data-theme="dark"] .ts-wrapper.single .ts-control,
html[data-theme="dark"] .ts-wrapper.multi .ts-control.disabled {
    background-color: #1e2130;
}

/* ========== Buttons ========== */
.btn {
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 10px 20px;
    transition: all var(--transition-speed);
    letter-spacing: 0.2px;
}

.btn-primary {
    background: var(--unctad-blue);
    border-color: var(--unctad-blue);
}

.btn-primary:hover {
    background: var(--unctad-blue-dark);
    border-color: var(--unctad-blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 158, 219, 0.3);
}

.btn-outline-primary {
    color: var(--unctad-blue);
    border-color: var(--unctad-blue);
}

.btn-outline-primary:hover {
    background: var(--unctad-blue);
    border-color: var(--unctad-blue);
}

.btn-sm {
    padding: 5px 14px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* ========== Accordion ========== */
.accordion-item {
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius) !important;
    margin-bottom: 12px;
    overflow: hidden;
}

.accordion-button {
    font-weight: 700;
    font-size: 1rem;
    padding: 16px 20px;
    background: #fff;
    color: #1a1d29;
}

.accordion-button:not(.collapsed) {
    background: var(--unctad-blue-light);
    color: var(--unctad-blue-dark);
    box-shadow: none;
}

.accordion-button:focus {
    box-shadow: 0 0 0 3px rgba(0, 158, 219, 0.15);
    border-color: var(--unctad-blue);
}

.accordion-body {
    padding: 24px;
    background: #fafbfc;
}

/* ========== Login / Register Pages ========== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1d29 0%, #2d3250 50%, var(--unctad-blue-dark) 100%);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: none;
    overflow: hidden;
}

.auth-brand {
    text-align: center;
    padding: 32px 20px 24px;
    background: linear-gradient(135deg, var(--unctad-blue) 0%, var(--unctad-blue-dark) 100%);
    color: #fff;
}

.auth-brand .brand-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.auth-brand .brand-name {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.auth-brand .brand-subtitle {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-top: 6px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.auth-body {
    padding: 32px;
}

.auth-body .form-floating {
    margin-bottom: 16px;
}

.auth-footer {
    text-align: center;
    padding: 16px 32px 24px;
    font-size: 0.85rem;
    color: #6c757d;
}

.auth-lang-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
}

.auth-lang-switcher .btn {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
    font-size: 0.75rem;
    padding: 4px 10px;
}

.auth-lang-switcher .btn:hover,
.auth-lang-switcher .btn.active-lang {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

/* ========== Flash Messages ========== */
.flash-message {
    border-radius: var(--border-radius);
    border: none;
    font-weight: 500;
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* ========== Legislation Panel ========== */
.legislation-panel {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--card-shadow);
}

.legislation-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f0f0;
}

.legislation-panel .panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1d29;
}

/* ========== Value Radio Buttons ========== */
.value-radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.value-radio-group .value-option {
    flex: 1;
    min-width: 100px;
}

.value-radio-group .value-option input[type="radio"] {
    display: none;
}

.value-radio-group .value-option label {
    display: block;
    text-align: center;
    padding: 10px 16px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all var(--transition-speed);
    text-transform: capitalize;
}

.value-radio-group .value-option input[type="radio"]:checked + label.label-yes {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.value-radio-group .value-option input[type="radio"]:checked + label.label-no {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.value-radio-group .value-option input[type="radio"]:checked + label.label-partial {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.value-radio-group .value-option input[type="radio"]:checked + label.label-draft {
    background: #e9ecef;
    border-color: #6c757d;
    color: #495057;
}

.value-radio-group .value-option label:hover {
    border-color: var(--unctad-blue);
    transform: translateY(-1px);
}

/* ========== Version Comparison ========== */
.version-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.version-compare .version-panel {
    padding: 20px;
    border-radius: var(--border-radius);
    border: 1px solid #e9ecef;
}

.version-compare .version-panel.old {
    background: #fff8f8;
    border-color: #f5c6cb;
}

.version-compare .version-panel.new {
    background: #f8fff8;
    border-color: #c3e6cb;
}

.version-compare .version-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid currentColor;
}

.version-compare .version-panel.old .version-label {
    color: #dc3545;
}

.version-compare .version-panel.new .version-label {
    color: #28a745;
}

.changed-field {
    background: #fffde7;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #ffeb3b;
}

/* ========== Notification Card ========== */
.notification-card {
    border-left: 4px solid var(--unctad-blue);
    background: var(--unctad-blue-light);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    padding: 16px 20px;
    margin-bottom: 12px;
}

.notification-card .notification-title {
    font-weight: 700;
    color: #1a1d29;
    margin-bottom: 6px;
}

.notification-card .notification-date {
    font-size: 0.8rem;
    color: #6c757d;
}

/* ========== Pagination ========== */
.pagination .page-link {
    color: var(--unctad-blue);
    border-radius: 6px;
    margin: 0 2px;
    font-weight: 600;
    font-size: 0.85rem;
}

.pagination .page-item.active .page-link {
    background: var(--unctad-blue);
    border-color: var(--unctad-blue);
}

/* ========== Copy Button ========== */
.copy-btn {
    cursor: pointer;
    transition: all var(--transition-speed);
}

.copy-btn:hover {
    color: var(--unctad-blue);
}

.copy-btn.copied {
    color: #28a745;
}

/* ========== Tab Navigation ========== */
.nav-tabs .nav-link {
    font-weight: 600;
    color: #6c757d;
    border: none;
    padding: 12px 20px;
    transition: all var(--transition-speed);
}

.nav-tabs .nav-link:hover {
    color: var(--unctad-blue);
    border-bottom: 2px solid var(--unctad-blue);
}

.nav-tabs .nav-link.active {
    color: var(--unctad-blue);
    border-bottom: 3px solid var(--unctad-blue);
    background: transparent;
}

/* ========== API Documentation ========== */
.api-docs code {
    background: #1a1d29;
    color: #e6e6e6;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.api-docs pre {
    background: #1a1d29;
    color: #e6e6e6;
    padding: 20px;
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.6;
}

.api-endpoint {
    background: var(--unctad-blue-light);
    border: 1px solid var(--unctad-blue);
    border-radius: var(--border-radius);
    padding: 16px 20px;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-weight: 600;
    color: var(--unctad-blue-dark);
}

/* ========== Responsive ========== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block !important;
    }
}

@media (min-width: 992px) {
    .sidebar-toggle {
        display: none !important;
    }
}

@media (max-width: 767.98px) {
    .stat-card .stat-number {
        font-size: 1.6rem;
    }

    .version-compare {
        grid-template-columns: 1fr;
    }

    .value-radio-group {
        flex-direction: column;
    }

    .top-navbar {
        padding: 10px 16px;
    }

    .top-navbar .page-title {
        font-size: 1rem;
    }
}

/* ========== Animations ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.card, .stat-card, .legislation-panel {
    animation: fadeIn 0.3s ease-out;
}

/* ========== Scrollbar ========== */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* ========== Action-required / deadline banner (editor dashboard) ========== */
.action-banner .action-banner-icon {
    font-size: 1.6rem;
    line-height: 1;
    margin-top: 2px;
}

.action-banner-pending {
    border-left: 4px solid #ffc107;
}

.action-banner-pending .action-banner-icon {
    color: #e0a800;
}

.action-banner-complete {
    border-left: 4px solid #28a745;
}

.action-banner-complete .action-banner-icon {
    color: #28a745;
}

/* ========== Section guidance box (edit country data form) ========== */
.section-guidance {
    background: var(--unctad-blue-light);
    border-radius: 8px;
    padding: 12px 16px;
    border-left: 3px solid var(--unctad-blue);
}

/* ========== Repeatable law rows (multiple laws per legislation area) ========== */
.law-row {
    background: #fff;
}

.law-row .law-row-number {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-law-row {
    margin-top: -4px;
}

.law-fields.law-fields-disabled {
    opacity: 0.55;
}

.law-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.law-input-wrap .law-input-wrap-field {
    flex: 1 1 auto;
    min-width: 0;
}

.law-input-wrap .law-missing-warning {
    display: none;
    flex: 0 0 auto;
    color: #dc3545;
    font-size: 1rem;
    line-height: 1;
}

.law-input-wrap.has-warning .law-missing-warning {
    display: inline-flex;
    align-items: center;
}

.law-input-wrap.has-warning .form-control {
    border-color: #dc3545;
}

.focus-panel .accordion-button {
    box-shadow: inset 3px 0 0 var(--unctad-blue);
}

/* ========== Contact / support widget ========== */
.contact-support-bar {
    background: #fff;
    border-top: 1px solid #e9ecef;
    padding: 14px 24px;
    font-size: 0.9rem;
    font-weight: 500;
}

.contact-support-bar a {
    color: var(--unctad-blue-dark);
}

.contact-support-bar a:hover {
    text-decoration: underline;
}

/* ========== Print Styles ========== */
@media print {
    .sidebar, .top-navbar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }
}

/* ==========================================================================
   Collapsed Sidebar (vertical layout, desktop only)
   ========================================================================== */
@media (min-width: 992px) {
    html[data-nav-layout="collapsed"] .sidebar {
        width: 76px;
    }

    html[data-nav-layout="collapsed"] .sidebar-brand {
        padding: 20px 8px 14px;
    }

    html[data-nav-layout="collapsed"] .sidebar-brand .brand-name,
    html[data-nav-layout="collapsed"] .sidebar-brand .brand-subtitle {
        display: none;
    }

    html[data-nav-layout="collapsed"] .sidebar-nav .nav-link {
        justify-content: center;
        padding: 12px 8px;
    }

    html[data-nav-layout="collapsed"] .sidebar-nav .nav-link i {
        margin-right: 0;
        font-size: 1.1rem;
    }

    html[data-nav-layout="collapsed"] .sidebar-nav .nav-link .link-text {
        display: none;
    }

    html[data-nav-layout="collapsed"] .sidebar-nav .nav-group-caret {
        display: none;
    }

    /* Not enough room for sub-item labels in the icon rail; clicking a group
       switches back to the expanded layout (see app.js), where it then opens
       inline as usual. */
    html[data-nav-layout="collapsed"] .sidebar-nav .nav-submenu {
        display: none !important;
    }

    html[data-nav-layout="collapsed"] .sidebar-server-info {
        justify-content: center;
        padding: 10px 8px 2px;
    }

    html[data-nav-layout="collapsed"] .sidebar-server-info i {
        margin-right: 0;
    }

    html[data-nav-layout="collapsed"] .sidebar-server-info .link-text {
        display: none;
    }

    html[data-nav-layout="collapsed"] .main-content {
        margin-left: 76px;
    }
}

/* ==========================================================================
   Horizontal Navigation Layout (desktop only)
   ========================================================================== */
@media (min-width: 992px) {
    html[data-nav-layout="horizontal"] .sidebar {
        position: static;
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: stretch;
        overflow: visible;
        z-index: 1031;
    }

    html[data-nav-layout="horizontal"] .sidebar-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        white-space: nowrap;
        padding: 10px 20px;
        border-bottom: none;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
        text-align: left;
    }

    html[data-nav-layout="horizontal"] .sidebar-brand .brand-icon {
        margin-bottom: 0;
    }

    html[data-nav-layout="horizontal"] .sidebar-brand .brand-subtitle {
        display: none;
    }

    html[data-nav-layout="horizontal"] .sidebar-nav {
        position: relative;
        flex: 1;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        padding: 4px 8px;
        overflow: visible;
    }

    html[data-nav-layout="horizontal"] .sidebar-nav .nav-group {
        display: flex;
        position: static;
    }

    html[data-nav-layout="horizontal"] .sidebar-nav .nav-link {
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        margin: 0 2px;
    }

    html[data-nav-layout="horizontal"] .sidebar-nav .nav-group-caret {
        margin-left: 8px;
    }

    /* Instead of a small flyout near the toggle, the submenu expands as a
       full-width panel directly below the entire horizontal bar. */
    html[data-nav-layout="horizontal"] .sidebar-nav .nav-submenu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        flex-wrap: wrap;
        gap: 4px;
        padding: 10px 20px;
        margin: 0;
        background: var(--sidebar-bg);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
        z-index: 1032;
    }

    html[data-nav-layout="horizontal"] .sidebar-nav .nav-submenu.show,
    html[data-nav-layout="horizontal"] .sidebar-nav .nav-submenu.collapsing {
        display: flex;
    }

    html[data-nav-layout="horizontal"] .sidebar-nav .nav-submenu-item {
        padding: 9px 14px;
        border-left: none;
        border-radius: 6px;
        flex: 0 0 auto;
    }

    html[data-nav-layout="horizontal"] .sidebar-nav .nav-link:hover {
        border-left-color: transparent;
        border-bottom-color: rgba(0, 158, 219, 0.3);
    }

    html[data-nav-layout="horizontal"] .sidebar-nav .nav-link.active {
        border-left-color: transparent;
        border-bottom-color: var(--unctad-blue);
    }

    html[data-nav-layout="horizontal"] .sidebar-footer {
        margin-top: 0;
        margin-left: auto;
        padding: 0 4px;
        border-top: none;
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }

    html[data-nav-layout="horizontal"] .sidebar-server-info {
        padding: 0 12px;
    }

    html[data-nav-layout="horizontal"] .main-content {
        margin-left: 0;
    }
}

/* ==========================================================================
   Dark Mode
   Bootstrap's own data-bs-theme="dark" handles most component colors
   automatically (cards, tables, forms, modals, dropdowns, alerts, badges).
   The overrides below cover this app's custom, hard-coded-color classes.
   ========================================================================== */
html[data-theme="dark"] {
    --body-bg: #12141c;
    --unctad-blue-light: rgba(0, 158, 219, 0.12);
    color-scheme: dark;
}

html[data-theme="dark"] body {
    color: #e4e6eb;
}

html[data-theme="dark"] .unctad-header {
    background: #1a1d29;
    border-bottom-color: #2a2d3a;
}

html[data-theme="dark"] .top-navbar {
    background: #1a1d29;
    border-bottom-color: #2a2d3a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .top-navbar .page-title {
    color: #f0f1f5;
}

html[data-theme="dark"] .top-navbar .user-name {
    color: #e4e6eb;
}

html[data-theme="dark"] .sidebar-collapse-toggle,
html[data-theme="dark"] .nav-orientation-toggle,
html[data-theme="dark"] .theme-toggle {
    color: #a4a6b3;
}

html[data-theme="dark"] .nav-layout-toggles {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .sidebar-collapse-toggle:hover,
html[data-theme="dark"] .nav-orientation-toggle:hover {
    color: var(--unctad-blue);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

html[data-theme="dark"] .theme-toggle:hover {
    color: var(--unctad-blue);
    background: rgba(0, 158, 219, 0.12);
}

html[data-theme="dark"] .card-header {
    background: #1e2130;
    border-bottom-color: #2a2d3a;
    color: #e4e6eb;
}

html[data-theme="dark"] .legislation-panel {
    background: #1a1d29;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .legislation-panel .panel-header {
    border-bottom-color: #2a2d3a;
}

html[data-theme="dark"] .legislation-panel .panel-title {
    color: #f0f1f5;
}

html[data-theme="dark"] .section-guidance {
    background: rgba(0, 158, 219, 0.1);
}

html[data-theme="dark"] .law-row {
    background: #1a1d29;
}

html[data-theme="dark"] .law-input-wrap.has-warning .form-control {
    border-color: #dc3545;
}

html[data-theme="dark"] .value-radio-group .value-option label {
    border-color: #3a3d4d;
    color: #cfd1db;
}

html[data-theme="dark"] .notification-card {
    background: rgba(0, 158, 219, 0.1);
}

html[data-theme="dark"] .notification-card .notification-title {
    color: #f0f1f5;
}

html[data-theme="dark"] .accordion-button {
    background: #1e2130;
    color: #e4e6eb;
}

html[data-theme="dark"] .accordion-button:not(.collapsed) {
    background: rgba(0, 158, 219, 0.12);
    color: #7cd0f5;
}

html[data-theme="dark"] .accordion-body {
    background: #161822;
}

html[data-theme="dark"] .contact-support-bar {
    background: #1a1d29;
    border-top-color: #2a2d3a;
}

html[data-theme="dark"] .version-compare .version-panel.old {
    background: rgba(220, 53, 69, 0.08);
}

html[data-theme="dark"] .version-compare .version-panel.new {
    background: rgba(40, 167, 69, 0.08);
}

html[data-theme="dark"] .changed-field {
    background: rgba(255, 235, 59, 0.15);
    border-color: rgba(255, 235, 59, 0.4);
    color: #f0f1f5;
}

html[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(0, 158, 219, 0.08);
}

html[data-theme="dark"] .country-group-detail-table {
    background-color: rgba(255, 255, 255, 0.02);
}

html[data-theme="dark"] .table thead th {
    color: #9aa0ab;
    border-bottom-color: #2a2d3a;
}

html[data-theme="dark"] .table tbody td {
    border-bottom-color: #262a38;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
    border-color: #3a3d4d;
}

html[data-theme="dark"] .form-label {
    color: #cfd1db;
}

/* Many pages hard-code Bootstrap's non-theme-aware bg-white/bg-light utilities
   (e.g. class="card-header bg-white") which force a literal white/light
   background via !important. Combined with the dark-mode text color, that
   made headers and panels unreadable (light text on white). Re-skin them
   for dark mode, but leave small badges/status chips (which pair bg-light
   with an explicit text-dark) and the MFA QR code box (needs true white
   for scannability) untouched. */
html[data-theme="dark"] .card-header.bg-white,
html[data-theme="dark"] .card-footer.bg-white {
    background-color: #1e2130 !important;
    color: #e4e6eb;
    border-color: #2a2d3a;
}

html[data-theme="dark"] .card.bg-light {
    background-color: #1e2130 !important;
    color: #e4e6eb;
}

html[data-theme="dark"] code.bg-light {
    background-color: #1e2130 !important;
    color: #e4e6eb !important;
}

html[data-theme="dark"] #cyberlaw-map {
    background: #1a1d29 !important;
}

/* ========== System-admin bulk-edit spreadsheet ========== */
.bulk-edit-wrap {
    overflow: auto;
    max-height: calc(100vh - 340px);
    border: 1px solid #e5e5e5;
    border-radius: var(--border-radius);
    background: #fff;
}

.bulk-edit-table {
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    min-width: max-content;
}

.bulk-edit-table thead th {
    position: sticky;
    z-index: 3;
    background: #f8f9fa;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    padding: 8px 10px;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 1px 0 #dee2e6;
}

.bulk-edit-table thead .be-group-row th {
    top: 0;
}

.bulk-edit-table thead .be-subhead-row th {
    top: 34px;
    font-weight: 600;
    color: #6c757d;
}

.bulk-edit-table .be-group-head {
    border-left: 1px solid #dee2e6;
    background: #eef6fb;
    color: #0a4d6b;
}

.bulk-edit-table tbody td {
    padding: 2px 4px;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
    border-right: 1px solid #f4f4f4;
}

.bulk-edit-table .be-col-country {
    min-width: 220px;
    max-width: 260px;
    left: 0;
}

.bulk-edit-table .be-col-code {
    min-width: 56px;
    left: 220px;
    text-align: center;
    font-variant: tabular-nums;
}

.bulk-edit-table th.be-sticky,
.bulk-edit-table td.be-sticky,
.bulk-edit-table th.be-sticky-2,
.bulk-edit-table td.be-sticky-2 {
    position: sticky;
    z-index: 2;
    background: #fff;
}

.bulk-edit-table thead th.be-sticky,
.bulk-edit-table thead th.be-sticky-2 {
    z-index: 5;
    background: #f8f9fa;
}

.bulk-edit-table tbody td.be-sticky,
.bulk-edit-table tbody td.be-sticky-2 {
    box-shadow: 1px 0 0 #ececec;
}

.bulk-edit-table .be-cell-value {
    min-width: 118px;
    border-left: 1px solid #dee2e6;
}

.bulk-edit-table .be-cell-text {
    min-width: 180px;
}

.bulk-edit-table.be-compact .be-detail {
    display: none;
}

.bulk-edit-table .be-input {
    border: 1px solid transparent;
    background: transparent;
    box-shadow: none;
    font-size: 0.8rem;
    padding: 4px 6px;
    min-height: 30px;
}

.bulk-edit-table .be-input:hover {
    border-color: #ced4da;
    background: #fff;
}

.bulk-edit-table .be-input:focus {
    border-color: var(--unctad-blue);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(0, 158, 219, 0.15);
}

.bulk-edit-table .be-value-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.bulk-edit-table .be-value-select {
    font-weight: 600;
}

.bulk-edit-table .be-value-select[data-value="yes"] {
    background: #d1e7dd;
    color: #0f5132;
}

.bulk-edit-table .be-value-select[data-value="no"] {
    background: #f8d7da;
    color: #842029;
}

.bulk-edit-table .be-value-select[data-value="partial"] {
    background: #fff3cd;
    color: #664d03;
}

.bulk-edit-table .be-value-select[data-value="draft"] {
    background: #e2e3e5;
    color: #41464b;
}

.bulk-edit-table .be-pdf-icon {
    color: #dc3545;
    font-size: 0.75rem;
}

.bulk-edit-table .be-cell.be-dirty {
    background: #fff8e1;
}

.bulk-edit-table tbody tr:hover td.be-sticky,
.bulk-edit-table tbody tr:hover td.be-sticky-2 {
    background: #f7fbfe;
}

html[data-theme="dark"] .bulk-edit-wrap {
    background: #1e2130;
    border-color: #2a2d3a;
}

html[data-theme="dark"] .bulk-edit-table thead th,
html[data-theme="dark"] .bulk-edit-table thead th.be-sticky,
html[data-theme="dark"] .bulk-edit-table thead th.be-sticky-2 {
    background: #252836;
    border-bottom-color: #2a2d3a;
    box-shadow: 0 1px 0 #2a2d3a;
}

html[data-theme="dark"] .bulk-edit-table .be-group-head {
    background: #1a3348;
    color: #9ad8f0;
    border-left-color: #2a2d3a;
}

html[data-theme="dark"] .bulk-edit-table tbody td {
    border-bottom-color: #262a38;
    border-right-color: #262a38;
}

html[data-theme="dark"] .bulk-edit-table .be-cell-value {
    border-left-color: #2a2d3a;
}

html[data-theme="dark"] .bulk-edit-table th.be-sticky,
html[data-theme="dark"] .bulk-edit-table td.be-sticky,
html[data-theme="dark"] .bulk-edit-table th.be-sticky-2,
html[data-theme="dark"] .bulk-edit-table td.be-sticky-2,
html[data-theme="dark"] .bulk-edit-table tbody td.be-sticky,
html[data-theme="dark"] .bulk-edit-table tbody td.be-sticky-2 {
    background: #1e2130;
}

html[data-theme="dark"] .bulk-edit-table tbody tr:hover td.be-sticky,
html[data-theme="dark"] .bulk-edit-table tbody tr:hover td.be-sticky-2 {
    background: #252a3a;
}

html[data-theme="dark"] .bulk-edit-table .be-input:hover,
html[data-theme="dark"] .bulk-edit-table .be-input:focus {
    background: #252836;
    border-color: #3a3d4d;
}

html[data-theme="dark"] .bulk-edit-table .be-cell.be-dirty {
    background: rgba(255, 193, 7, 0.12);
}

html[data-theme="dark"] .bulk-edit-table .be-value-select[data-value="yes"] {
    background: rgba(25, 135, 84, 0.25);
    color: #75b798;
}

html[data-theme="dark"] .bulk-edit-table .be-value-select[data-value="no"] {
    background: rgba(220, 53, 69, 0.25);
    color: #ea868f;
}

html[data-theme="dark"] .bulk-edit-table .be-value-select[data-value="partial"] {
    background: rgba(255, 193, 7, 0.2);
    color: #ffda6a;
}

html[data-theme="dark"] .bulk-edit-table .be-value-select[data-value="draft"] {
    background: rgba(108, 117, 125, 0.3);
    color: #c5c7cb;
}
