/* Paletas basadas en los temas de Davar:
   claro = "Gracia", sepia = "Papiro", oscuro = "Sinaí - Noche Marina" */
:root,
[data-theme="light"] {
    color-scheme: light;
    --page-bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-translucent: rgba(255, 255, 255, 0.92);
    --header-bg: linear-gradient(135deg, #ffffff 0%, #eef4fa 100%);
    --primary-color: #0284c7;
    --secondary-color: #2c3e50;
    --accent-color: #0284c7;
    --light-bg: #f1f5f9;
    --border-color: rgba(0, 0, 0, 0.09);
    --on-secondary: #ffffff;
    --text-color: #334155;
    --text-strong: #1e293b;
    --text-light: #64748b;
    --hover-bg: rgba(2, 132, 199, 0.08);
    --active-bg: rgba(2, 132, 199, 0.16);
    --on-accent: #ffffff;
    --toggler-filter: invert(1) opacity(0.65);
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --font-hebrew: "Noto Sans Hebrew", "David", serif;
}

[data-theme="sepia"] {
    color-scheme: light;
    --warning-color: #b45309;
    --page-bg: #e4d8bf;
    --surface: #fdf9ed;
    --surface-2: #f5eddc;
    --surface-translucent: rgba(247, 240, 226, 0.94);
    --header-bg: linear-gradient(135deg, #fdf9ed 0%, #efe4cd 100%);
    --primary-color: #9e3b1e;
    --secondary-color: #4a2c14;
    --accent-color: #9e3b1e;
    --light-bg: #f5eddc;
    --border-color: rgba(140, 80, 20, 0.2);
    --on-secondary: #ffffff;
    --text-color: #2b1b0e;
    --text-strong: #2b1b0e;
    --text-light: #6e5843;
    --hover-bg: rgba(140, 80, 20, 0.1);
    --active-bg: rgba(140, 80, 20, 0.2);
    --on-accent: #ffffff;
    --toggler-filter: invert(1) sepia(1) saturate(3) hue-rotate(-20deg) opacity(0.75);
}

[data-theme="dark"] {
    color-scheme: dark;
    --warning-color: #fbbf24;
    --page-bg: #0f172a;
    --surface: #1e293b;
    --surface-2: rgba(255, 255, 255, 0.05);
    --surface-translucent: rgba(30, 41, 59, 0.92);
    --header-bg: linear-gradient(135deg, #16213c 0%, #0f172a 100%);
    --primary-color: #38bdf8;
    --secondary-color: #334155;
    --accent-color: #7dd3fc;
    --light-bg: rgba(255, 255, 255, 0.06);
    --border-color: rgba(255, 255, 255, 0.14);
    --on-secondary: #ffffff;
    --text-color: #e2e8f0;
    --text-strong: #ffffff;
    --text-light: #94a3b8;
    --hover-bg: rgba(125, 211, 252, 0.15);
    --active-bg: rgba(125, 211, 252, 0.25);
    --on-accent: #0f172a;
    --toggler-filter: none;
}

[data-theme="ocean"] {
    color-scheme: dark;
    --warning-color: #fcd34d;
    --page-bg: #012b3d;
    --surface: #06262d;
    --surface-2: rgba(45, 212, 191, 0.08);
    --surface-translucent: rgba(6, 38, 45, 0.94);
    --header-bg: linear-gradient(135deg, #083f4d 0%, #012b3d 100%);
    --primary-color: #2dd4bf;
    --secondary-color: #0b4f5c;
    --accent-color: #5eead4;
    --light-bg: rgba(255, 255, 255, 0.06);
    --border-color: rgba(45, 212, 191, 0.22);
    --on-secondary: #ffffff;
    --text-color: #f0fdfa;
    --text-strong: #ffffff;
    --text-light: #99f6e4;
    --hover-bg: rgba(45, 212, 191, 0.14);
    --active-bg: rgba(45, 212, 191, 0.24);
    --on-accent: #04212a;
    --toggler-filter: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.search-container,
.dictionary-section,
.word-card,
.footer-content,
.stats-container {
    max-width: 100%;
}

.container {
    width: 100%;
    max-width: 100%;
    padding: 0 1rem;
}

body {
    font-family: 'Open Sans', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--page-bg);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
header {
    background: var(--header-bg);
    color: var(--text-color);
    padding: 0.2rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Cabecera de marca: logo de Davar + título (a juego con la página de Davar) */
.brand-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    margin: 0.4rem 0 0.5rem;
}

.brand-logo {
    flex: 0 0 auto;
    display: block;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22), 0 0 0 3px var(--hover-bg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.brand-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-logo:hover {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 7px 18px rgba(0, 0, 0, 0.3), 0 0 0 3px var(--active-bg);
}

.brand-titles {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.brand-titles h4 {
    margin: 0;
    text-align: left;
    line-height: 1.15;
}

.brand-subtitle {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* En pantallas estrechas el distintivo sobra: el pie ya lleva la firma */
@media (max-width: 560px) {
    .brand-subtitle {
        display: none;
    }

    .brand-logo {
        width: 42px;
        height: 42px;
    }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Heebo', sans-serif;
    font-size: 2rem;
    font-weight: 700;
}

.form-group {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.25rem 0 1.5rem;
    gap: 0.85rem;
    flex-wrap: wrap;
    direction: ltr;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.25rem 1.75rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.form-group:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.form-group label {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-strong);
    letter-spacing: -0.01em;
    white-space: nowrap;
    margin: 0;
}

.form-group input,
#verb {
    padding: 0.45rem 0.85rem;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    width: 140px;
    max-width: 180px;
    text-align: center;
    direction: rtl;
    font-family: var(--font-hebrew);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.3;
    background-color: var(--surface-2);
    color: var(--text-strong);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.form-group input::placeholder,
#verb::placeholder {
    color: var(--text-light);
    opacity: 0.7;
    font-family: var(--font-hebrew);
}

.form-group input:focus,
#verb:focus {
    outline: none;
    border-color: var(--accent-color);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px var(--active-bg);
}

.form-group button,
#generateBtn {
    padding: 0.55rem 1.35rem;
    background-color: var(--primary-color);
    color: var(--on-accent);
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group button:hover,
#generateBtn:hover {
    background-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}

.form-group button:active,
#generateBtn:active {
    transform: translateY(0);
}

.form-group > p:first-of-type {
    flex-basis: 100%;
    text-align: center;
    margin: 0.35rem 0 0 0;
    font-size: 0.88rem;
    color: var(--text-light);
}

/* Significado del verbo: glosa en su propio renglon, con los datos del lexico debajo */
#verbDefinition {
    flex-basis: 100%;
    margin: 0.35rem 0 0 0;
    text-align: center;
    line-height: 1.4;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.05rem;
    min-height: 1.5em;
}

.verb-definition-meta {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--text-light);
}

.verb-types-hint {
    display: inline-block;
    color: var(--warning-color, #f39c12);
    font-size: 0.88rem;
    font-weight: 500;
    margin: 0.2rem auto 0;
    text-align: center;
    padding: 0.25rem 0.75rem;
    background-color: var(--surface-2);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
}

h1,
h2,
h3,
h4 {
    font-weight: 600;
    color: var(--primary-color);
    /* Applied to all headings for advanced mode consistency */
}

h4 {
    text-align: center;
}

/* Barra de navegación mejorada */
.navbar {
    border-radius: 12px;
    background: var(--surface-2) !important;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.5rem 1rem;
    margin: 0.2rem 0 1rem 0;
}

.navbar-brand h6 {
    color: var(--text-strong) !important;
    font-weight: 600;
    margin: 0;
    padding: 0.5rem 0;
    font-size: 1.1rem;
}

.nav-link {
    color: var(--text-color) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    margin: 0 0.2rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: var(--text-strong) !important;
    background-color: var(--hover-bg);
    transform: translateY(-2px);
}

.nav-link.active {
    background-color: var(--active-bg);
    color: var(--text-strong) !important;
    font-weight: 600;
}

.navbar-toggler {
    border-color: var(--border-color);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    filter: var(--toggler-filter);
}

/* Selector de tema (paletas de Davar) */
.theme-switch {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 0.6rem 0 0.2rem;
}

.theme-switch button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--surface-2);
    color: var(--text-color);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-switch button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--surface-2);
}

.theme-switch button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--on-accent);
}

.theme-switch .swatch {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.swatch-light { background: #ffffff; }
.swatch-sepia { background: #e4d8bf; }
.swatch-dark { background: #0f172a; }
.swatch-ocean { background: #2dd4bf; }

label {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    text-align: left;
    /* Asegurar alineación a la izquierda */
}

input {
    font-family: var(--font-hebrew);
    font-size: 1.5rem;
    padding: 0.5rem 1rem;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    background-color: var(--surface);
    color: var(--text-color);
    direction: ltr;
    /* Para entradas de texto */
}

input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.5);
}

/* Search Container */
.search-container {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 1.5rem 2rem;
    margin: 2rem auto;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.search-direction {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-direction label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-2);
    color: var(--text-color);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.search-direction label:hover {
    background-color: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--text-strong);
    transform: translateY(-1px);
}

.search-direction input[type="radio"] {
    appearance: auto;
    accent-color: var(--primary-color);
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.search-direction label:has(input[type="radio"]:checked),
.search-direction label:has(input:checked) {
    background-color: var(--active-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.18);
}

.search-input-group {
    display: flex;
    width: 100%;
    flex-direction: column;
}

.search-input-group input[type="text"],
.search-input-group button {
    width: 100%;
    border-radius: 20px;
    margin: 0.3rem 0;
}

.search-container input[type="text"] {
    flex: 1;
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 20px 0 0 20px;
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    outline: none;
    background-color: var(--surface);
    color: var(--text-color);
    transition: border-color 0.3s;
}

.search-container input[type="text"]:focus {
    border-color: var(--primary-color);
}

.search-container button {
    background-color: var(--primary-color);
    color: var(--on-accent);
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 20px 20px 20px 20px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

.search-container button:hover {
    background-color: var(--accent-color);
}

button {
    background-color: var(--primary-color);
    color: var(--on-accent);
    border: none;
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: var(--accent-color);
}

.tabs {
    max-width: 1200px;
    margin: 1.25rem auto 0;
    padding: 0.45rem 0.65rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    background-color: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 14px 14px 0 0;
}

.tab {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-radius: 10px 10px 0 0;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-color);
    transition: all 0.2s ease;
    border: 1px solid transparent;
    border-bottom: none;
    user-select: none;
}

.tab:hover {
    background-color: var(--hover-bg);
    color: var(--text-strong);
}

.tab.active {
    background-color: var(--surface);
    border-color: var(--border-color);
    border-bottom: 1px solid var(--surface);
    margin-bottom: -1px;
    font-weight: 700;
    color: var(--primary-color);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.tab-content {
    max-width: 1200px;
    margin: 0 auto 2rem;
    display: none;
    padding: 1.75rem 2rem;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 0 0 14px 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
}

.tab-content.active {
    display: block;
}

.tab-content h2 {
    color: var(--primary-color);
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--hover-bg);
    padding-bottom: 0.5rem;
}

.tab-content h3 {
    color: var(--text-strong);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0 1.25rem 0;
    font-size: 0.92rem;
}

th,
td {
    padding: 0.65rem 0.85rem;
    text-align: center;
    border: 1px solid var(--border-color);
    vertical-align: middle;
}

th {
    background-color: var(--secondary-color);
    color: var(--on-secondary, #ffffff);
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: 0.02em;
}

tr:nth-child(even) td {
    background-color: var(--surface-2);
}

tr:hover td {
    background-color: var(--hover-bg);
}

td:first-child,
.binyan-name {
    font-weight: 600;
    color: var(--primary-color);
    background-color: var(--surface);
    white-space: nowrap;
}

.hebrew {
    font-family: var(--font-hebrew);
    font-size: 1.45rem;
    direction: rtl;
    line-height: 1.35;
    font-weight: 500;
}

.theoretical {
    color: var(--text-light);
    font-style: italic;
    position: relative;
}

.theoretical::after {
    content: '*';
    font-size: 0.7em;
    vertical-align: super;
    margin-right: 2px;
}

.note {
    max-width: 1200px;
    margin: 1.5rem auto 2rem;
    padding: 1rem 1.25rem;
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 0 12px 12px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    font-size: 0.9rem;
    color: var(--text-light);
    font-style: italic;
}

.note p {
    margin: 0;
    line-height: 1.5;
}

/* Main Content */
main {
    padding: 2rem 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-options select {
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    outline: none;
    font-size: 0.9rem;
}

/* Categories */
.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin: 2rem 0;
}

.category-btn {
    background-color: var(--surface);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.category-btn:hover,
.category-btn.active {
    background-color: var(--primary-color);
    color: var(--on-accent);
}

/* Dictionary Section */
.dictionary-section {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
}

h2 {
    font-family: 'Heebo', sans-serif;
    color: var(--text-strong);
    font-weight: 700;
    font-size: 1.5rem;
}

/* Word List and Cards */
.word-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.word-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-color: var(--surface);
}

.word-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.word-card.popular {
    border-left: 3px solid var(--accent-color);
}

.hebrew-word {
    font-family: 'Heebo', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-strong);
    direction: rtl;
    text-align: right;
}

.spanish-word {
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.word-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.word-detail {
    display: flex;
    justify-content: space-between;
}

.detail-label {
    font-weight: 600;
    color: var(--text-light);
}

.detail-value {
    color: var(--text-color);
    text-align: right;
}

/* Estilos para la barra de estadísticas compacta */
.stats-container.compact {
    background-color: var(--surface-2);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 20px;
}

.stats-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    font-size: 0.9rem;
}

.stats-summary .stat-item {
    margin: 0 5px;
}

/* Estilos para el indicador de dirección */
.search-direction-indicator {
    font-size: 0.8rem;
    color: var(--text-light);
    text-align: right;
    margin-top: 4px;
}

/* Statistics */
.stats-container {
    background-color: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stats-container h3 {
    margin-bottom: 1.5rem;
    color: var(--text-strong);
    text-align: center;
    font-family: 'Heebo', sans-serif;
    font-size: 1.3rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    text-align: center;
}

.stat-item {
    padding: 1rem;
    border-radius: 8px;
    background-color: var(--light-bg);
    transition: transform 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-3px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Loading, Error and Empty States */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error {
    background-color: #ffebee;
    color: var(--error-color);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: center;
    border-left: 4px solid var(--error-color);
}

.empty-results {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Pie de página */
h5 {
    margin-top: 40px;
    color: #578285;
    font-style: italic;
    text-align: center;
    font-weight: normal;
    font-size: medium;
}

/* Footer (a juego con el pie de Davar) */
.site-footer {
    background: transparent;
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 1.4rem 1rem 1.6rem;
    margin-top: 2.5rem;
    text-align: center;
}

.footer-copyright {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-strong);
}

.footer-license {
    max-width: 68ch;
    margin: 0 auto;
    font-size: 0.75rem;
    line-height: 1.6;
    opacity: 0.85;
}

.footer-license a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.footer-license a:hover {
    text-decoration: underline;
}

/* El pie, más recogido en pantallas pequeñas */
@media (max-width: 768px) {
    .site-footer {
        padding: 1.1rem 1rem 1.3rem;
        margin-top: 2rem;
    }

    .footer-copyright {
        font-size: 0.8rem;
    }

    .footer-license {
        font-size: 0.72rem;
        line-height: 1.5;
    }
}

.footer-content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 2rem;
}

.footer-section {
    flex: 1;
    min-width: 200px;
}

.footer-section h3 {
    margin-bottom: 0.5rem;
    font-family: 'Heebo', sans-serif;
    font-size: 1.2rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.footer-section h3::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 40px;
    height: 2px;
    background-color: var(--primary-color);
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.8rem;
}

.footer-section a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: white;
}

.copyright {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Vue-specific */
[v-cloak] {
    display: none;
}

/* Las tablas de conjugación se desplazan dentro de su pestaña, sin desbordar la página */
.tab-content,
.dictionary-section,
.stats-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Responsive Styles */
@media (max-width: 1200px) {
    /* Entre 992 y 1200px la barra expandida se queda sin sitio: se permite el salto de línea */
    .navbar-nav {
        flex-wrap: wrap;
    }

    .nav-link {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.92rem;
    }

    .navbar-brand h6 {
        font-size: 1rem;
    }
}

@media (max-width: 900px) {
    .container {
        padding: 0.4rem 0.8rem;
    }

    .theme-switch {
        flex-wrap: wrap;
        justify-content: center;
        padding-top: 0.3rem;
    }

    .theme-switch button {
        padding: 3px 10px;
        font-size: 0.75rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.4rem;
    }

    .hebrew {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.45rem;
    }

    .hebrew {
        font-size: 1.1rem;
    }

    /* Pestañas en una sola fila desplazable, en lugar de varias líneas */
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 0.5rem 0.8rem;
        margin-bottom: 0;
    }

    header .container>h4 {
        font-size: 1.1rem;
    }

    .theme-switch button {
        padding: 3px 10px;
        font-size: 0.72rem;
    }

    .form-group {
        padding: 1.1rem 1rem;
        margin: 0.8rem 0;
        flex-direction: column;
        align-items: center;
        gap: 0.6rem;
    }

    .form-group label {
        font-size: 1rem;
    }

    .form-group input,
    #verb {
        width: 100%;
        max-width: 220px;
        font-size: 1.25rem;
        padding: 0.4rem 0.75rem;
    }

    .form-group button,
    #generateBtn {
        width: 100%;
        max-width: 220px;
        font-size: 0.92rem;
        padding: 0.5rem 1rem;
    }

    .form-group p {
        margin: 0;
        font-size: 0.8rem;
    }

    .tab-content {
        padding: 1.1rem 0.9rem;
        border-radius: 0 0 10px 10px;
    }

    .tabs {
        border-radius: 10px 10px 0 0;
        padding: 0.3rem 0.4rem 0;
    }
}

@media print {

    header,
    footer,
    .form-group,
    .tabs {
        display: none;
    }

    .tab-content {
        display: block !important;
        box-shadow: none;
    }

    body {
        font-size: 12pt;
    }
}

@media print {

    header,
    footer,
    .form-group,
    .tabs {
        display: none;
    }

    .tab-content {
        display: block !important;
        box-shadow: none;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    nav ul {
        margin-top: 1rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    nav li {
        margin: 0.5rem;
    }

    .word-list {
        grid-template-columns: 1fr;
    }

    .search-direction {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .search-input-group {
        flex-direction: column;
    }

    .search-container input[type="text"] {
        border-radius: 20px;
        border-right: 1px solid var(--border-color);
        margin-bottom: 0.8rem;
    }

    .search-container button {
        border-radius: 20px;
        width: 100%;
    }

    @media (max-width: 360px) {
        .hebrew-word {
            font-size: 1.4rem;
        }

        .spanish-word {
            font-size: 1rem;
        }

        h2 {
            font-size: 1.2rem;
        }

        .search-container {
            padding: 1rem;
        }
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    .tab-content.active {
        animation: fadeIn 0.5s ease-in-out;
    }

    .tooltip {
        position: relative;
        display: inline-block;
        cursor: help;
        border-bottom: 1px dotted var(--primary-color);
    }

    .tooltip .tooltip-text {
        visibility: hidden;
        width: 200px;
        background-color: var(--dark-color);
        color: white;
        text-align: center;
        border-radius: 6px;
        padding: 5px;
        position: absolute;
        z-index: 1;
        bottom: 125%;
        left: 50%;
        margin-left: -100px;
        opacity: 0;
        transition: opacity 0.3s;
        font-size: 0.9rem;
    }

    .tooltip:hover .tooltip-text {
        visibility: visible;
        opacity: 1;
    }
}

/* ------------------------------------------------------------------
   Móvil en apaisado (poca altura). Va al final a propósito: así gana a
   los bloques por anchura, que también se aplican en esta orientación.
   ------------------------------------------------------------------ */
@media (max-height: 520px) {
    header {
        padding: 0.1rem 0;
        margin-bottom: 0.3rem;
    }

    /* El nombre y el logo ya están en la barra de navegación */
    .brand-header {
        display: none;
    }

    /* El selector de tema comparte fila con la navegación */
    header .container {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.3rem 0.8rem;
    }

    .navbar {
        order: 1;
        flex: 1 1 auto;
        width: auto;
        padding: 0.15rem 0.5rem;
        margin: 0;
    }

    .navbar-brand h6 {
        font-size: 0.95rem;
        padding: 0.15rem 0;
    }

    .theme-switch {
        order: 2;
        margin-left: auto;
        padding: 0;
        flex: 0 0 auto;
    }

    .theme-switch button {
        padding: 2px 8px;
        font-size: 0.7rem;
    }

    .theme-switch .swatch {
        width: 9px;
        height: 9px;
    }

    .form-group {
        order: 3;
        flex: 1 0 100%;
        margin: 0.2rem 0;
        gap: 0.5rem;
        align-items: center;
    }

    .form-group label {
        font-size: 0.95rem;
    }

    .form-group input {
        font-size: 1.1rem;
        padding: 0.25rem 0.6rem;
        border-width: 1px;
    }

    .form-group button {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    /* Se oculta solo la nota estática; se conserva la definición de la raíz */
    .form-group>p:first-of-type {
        display: none;
    }

    .form-group p {
        margin: 0;
        font-size: 0.85rem;
        min-height: 0 !important;
    }

    /* Pestañas en una sola fila desplazable */
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        flex: 0 0 auto;
        padding: 0.35rem 0.7rem;
        font-size: 0.85rem;
        margin-bottom: 0;
    }

    main {
        padding: 0;
    }

    .tab-content {
        padding: 0.4rem;
    }

    /* El nombre del tiempo verbal ya está en la pestaña activa */
    .tab-content h2 {
        display: none;
    }

    th,
    td {
        padding: 0.25rem 0.4rem;
    }
}

/* ------------------------------------------------------------------
   Aviso de cookies (Acceptrics). En móvil apaisado el banner es más
   alto que la pantalla y tapa toda la app: lo acotamos y permitimos
   desplazarlo internamente para poder leerlo y aceptarlo.
   ------------------------------------------------------------------ */
@media (max-height: 520px) {
    #acceptricsCookieBanner {
        max-height: 52vh !important;
        overflow-y: auto !important;
        padding: 10px 14px !important;
        line-height: 1.3 !important;
    }

    #acceptricsCookieBanner p,
    #acceptricsCookieBanner span,
    #acceptricsCookieBanner div {
        font-size: 0.78rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.4rem !important;
    }

    #acceptricsCookieBanner button,
    #acceptricsCookieBanner a {
        padding: 4px 12px !important;
        font-size: 0.78rem !important;
        margin: 2px 0 !important;
    }
}

/* ------------------------------------------------------------------
   Modo incrustado (?embed=1) para Davar y Léxico ampliado
   ------------------------------------------------------------------ */
body.is-embedded .brand-header,
body.is-embedded .theme-switch,
body.is-embedded nav.navbar,
body.is-embedded footer,
body.is-embedded #acceptricsCookieBanner {
    display: none !important;
}

body.is-embedded {
    background-color: var(--surface) !important;
    padding-top: 0 !important;
}

body.is-embedded header {
    padding: 0.4rem 0 !important;
    margin-bottom: 0.4rem !important;
    box-shadow: none !important;
    border-bottom: 1px solid var(--border-color) !important;
}

body.is-embedded .form-group {
    margin: 0.3rem 0 !important;
    flex-wrap: wrap;
    gap: 0.5rem;
}

body.is-embedded .container {
    max-width: 100% !important;
    padding: 0.4rem 0.8rem !important;
}

body.is-embedded .tabs {
    margin-top: 0.4rem;
}

/* Dropdown navigation styles (Option A) */
.nav-item.dropdown {
    position: relative;
}
.dropdown-menu {
    background-color: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    border-radius: 10px;
    padding: 6px 0;
    min-width: 200px;
}
.dropdown-item {
    color: var(--text-color);
    font-size: 0.92rem;
    font-weight: 500;
    padding: 7px 16px;
    display: block;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--hover-bg);
    color: var(--primary);
}


/* Barra de navegación unificada (Autónoma, no depende de Bootstrap externo) */
.navbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    border-radius: 12px;
    background: var(--surface-2) !important;
    border: 1px solid var(--border, var(--border-color, rgba(0,0,0,0.1)));
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.5rem 1rem;
    margin: 0.2rem 0 1rem 0;
    position: relative;
    box-sizing: border-box;
}

.navbar .container-fluid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0;
    margin: 0;
}

.navbar-brand {
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    margin-right: 1rem;
}

.navbar-brand h6 {
    color: var(--text-strong) !important;
    font-weight: 700;
    margin: 0;
    padding: 0.35rem 0;
    font-size: 1.05rem;
    text-decoration: none !important;
}

.navbar-collapse {
    display: flex;
    flex-basis: auto;
    flex-grow: 1;
    align-items: center;
}

.navbar-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    list-style: none !important;
    margin: 0;
    padding: 0;
    gap: 4px;
    align-items: center;
}

.nav-item {
    list-style: none !important;
    margin: 0;
    padding: 0;
    position: relative;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    color: var(--text, var(--text-color, #333)) !important;
    font-weight: 500;
    padding: 0.45rem 0.85rem !important;
    margin: 0;
    border-radius: 8px;
    text-decoration: none !important;
    transition: all 0.2s ease;
    font-size: 0.92rem;
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text-strong) !important;
    background-color: var(--hover-bg);
    text-decoration: none !important;
    transform: translateY(-1px);
}

.nav-link.active {
    background-color: var(--active-bg);
    color: var(--text-strong) !important;
    font-weight: 700;
    border-color: var(--border, var(--border-color, rgba(0,0,0,0.1)));
    text-decoration: none !important;
}

.dropdown {
    position: relative;
}

.dropdown-toggle::after {
    display: inline-block;
    margin-left: 0.35em;
    vertical-align: 0.15em;
    content: "";
    border-top: 0.35em solid;
    border-right: 0.3em solid transparent;
    border-bottom: 0;
    border-left: 0.3em solid transparent;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1050;
    min-width: 13rem;
    padding: 0.4rem 0;
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    color: var(--text, var(--text-color, #333));
    text-align: left;
    list-style: none !important;
    background-color: var(--surface);
    border: 1px solid var(--border, var(--border-color, rgba(0,0,0,0.1)));
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.dropdown:hover .dropdown-menu,
.dropdown.show .dropdown-menu,
.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1.15rem;
    clear: both;
    font-weight: 500;
    color: var(--text, var(--text-color, #333)) !important;
    text-align: inherit;
    text-decoration: none !important;
    white-space: nowrap;
    background-color: transparent;
    border: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: var(--text-strong) !important;
    background-color: var(--hover-bg);
    text-decoration: none !important;
}

.navbar-toggler {
    display: none;
    padding: 0.35rem 0.65rem;
    font-size: 1.1rem;
    line-height: 1;
    background-color: transparent;
    border: 1px solid var(--border, var(--border-color, rgba(0,0,0,0.1)));
    border-radius: 8px;
    cursor: pointer;
}

.navbar-toggler-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(120, 100, 80, 0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
    filter: var(--toggler-filter);
}

@media (max-width: 991px) {
    .navbar-toggler {
        display: block;
    }
    .navbar-collapse {
        flex-basis: 100%;
        display: none;
        padding-top: 0.75rem;
    }
    .navbar-collapse.show {
        display: block;
    }
    .navbar-nav {
        flex-direction: column;
        align-items: stretch;
    }
    .nav-link {
        padding: 0.6rem 1rem !important;
    }
    .dropdown-menu {
        position: static;
        box-shadow: none;
        border: 1px solid var(--border, var(--border-color, rgba(0,0,0,0.1)));
        margin: 0.25rem 0.5rem;
    }
}

/* Fallbacks para iconos si FontAwesome es bloqueado por CSP */
.fa-search:empty::before,
.fas.fa-search:empty::before {
    content: "🔍";
    font-style: normal;
}

.fa-times:empty::before,
.fas.fa-times:empty::before {
    content: "✕";
    font-style: normal;
}
