/* ====================================
   econstitucional - Design System
   Inspired by Cloudscape Design Foundation
   ==================================== */

/* ====================================
   Design Tokens - Light Theme (Default)
   ==================================== */
:root {
    /* === Typography === */
    --font-family-base: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-family-mono: Monaco, Menlo, Consolas, 'Courier Prime', Courier, 'Courier New', monospace;

    /* Font sizes (Cloudscape scale) */
    --font-size-body-s: 12px;
    --font-size-body-m: 14px;
    --font-size-heading-xs: 14px;
    --font-size-heading-s: 16px;
    --font-size-heading-m: 18px;
    --font-size-heading-l: 20px;
    --font-size-heading-xl: 24px;
    --font-size-display-l: 42px;

    /* Line heights */
    --line-height-body-s: 16px;
    --line-height-body-m: 20px;
    --line-height-heading-xs: 18px;
    --line-height-heading-s: 20px;
    --line-height-heading-m: 22px;
    --line-height-heading-l: 24px;
    --line-height-heading-xl: 30px;

    /* Font weights */
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-bold: 700;
    --font-weight-heavy: 900;

    /* === Spacing (4px base unit) === */
    --space-xxxs: 2px;
    --space-xxs: 4px;
    --space-xs: 8px;
    --space-s: 12px;
    --space-m: 16px;
    --space-l: 20px;
    --space-xl: 24px;
    --space-xxl: 32px;
    --space-xxxl: 40px;

    /* === Border radius === */
    --border-radius-s: 4px;
    --border-radius-m: 8px;
    --border-radius-l: 12px;
    --border-radius-xl: 16px;
    --border-radius-pill: 9999px;

    /* === Transitions === */
    --motion-duration-fast: 90ms;
    --motion-duration-normal: 180ms;
    --motion-duration-slow: 270ms;
    --motion-easing-default: cubic-bezier(0.165, 0.84, 0.44, 1);

    /* === Light Theme Colors === */
    /* Background colors */
    --color-background-layout-main: #ffffff;
    --color-background-container-content: #ffffff;
    --color-background-container-header: #fafafa;
    --color-background-input-default: #ffffff;
    --color-background-input-disabled: #e9ebed;
    --color-background-item-hover: #f4f4f4;
    --color-background-item-selected: #e9f3ff;
    --color-background-dropdown: #ffffff;
    --color-background-notification-blue: #e9f3ff;
    --color-background-status-success: #d5f4e6;
    --color-background-status-error: #fce9e9;
    --color-background-status-warning: #fff7e6;
    --color-background-modal-overlay: rgba(0, 7, 22, 0.7);

    /* Text colors */
    --color-text-body-default: #16191f;
    --color-text-body-secondary: #5f6b7a;
    --color-text-heading-default: #16191f;
    --color-text-heading-secondary: #414d5c;
    --color-text-interactive-default: #0972d3;
    --color-text-interactive-hover: #033160;
    --color-text-interactive-active: #033160;
    --color-text-link-default: #0972d3;
    --color-text-link-hover: #033160;
    --color-text-inverted: #ffffff;
    --color-text-label: #16191f;
    --color-text-placeholder: #5f6b7a;
    --color-text-disabled: #9ba7b6;
    --color-text-status-error: #d91515;
    --color-text-status-success: #037f0c;
    --color-text-status-warning: #8d6605;

    /* Border colors */
    --color-border-container-default: #e9ebed;
    --color-border-divider-default: #e9ebed;
    --color-border-input-default: #7d8998;
    --color-border-input-focus: #0972d3;
    --color-border-item-hover: #7d8998;
    --color-border-item-selected: #0972d3;
    --color-border-status-error: #d91515;
    --color-border-status-success: #037f0c;

    /* Primary/Brand colors */
    --color-primary-default: #0972d3;
    --color-primary-hover: #033160;
    --color-primary-active: #033160;
    --color-primary-subtle: #e9f3ff;

    /* Status colors */
    --color-status-success: #037f0c;
    --color-status-error: #d91515;
    --color-status-warning: #8d6605;
    --color-status-info: #0972d3;

    /* Shadow colors */
    --color-shadow-default: rgba(0, 7, 22, 0.12);
    --color-shadow-medium: rgba(0, 7, 22, 0.12);

    /* Shadows */
    --shadow-container: 0 1px 1px 0 var(--color-shadow-default), 0 1px 8px 0 var(--color-shadow-medium);
    --shadow-dropdown: 0 4px 20px var(--color-shadow-default);
    --shadow-sticky: 0 4px 8px var(--color-shadow-default);
    --shadow-modal: 0 4px 20px var(--color-shadow-default);
    --shadow-popover: 0 4px 20px var(--color-shadow-default);

    /* Focus ring */
    --color-border-item-focused: #0972d3;
    --shadow-focus-ring: 0 0 0 2px var(--color-border-item-focused);
}

/* ====================================
   Dark Theme Tokens
   ==================================== */
[data-theme="dark"],
.awsui-dark-mode {
    /* Background colors - Dark */
    --color-background-layout-main: #0f1b2a;
    --color-background-container-content: #1a242e;
    --color-background-container-header: #232f3e;
    --color-background-input-default: #1a242e;
    --color-background-input-disabled: #232f3e;
    --color-background-item-hover: #232f3e;
    --color-background-item-selected: #0f1b2a;
    --color-background-dropdown: #1a242e;
    --color-background-notification-blue: #0f1b2a;
    --color-background-status-success: #0a2816;
    --color-background-status-error: #2a0d0d;
    --color-background-status-warning: #2a1d0a;
    --color-background-modal-overlay: rgba(0, 0, 0, 0.85);

    /* Text colors - Dark */
    --color-text-body-default: #d1d5db;
    --color-text-body-secondary: #8d99a8;
    --color-text-heading-default: #e9ebed;
    --color-text-heading-secondary: #b4bfc9;
    --color-text-interactive-default: #539fe5;
    --color-text-interactive-hover: #89bcf0;
    --color-text-interactive-active: #89bcf0;
    --color-text-link-default: #539fe5;
    --color-text-link-hover: #89bcf0;
    --color-text-inverted: #0f1b2a;
    --color-text-label: #d1d5db;
    --color-text-placeholder: #8d99a8;
    --color-text-disabled: #5f6b7a;
    --color-text-status-error: #ff8888;
    --color-text-status-success: #6aaf6d;
    --color-text-status-warning: #f5b942;

    /* Border colors - Dark */
    --color-border-container-default: #354150;
    --color-border-divider-default: #354150;
    --color-border-input-default: #5f6b7a;
    --color-border-input-focus: #539fe5;
    --color-border-item-hover: #7d8998;
    --color-border-item-selected: #539fe5;
    --color-border-status-error: #ff8888;
    --color-border-status-success: #6aaf6d;

    /* Primary colors - Dark */
    --color-primary-default: #539fe5;
    --color-primary-hover: #89bcf0;
    --color-primary-active: #89bcf0;
    --color-primary-subtle: #0f1b2a;

    /* Status colors - Dark */
    --color-status-success: #6aaf6d;
    --color-status-error: #ff8888;
    --color-status-warning: #f5b942;
    --color-status-info: #539fe5;

    /* Shadow colors - Dark */
    --color-shadow-default: rgba(0, 0, 0, 0.5);
    --color-shadow-medium: rgba(0, 0, 0, 0.5);
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        /* Background colors - Dark */
        --color-background-layout-main: #0f1b2a;
        --color-background-container-content: #1a242e;
        --color-background-container-header: #232f3e;
        --color-background-input-default: #1a242e;
        --color-background-input-disabled: #232f3e;
        --color-background-item-hover: #232f3e;
        --color-background-item-selected: #0f1b2a;
        --color-background-dropdown: #1a242e;
        --color-background-notification-blue: #0f1b2a;
        --color-background-status-success: #0a2816;
        --color-background-status-error: #2a0d0d;
        --color-background-status-warning: #2a1d0a;
        --color-background-modal-overlay: rgba(0, 0, 0, 0.85);

        /* Text colors - Dark */
        --color-text-body-default: #d1d5db;
        --color-text-body-secondary: #8d99a8;
        --color-text-heading-default: #e9ebed;
        --color-text-heading-secondary: #b4bfc9;
        --color-text-interactive-default: #539fe5;
        --color-text-interactive-hover: #89bcf0;
        --color-text-interactive-active: #89bcf0;
        --color-text-link-default: #539fe5;
        --color-text-link-hover: #89bcf0;
        --color-text-inverted: #0f1b2a;
        --color-text-label: #d1d5db;
        --color-text-placeholder: #8d99a8;
        --color-text-disabled: #5f6b7a;
        --color-text-status-error: #ff8888;
        --color-text-status-success: #6aaf6d;
        --color-text-status-warning: #f5b942;

        /* Border colors - Dark */
        --color-border-container-default: #354150;
        --color-border-divider-default: #354150;
        --color-border-input-default: #5f6b7a;
        --color-border-input-focus: #539fe5;
        --color-border-item-hover: #7d8998;
        --color-border-item-selected: #539fe5;
        --color-border-status-error: #ff8888;
        --color-border-status-success: #6aaf6d;

        /* Primary colors - Dark */
        --color-primary-default: #539fe5;
        --color-primary-hover: #89bcf0;
        --color-primary-active: #89bcf0;
        --color-primary-subtle: #0f1b2a;

        /* Status colors - Dark */
        --color-status-success: #6aaf6d;
        --color-status-error: #ff8888;
        --color-status-warning: #f5b942;
        --color-status-info: #539fe5;

        /* Shadow colors - Dark */
        --color-shadow-default: rgba(0, 0, 0, 0.5);
        --color-shadow-medium: rgba(0, 0, 0, 0.5);
    }
}

/* ====================================
   Base Styles
   ==================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family-base);
    font-size: var(--font-size-body-m);
    line-height: var(--line-height-body-m);
    font-weight: var(--font-weight-normal);
    color: var(--color-text-body-default);
    background-color: var(--color-background-layout-main);
    margin: 0;
    transition: background-color var(--motion-duration-normal) var(--motion-easing-default),
                color var(--motion-duration-normal) var(--motion-easing-default);
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    color: var(--color-text-heading-default);
    font-weight: var(--font-weight-bold);
    margin: 0 0 var(--space-m);
}

h1 {
    font-size: var(--font-size-heading-xl);
    line-height: var(--line-height-heading-xl);
}

h2 {
    font-size: var(--font-size-heading-l);
    line-height: var(--line-height-heading-l);
}

h3 {
    font-size: var(--font-size-heading-m);
    line-height: var(--line-height-heading-m);
}

h4 {
    font-size: var(--font-size-heading-s);
    line-height: var(--line-height-heading-s);
}

h5, h6 {
    font-size: var(--font-size-heading-xs);
    line-height: var(--line-height-heading-xs);
}

/* Text utilities */
.text-muted {
    color: var(--color-text-body-secondary) !important;
}

.text-body {
    color: var(--color-text-body-default) !important;
}

/* Links */
a {
    color: var(--color-text-link-default);
    text-decoration: none;
    transition: color var(--motion-duration-fast) var(--motion-easing-default);
}

a:hover {
    color: var(--color-text-link-hover);
    text-decoration: underline;
}

/* ====================================
   Navbar
   ==================================== */
.navbar {
    background: var(--color-primary-default) !important;
    padding: var(--space-s) 0;
    box-shadow: var(--shadow-sticky);
    transition: background-color var(--motion-duration-normal) var(--motion-easing-default);
}

.navbar-brand {
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-heading-m);
    color: var(--color-text-inverted) !important;
}

.navbar-brand i {
    font-size: var(--font-size-heading-l);
}

.nav-link {
    font-weight: var(--font-weight-medium);
    padding: var(--space-xs) var(--space-m) !important;
    border-radius: var(--border-radius-m);
    color: var(--color-text-inverted) !important;
    opacity: 0.9;
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    opacity: 1;
}

/* Theme Toggle Button */
.theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--color-text-inverted);
    padding: var(--space-xs) var(--space-s);
    border-radius: var(--border-radius-m);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-body-s);
    font-weight: var(--font-weight-medium);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.theme-toggle i {
    font-size: var(--font-size-body-m);
}

/* ====================================
   Mobile Drawer (Offcanvas)
   ==================================== */
.offcanvas {
    background-color: var(--color-background-container-content);
    border-left: 1px solid var(--color-border-container-default);
}

.offcanvas-header {
    background-color: var(--color-primary-default);
    color: #ffffff;
    padding: var(--space-m) var(--space-l);
}

.offcanvas-title {
    color: #ffffff;
    font-weight: var(--font-weight-bold);
}

.offcanvas-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.offcanvas-body {
    padding: var(--space-l);
}

.offcanvas-body .navbar-nav {
    gap: var(--space-xs);
}

.offcanvas-body .nav-link {
    color: #16191f !important;
    padding: var(--space-s) var(--space-m);
    border-radius: var(--border-radius-m);
    font-size: var(--font-size-body-m);
    font-weight: var(--font-weight-medium);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
    background-color: #f4f4f4;
}

.offcanvas-body .nav-link:hover {
    background-color: #e9ebed !important;
}

.offcanvas-body .nav-link.active {
    background-color: #e9f3ff !important;
    color: #0972d3 !important;
    font-weight: var(--font-weight-bold);
}

.offcanvas-body .nav-link i {
    color: #414d5c !important;
}

.offcanvas-body .nav-link.active i {
    color: #0972d3 !important;
}

/* Dark mode drawer text */
[data-theme="dark"] .offcanvas-body .nav-link {
    color: #d1d5db !important;
    background-color: #232f3e;
}

[data-theme="dark"] .offcanvas-body .nav-link:hover {
    background-color: #354150 !important;
}

[data-theme="dark"] .offcanvas-body .nav-link.active {
    background-color: #0f1b2a !important;
    color: #539fe5 !important;
}

[data-theme="dark"] .offcanvas-body .nav-link i {
    color: #8d99a8 !important;
}

[data-theme="dark"] .offcanvas-body .nav-link.active i {
    color: #539fe5 !important;
}

.offcanvas-body hr {
    border-color: var(--color-border-divider-default);
    margin: var(--space-l) 0;
}

.offcanvas-body .theme-toggle {
    background: #f4f4f4;
    border: 1px solid #e9ebed;
    color: #16191f;
    justify-content: center;
}

.offcanvas-body .theme-toggle:hover {
    background: #e9ebed;
}

.offcanvas-body .theme-toggle i {
    color: #414d5c;
}

/* Dark mode drawer theme toggle */
[data-theme="dark"] .offcanvas-body .theme-toggle {
    background: var(--color-background-item-hover);
    border-color: var(--color-border-container-default);
    color: var(--color-text-body-default);
}

[data-theme="dark"] .offcanvas-body .theme-toggle:hover {
    background: var(--color-background-item-selected);
}

[data-theme="dark"] .offcanvas-body .theme-toggle i {
    color: var(--color-text-body-secondary);
}

/* ====================================
   Main Section
   ==================================== */
.main-section {
    padding-top: 120px;
    padding-bottom: var(--space-xxl);
    min-height: 100vh;
}

.section-title {
    font-size: var(--font-size-heading-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-heading-default);
    margin-bottom: 0;
}

.cpe-reference {
    font-size: var(--font-size-body-s);
    color: var(--color-text-body-secondary);
    margin-top: var(--space-xs);
    margin-bottom: 0;
}

/* ====================================
   Search Box
   ==================================== */
.search-box {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border-input-default);
    border-radius: var(--border-radius-m);
    padding: 0 var(--space-m);
    height: 48px;
    background: var(--color-background-input-default);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.search-box:focus-within {
    border-color: var(--color-border-input-focus);
    box-shadow: var(--shadow-focus-ring);
}

.search-icon {
    color: var(--color-text-body-secondary);
    display: flex;
    align-items: center;
    margin-right: var(--space-s);
}

.search-box input {
    flex: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent;
    font-size: var(--font-size-body-m);
    color: var(--color-text-body-default);
    height: 100%;
}

.search-box input::placeholder {
    color: var(--color-text-placeholder);
}

/* ====================================
   Category Dropdown
   ==================================== */
.category-dropdown {
    position: relative;
    width: 100%;
}

.category-select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 var(--space-m);
    background: var(--color-background-input-default);
    border: 1px solid var(--color-border-input-default);
    border-radius: var(--border-radius-m);
    cursor: pointer;
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.category-select:hover {
    border-color: var(--color-border-item-hover);
}

.category-select.open {
    border-color: var(--color-border-input-focus);
    box-shadow: var(--shadow-focus-ring);
}

.category-select .category-label {
    color: var(--color-text-body-default);
    font-size: var(--font-size-body-m);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.category-select i {
    color: var(--color-text-body-secondary);
    transition: transform var(--motion-duration-fast) var(--motion-easing-default);
}

.category-select.open i {
    transform: rotate(180deg);
}

.category-menu {
    position: absolute;
    top: calc(100% + var(--space-xs));
    left: 0;
    right: 0;
    background: var(--color-background-dropdown);
    border: 1px solid var(--color-border-container-default);
    border-radius: var(--border-radius-m);
    box-shadow: var(--shadow-dropdown);
    z-index: 1000;
    display: none;
    max-height: 320px;
    overflow: hidden;
}

.category-menu.open {
    display: block;
}

.category-search {
    display: flex;
    align-items: center;
    padding: var(--space-s);
    border-bottom: 1px solid var(--color-border-divider-default);
    gap: var(--space-xs);
}

.category-search i {
    color: var(--color-text-body-secondary);
    font-size: var(--font-size-body-m);
}

.category-search input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: var(--font-size-body-m);
    color: var(--color-text-body-default);
    outline: none;
}

.category-search input::placeholder {
    color: var(--color-text-placeholder);
}

.category-options {
    max-height: 250px;
    overflow-y: auto;
}

.category-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-s) var(--space-m);
    cursor: pointer;
    transition: background-color var(--motion-duration-fast) var(--motion-easing-default);
}

.category-option:hover {
    background: var(--color-background-item-hover);
}

.category-option.selected {
    background: var(--color-background-item-selected);
    color: var(--color-primary-default);
}

.category-option .category-name {
    flex: 1;
    font-size: var(--font-size-body-m);
    color: var(--color-text-body-default);
}

.category-option.selected .category-name {
    color: var(--color-primary-default);
    font-weight: var(--font-weight-medium);
}

.category-option .category-count {
    font-size: var(--font-size-body-s);
    color: var(--color-text-body-secondary);
    background: var(--color-background-container-header);
    padding: var(--space-xxxs) var(--space-xs);
    border-radius: var(--border-radius-s);
}

.category-option.selected .category-count {
    background: var(--color-primary-subtle);
    color: var(--color-primary-default);
}

.category-no-results {
    padding: var(--space-l);
    text-align: center;
    color: var(--color-text-body-secondary);
    font-size: var(--font-size-body-s);
}

/* ====================================
   Cards
   ==================================== */
.card {
    background: var(--color-background-container-content);
    border: 1px solid var(--color-border-container-default);
    border-radius: var(--border-radius-l);
    box-shadow: var(--shadow-container);
    transition: all var(--motion-duration-normal) var(--motion-easing-default);
}

.card-body {
    padding: var(--space-m);
    background: var(--color-background-container-content);
}

.card-title {
    font-size: var(--font-size-heading-s);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-heading-default);
}

.card-text {
    font-size: var(--font-size-body-s);
    color: var(--color-text-body-secondary);
    line-height: 1.5;
}

.card-footer {
    padding: var(--space-s) var(--space-m);
    background: var(--color-background-container-header);
    border-top: 1px solid var(--color-border-divider-default);
}

/* Article Cards */
.article-card {
    border: 1px solid var(--color-border-container-default);
    cursor: pointer;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-dropdown);
    border-color: var(--color-border-item-hover);
}

.article-card .card-body {
    border-radius: var(--border-radius-l) var(--border-radius-l) 0 0;
}

.article-card .card-footer {
    border-radius: 0 0 var(--border-radius-l) var(--border-radius-l);
}

/* ====================================
   Buttons
   ==================================== */
.btn {
    font-family: var(--font-family-base);
    font-weight: var(--font-weight-medium);
    border-radius: var(--border-radius-m);
    padding: var(--space-xs) var(--space-m);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.btn-primary {
    background: var(--color-primary-default);
    border-color: var(--color-primary-default);
    color: var(--color-text-inverted);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-container);
}

.btn-outline-primary {
    color: var(--color-primary-default);
    border-color: var(--color-primary-default);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--color-primary-default);
    border-color: var(--color-primary-default);
    color: var(--color-text-inverted);
}

.btn-outline-secondary {
    color: var(--color-text-body-default);
    border-color: var(--color-border-input-default);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--color-background-item-hover);
    border-color: var(--color-border-item-hover);
    color: var(--color-text-body-default);
}

/* ====================================
   Badges
   ==================================== */
.badge {
    font-weight: var(--font-weight-medium);
    padding: var(--space-xxs) var(--space-xs);
    border-radius: var(--border-radius-s);
}

.badge.bg-primary {
    background-color: var(--color-primary-default) !important;
    color: var(--color-text-inverted) !important;
}

.badge.bg-info {
    background-color: var(--color-status-info) !important;
    color: var(--color-text-inverted) !important;
}

.badge.bg-success {
    background-color: var(--color-status-success) !important;
    color: var(--color-text-inverted) !important;
}

.badge.bg-warning {
    background-color: var(--color-status-warning) !important;
    color: var(--color-text-inverted) !important;
}

.badge.bg-secondary {
    background-color: var(--color-text-body-secondary) !important;
    color: var(--color-text-inverted) !important;
}

/* ====================================
   Modal
   ==================================== */
.modal-dialog {
    max-height: calc(100vh - 120px);
    margin-top: 40px;
    margin-bottom: 80px;
}

.modal-content {
    background-color: var(--color-background-container-content);
    border: 1px solid var(--color-border-container-default);
    border-radius: var(--border-radius-l);
    box-shadow: var(--shadow-modal);
    max-height: calc(100vh - 140px);
}

.modal-header {
    background: var(--color-primary-default);
    color: #ffffff;
    border-radius: var(--border-radius-l) var(--border-radius-l) 0 0;
    padding: var(--space-m);
}

.modal-header .modal-title {
    color: #ffffff;
}

.modal-header .btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 1;
    transition: transform var(--motion-duration-fast) var(--motion-easing-default),
                opacity var(--motion-duration-fast) var(--motion-easing-default);
}

.modal-header .btn-close-white:hover {
    opacity: 0.85;
}

.modal-header .btn-close-white:active {
    transform: scale(0.85);
    opacity: 0.7;
}

.modal-body {
    padding: var(--space-l);
    color: var(--color-text-body-default);
}

.modal-body h6 {
    color: var(--color-text-heading-default);
}

.modal-body p {
    color: var(--color-text-body-default);
}

.modal-footer {
    background-color: var(--color-background-container-header);
    border-top: 1px solid var(--color-border-divider-default);
    padding: var(--space-m);
    border-radius: 0 0 var(--border-radius-l) var(--border-radius-l);
}

#articleModal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* ====================================
   Accordion
   ==================================== */
.accordion-button {
    color: var(--color-text-body-default);
    background-color: var(--color-background-container-content);
    font-weight: var(--font-weight-medium);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.accordion-button:not(.collapsed) {
    color: var(--color-primary-default);
    background-color: var(--color-primary-subtle);
}

.accordion-button:focus {
    box-shadow: var(--shadow-focus-ring);
    border-color: var(--color-border-input-focus);
}

.accordion-body {
    color: var(--color-text-body-default);
    background-color: var(--color-background-container-content);
    font-size: var(--font-size-body-m);
    line-height: 1.7;
}

.accordion-item {
    border-color: var(--color-border-container-default);
    background-color: var(--color-background-container-content);
}

/* ====================================
   Forms
   ==================================== */
.form-control {
    background-color: var(--color-background-input-default);
    border: 1px solid var(--color-border-input-default);
    color: var(--color-text-body-default);
    border-radius: var(--border-radius-m);
    padding: var(--space-xs) var(--space-s);
    font-size: var(--font-size-body-m);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.form-control:focus {
    background-color: var(--color-background-input-default);
    border-color: var(--color-border-input-focus);
    box-shadow: var(--shadow-focus-ring);
    color: var(--color-text-body-default);
}

.form-control::placeholder {
    color: var(--color-text-placeholder);
}

.form-control:disabled {
    background-color: var(--color-background-input-disabled);
    color: var(--color-text-disabled);
}

.form-label {
    color: var(--color-text-label);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--space-xxs);
}

/* ====================================
   Chat Widget
   ==================================== */
.chat-widget {
    position: fixed;
    bottom: var(--space-xl);
    right: var(--space-xl);
    z-index: 99999;
    pointer-events: auto !important;
}

.chat-widget * {
    pointer-events: auto !important;
}

.chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary-default);
    border: none;
    color: var(--color-text-inverted);
    font-size: var(--font-size-heading-l);
    cursor: pointer;
    box-shadow: var(--shadow-dropdown);
    transition: all var(--motion-duration-normal) var(--motion-easing-default);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-toggle-btn:hover {
    background: var(--color-primary-hover);
    transform: scale(1.05);
}

.chat-toggle-btn.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: var(--color-status-error);
    color: var(--color-text-inverted);
    font-size: var(--font-size-body-s);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 380px;
    max-height: 500px;
    background: var(--color-background-container-content);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-modal);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    border: 1px solid var(--color-border-container-default);
}

.chat-window.open {
    display: flex;
}

.chat-window textarea,
.chat-window button,
.chat-window input {
    pointer-events: auto;
}

/* Chat backdrop overlay */
.chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-background-modal-overlay);
    z-index: 99990 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--motion-duration-normal) var(--motion-easing-default),
                visibility var(--motion-duration-normal) var(--motion-easing-default);
    pointer-events: none;
}

.chat-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Disable Bootstrap modal backdrop when chat is open */
body.chat-open .modal-backdrop {
    pointer-events: none !important;
}

body.chat-open .modal {
    pointer-events: none !important;
}

body.chat-open .modal-dialog {
    pointer-events: auto;
}

.chat-widget .chat-header {
    background: var(--color-primary-default);
    color: var(--color-text-inverted);
    padding: var(--space-m);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-weight: var(--font-weight-medium);
}

.chat-header-info i {
    font-size: var(--font-size-heading-s);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.chat-new-btn,
.chat-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    font-size: var(--font-size-body-m);
    cursor: pointer;
    opacity: 0.9;
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-m);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-new-btn:hover,
.chat-close-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.25);
}

/* Chat Messages */
.chat-widget .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-m);
    max-height: 320px;
    background: var(--color-background-container-header);
}

.chat-widget .message {
    margin-bottom: var(--space-m);
    animation: slideIn var(--motion-duration-normal) var(--motion-easing-default);
}

.chat-widget .message-content {
    padding: var(--space-s) var(--space-m);
    border-radius: var(--border-radius-l);
    font-size: var(--font-size-body-m);
    line-height: 1.5;
    max-width: 85%;
}

.chat-widget .assistant-message .message-content {
    background: var(--color-background-container-content);
    color: var(--color-text-body-default);
    border: 1px solid var(--color-border-container-default);
}

.chat-widget .user-message {
    display: flex;
    justify-content: flex-end;
}

.chat-widget .user-message .message-content {
    background: var(--color-primary-default);
    color: var(--color-text-inverted);
}

/* Chat Input Area */
.chat-input-area {
    padding: var(--space-m);
    background: var(--color-background-container-content);
    border-top: 1px solid var(--color-border-divider-default);
}

.chat-input-wrapper {
    display: flex;
    gap: var(--space-xs);
    align-items: flex-end;
}

.chat-input-wrapper textarea {
    flex: 1;
    border: 1px solid var(--color-border-input-default);
    border-radius: var(--border-radius-l);
    padding: var(--space-s) var(--space-m);
    font-size: var(--font-size-body-m);
    resize: none;
    min-height: 42px;
    max-height: 120px;
    line-height: 1.4;
    background: var(--color-background-input-default);
    color: var(--color-text-body-default);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.chat-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--color-border-input-focus);
    box-shadow: var(--shadow-focus-ring);
}

.chat-input-wrapper textarea::placeholder {
    color: var(--color-text-placeholder);
}

.chat-input-wrapper button {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary-default);
    color: var(--color-text-inverted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
    flex-shrink: 0;
}

.chat-input-wrapper button:hover {
    background: var(--color-primary-hover);
}

.chat-input-wrapper button:disabled {
    background: var(--color-background-input-disabled);
    color: var(--color-text-disabled);
    cursor: not-allowed;
}

/* Article Links in Chat */
.article-link {
    color: var(--color-text-link-default);
    background: var(--color-primary-subtle);
    padding: var(--space-xxxs) var(--space-xs);
    border-radius: var(--border-radius-s);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.article-link:hover {
    background: var(--color-background-item-selected);
    color: var(--color-text-link-hover);
    text-decoration: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: var(--space-xs);
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--color-primary-default);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Message content extras */
.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin-bottom: var(--space-xs);
    padding-left: var(--space-l);
}

/* ====================================
   Related Articles
   ==================================== */
.related-articles {
    padding: var(--space-xs);
    background: var(--color-background-container-header);
    border-radius: var(--border-radius-m);
}

.related-article-btn {
    font-size: var(--font-size-body-s);
    padding: var(--space-xxxs) var(--space-xs);
}

/* ====================================
   Constitutional Structure Breadcrumb
   ==================================== */
.estructura-breadcrumb {
    background: var(--color-background-container-header);
    border-radius: var(--border-radius-l);
    padding: var(--space-m) var(--space-l);
    border-left: 4px solid var(--color-primary-default);
}

.estructura-breadcrumb h6 {
    font-size: var(--font-size-body-s);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-heading-secondary);
}

.estructura-path {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.estructura-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-s);
    border-radius: var(--border-radius-m);
    font-size: var(--font-size-body-s);
    background: var(--color-background-container-content);
    color: var(--color-text-body-default);
    border: 1px solid var(--color-border-container-default);
}

.estructura-item i {
    font-size: var(--font-size-body-m);
    opacity: 0.8;
}

.estructura-item.parte {
    background: var(--color-primary-default);
    color: var(--color-text-inverted);
    border: none;
    font-weight: var(--font-weight-bold);
}

.estructura-item.titulo {
    background: var(--color-primary-subtle);
    color: var(--color-primary-default);
    border-color: var(--color-primary-default);
    font-weight: var(--font-weight-medium);
}

.estructura-item.capitulo {
    background: var(--color-background-notification-blue);
    color: var(--color-text-interactive-default);
    border-color: var(--color-border-item-selected);
}

.estructura-item.seccion {
    background: var(--color-background-status-warning);
    color: var(--color-text-status-warning);
    border-color: var(--color-status-warning);
}

.estructura-separator {
    display: none;
}

@media (min-width: 768px) {
    .estructura-path {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .estructura-separator {
        display: flex;
        align-items: center;
        color: var(--color-text-body-secondary);
        font-size: var(--font-size-body-s);
    }

    .estructura-item {
        flex: none;
    }
}

/* ====================================
   About Section
   ==================================== */
.about-block {
    padding: var(--space-l);
    background: var(--color-background-container-content);
    border-radius: var(--border-radius-m);
    border-left: 4px solid var(--color-primary-default);
}

.about-block h5 {
    margin-bottom: var(--space-s);
    color: var(--color-text-heading-default);
}

.about-block p {
    margin-bottom: 0;
    color: var(--color-text-body-default);
    line-height: 1.7;
}

.method-list {
    padding-left: var(--space-l);
    margin-bottom: 0;
}

.method-list li {
    margin-bottom: var(--space-xs);
    line-height: 1.6;
    color: var(--color-text-body-default);
}

.method-list li:last-child {
    margin-bottom: 0;
}

/* ====================================
   Pagination
   ==================================== */
.pagination .page-link {
    color: var(--color-text-interactive-default);
    background-color: var(--color-background-container-content);
    border-color: var(--color-border-container-default);
    transition: all var(--motion-duration-fast) var(--motion-easing-default);
}

.pagination .page-link:hover {
    color: var(--color-text-interactive-hover);
    background-color: var(--color-background-item-hover);
    border-color: var(--color-border-item-hover);
}

.pagination .page-item.active .page-link {
    background-color: var(--color-primary-default);
    border-color: var(--color-primary-default);
    color: var(--color-text-inverted);
}

.pagination .page-item.disabled .page-link {
    color: var(--color-text-disabled);
    background-color: var(--color-background-input-disabled);
}

/* ====================================
   Articles Grid Animation
   ==================================== */
#articlesGrid {
    opacity: 1;
    transition: opacity var(--motion-duration-normal) var(--motion-easing-default);
}

#articlesGrid.hidden {
    opacity: 0;
}

#paginationContainer {
    opacity: 1;
    transition: opacity var(--motion-duration-normal) var(--motion-easing-default);
}

#paginationContainer.hidden {
    opacity: 0;
}

/* ====================================
   Scrollbar
   ==================================== */
.chat-messages::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
#tematicasFilter::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
#tematicasFilter::-webkit-scrollbar-track {
    background: var(--color-background-container-header);
}

.chat-messages::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
#tematicasFilter::-webkit-scrollbar-thumb {
    background: var(--color-border-input-default);
    border-radius: var(--border-radius-s);
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
#tematicasFilter::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-body-secondary);
}

/* ====================================
   Focus & Accessibility
   ==================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--color-border-item-focused);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ====================================
   Responsive
   ==================================== */
@media (max-width: 576px) {
    .chat-widget {
        bottom: var(--space-m);
        right: var(--space-m);
    }

    .chat-window {
        width: calc(100vw - 32px);
        max-height: 70vh;
        right: -8px;
    }

    .main-section {
        padding-top: 100px;
    }
}

/* ====================================
   Print Styles
   ==================================== */
@media print {
    .navbar,
    .chat-widget {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    .card,
    .modal-content {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ====================================
   Dark Mode Specific Overrides
   ==================================== */

/* Keep white text on blue backgrounds (navbar, modal header, chat header) */
[data-theme="dark"] .navbar-brand,
[data-theme="dark"] .nav-link,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-header .modal-title,
[data-theme="dark"] .chat-header,
[data-theme="dark"] .chat-header-info {
    color: #ffffff !important;
}

/* Article text box in modal - bright text on dark background */
[data-theme="dark"] .modal-body .bg-light {
    background-color: var(--color-background-container-header) !important;
    color: var(--color-text-body-default) !important;
}

[data-theme="dark"] .modal-body .bg-light * {
    color: var(--color-text-body-default);
}

/* System preference dark mode - same overrides */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .navbar-brand,
    :root:not([data-theme="light"]) .nav-link,
    :root:not([data-theme="light"]) .modal-header,
    :root:not([data-theme="light"]) .modal-header .modal-title,
    :root:not([data-theme="light"]) .chat-header,
    :root:not([data-theme="light"]) .chat-header-info {
        color: #ffffff !important;
    }

    :root:not([data-theme="light"]) .modal-body .bg-light {
        background-color: var(--color-background-container-header) !important;
        color: var(--color-text-body-default) !important;
    }

    :root:not([data-theme="light"]) .modal-body .bg-light * {
        color: var(--color-text-body-default);
    }
}
