/* בסיס כללי */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: "Heebo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #161b33 0, #050609 45%, #02030a 100%);
    color: #f7f7ff;
}

/* שורש האפליקציה */
.app-root {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-icon {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: conic-gradient(from 210deg, #18ffff, #7c4dff, #ff4081, #18ffff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.4rem;
    color: #050609;
    box-shadow: 0 0 20px rgba(24, 255, 255, 0.35);
}

.brand-text h1 {
    margin: 0;
    font-size: 1.9rem;
}

.brand-text p {
    margin: 0.25rem 0 0;
    opacity: 0.75;
    font-size: 0.95rem;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    background: rgba(10, 16, 40, 0.8);
    border: 1px solid rgba(120, 143, 255, 0.35);
    font-size: 0.85rem;
}

.pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #18ffff;
    box-shadow: 0 0 12px rgba(24, 255, 255, 0.9);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.4; }
    100% { transform: scale(1); opacity: 1; }
}

/* Main layout */
.app-main {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Glass card */
.glass {
    background: linear-gradient(135deg, rgba(18, 22, 55, 0.82), rgba(7, 11, 35, 0.9));
    border-radius: 22px;
    padding: 1.4rem 1.6rem;
    border: 1px solid rgba(132, 150, 255, 0.35);
    box-shadow:
        0 18px 45px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(16px);
}

/* Filters */
.filters-card {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.filters-header h2 {
    margin: 0;
    font-size: 1.3rem;
}

.filters-header p {
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field.compact {
    justify-content: flex-end;
}

label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Inputs & selects */
select,
input[type="number"] {
    width: 100%;
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    border: 1px solid rgba(132, 150, 255, 0.6);
    background: rgba(4, 7, 20, 0.9);
    color: #f7f7ff;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

select:focus,
input[type="number"]:focus {
    border-color: #18ffff;
    box-shadow: 0 0 0 1px rgba(24, 255, 255, 0.35);
    background: rgba(6, 10, 27, 0.95);
}

select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Buttons */
.primary-btn {
    padding: 0.55rem 1.2rem;
    border-radius: 999px;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    background: linear-gradient(135deg, #18ffff, #7c4dff);
    color: #050609;
    box-shadow: 0 9px 24px rgba(24, 255, 255, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.primary-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 12px 30px rgba(24, 255, 255, 0.55);
}

.primary-btn:active {
    transform: translateY(1px);
    box-shadow: 0 5px 18px rgba(24, 255, 255, 0.35);
}

.chip-btn {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(132, 150, 255, 0.6);
    background: rgba(6, 11, 35, 0.9);
    color: #d0d4ff;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.chip-btn:hover {
    background: rgba(10, 17, 53, 0.95);
    border-color: #18ffff;
    transform: translateY(-1px);
}

.chip-btn:active {
    transform: translateY(1px);
}

/* Summary row */
.summary-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.summary-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.summary-card h3 {
    margin: 0;
    font-size: 1rem;
}

.summary-value {
    margin: 0.2rem 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.summary-label {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ===== כרטיס השוואה ===== */
.compare-card {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.compare-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.compare-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.compare-subtext {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    opacity: 0.8;
}

.compare-warning {
    font-size: 0.8rem;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 193, 7, 0.12);
    border: 1px solid rgba(255, 193, 7, 0.6);
    color: #ffe082;
}

.compare-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.3fr);
    gap: 1rem;
}

.compare-table-wrapper {
    overflow-x: auto;
}

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.compare-table thead {
    background: linear-gradient(90deg, rgba(10, 16, 45, 0.98), rgba(3, 10, 35, 0.98));
}

.compare-table th,
.compare-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid rgba(42, 56, 120, 0.55);
    text-align: right;
}

.compare-table th {
    font-size: 0.8rem;
    opacity: 0.9;
}

.compare-table tbody tr:nth-child(odd) {
    background: rgba(2, 6, 20, 0.75);
}

.compare-table tbody tr:nth-child(even) {
    background: rgba(2, 5, 18, 0.95);
}

.compare-table td.metric-label {
    font-weight: 500;
    white-space: nowrap;
}

.compare-table td.highlight-max {
    background: radial-gradient(circle at center, rgba(24, 255, 255, 0.24), rgba(6, 10, 32, 0.95));
    box-shadow: inset 0 0 0 1px rgba(24, 255, 255, 0.6);
    font-weight: 600;
}

.compare-chart-wrapper {
    background: radial-gradient(circle at top, rgba(13, 19, 51, 0.98), rgba(3, 6, 18, 0.98));
    border-radius: 18px;
    border: 1px solid rgba(132, 150, 255, 0.4);
    padding: 0.75rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
}

/* Table card */
.table-card {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.table-header-row h2 {
    margin: 0;
    font-size: 1.3rem;
}

.table-header-row p {
    margin: 0.3rem 0 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Status bar */
.status-bar {
    font-size: 0.85rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    background: rgba(4, 7, 22, 0.9);
    border: 1px dashed rgba(120, 143, 255, 0.5);
    opacity: 0.92;
}

/* Table wrapper – בלי גלילה אופקית */
.table-wrapper {
    position: relative;
    border-radius: 18px;
    border: 1px solid rgba(132, 150, 255, 0.4);
    background: radial-gradient(circle at top, rgba(13, 19, 51, 0.98), rgba(3, 6, 18, 0.98));
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
}

/* Table */
.funds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
    position: relative;
    z-index: 1;
    table-layout: fixed;
}

.funds-table thead {
    background: linear-gradient(90deg, rgba(10, 16, 45, 0.98), rgba(3, 10, 35, 0.98));
}

.funds-table th,
.funds-table td {
    padding: 0.5rem 0.45rem;
    text-align: right;
    border-bottom: 1px solid rgba(42, 56, 120, 0.55);
}

/* כותרות יכולות לרדת לשתי שורות */
.funds-table th {
    font-size: 0.8rem;
    opacity: 0.9;
    white-space: normal;
    word-wrap: break-word;
}

/* ברירת מחדל – הערכים עצמם בשורה אחת */
.funds-table td {
    white-space: nowrap;
}

/* ✅ 4 העמודות הטקסטואליות: שם קופה, סיווג, התמחות, תת־התמחות – מותר לשבור שורה */
.funds-table td:nth-child(2),
.funds-table td:nth-child(3),
.funds-table td:nth-child(4),
.funds-table td:nth-child(5) {
    white-space: normal;
    word-wrap: break-word;
}

.funds-table tbody tr:nth-child(odd) {
    background: rgba(2, 6, 20, 0.72);
}

.funds-table tbody tr:nth-child(even) {
    background: rgba(2, 5, 18, 0.9);
}

.funds-table tbody tr:hover {
    background: rgba(10, 22, 70, 0.9);
}

.funds-table td {
    vertical-align: middle;
}

/* מספרים */
.funds-table td.num-col,
.funds-table td.num-col .num {
    direction: ltr;
    text-align: center;
    unicode-bidi: bidi-override;
}

/* צפיפות טבלה (מצב קומפקט) */
.funds-table.compact th,
.funds-table.compact td {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
}

/* Footer */
.app-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.8rem;
    opacity: 0.7;
    flex-wrap: wrap;
}

/* ---------- רספונסיביות כללית ---------- */

@media (max-width: 980px) {
    .filters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .summary-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .compare-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .app-root {
        padding: 1rem;
    }
    .filters-grid {
        grid-template-columns: 1fr;
    }
    .summary-row {
        grid-template-columns: 1fr;
    }
}

/* ---------- מצב כרטיסים – כשאי אפשר להציג את כל העמודות ---------- */
/* במסכים עד 900px כל שורה הופכת לכרטיס */

@media (max-width: 900px) {

    .table-wrapper {
        overflow-x: hidden;
        overflow-y: visible;
        border-radius: 0;
        border: none;
        background: transparent;
        max-width: 100%;
    }

    .funds-table {
        border-collapse: separate;
        border-spacing: 0 0.75rem;
        font-size: 0.8rem;
        min-width: 0;
    }

    .funds-table thead {
        display: none; /* הכותרות יעברו ל־data-label */
    }

    .funds-table tbody tr {
        display: block;
        background: linear-gradient(135deg, rgba(6, 10, 32, 0.98), rgba(3, 6, 20, 0.98));
        border-radius: 16px;
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
        overflow: hidden;
        border: 1px solid rgba(132, 150, 255, 0.4);
        margin-bottom: 0.75rem;
        width: 100%;
    }

    .funds-table tbody tr:hover {
        background: linear-gradient(135deg, rgba(10, 16, 46, 0.98), rgba(4, 9, 28, 0.98));
    }

    .funds-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid rgba(42, 56, 120, 0.45);
        padding: 0.45rem 0.8rem;
        white-space: normal; /* במסך קטן תמיד מותר לשבור שורה */
    }

    .funds-table td:last-child {
        border-bottom: none;
    }

    .funds-table td::before {
        content: attr(data-label);
        font-weight: 500;
        font-size: 0.8rem;
        color: #c5cae9;
        margin-left: 0.5rem;
        flex: 0 0 auto;
    }

    .funds-table td.num-col,
    .funds-table td.num-col .num {
        text-align: center;
        direction: ltr;
    }

    /* שם קופה – כותרת הכרטיס */
    .funds-table td[data-label="שם קופה"] {
        font-weight: 600;
        font-size: 0.95rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        padding-top: 0.6rem;
    }
}

/* טקסט משני מתחת לכותרת הטבלה */
.table-subtext {
    font-size: 0.85rem;
    color: #9aa0b2;
    margin-top: 4px;
    margin-bottom: 14px;
    line-height: 1.45;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 6px;
}

.table-subtext .table-icon {
    font-size: 1.05rem;
    opacity: 0.85;
    vertical-align: middle;
}

/* הדגשת הערך המקסימלי בעמודות התשואה */
.funds-table td.highlight-max {
    background: radial-gradient(circle at center, rgba(24, 255, 255, 0.24), rgba(6, 10, 32, 0.95));
    box-shadow: inset 0 0 0 1px rgba(24, 255, 255, 0.6);
    font-weight: 600;
}

/* ===== נגישות – לוח צדדי ===== */
.a11y-panel {
    position: fixed;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
    width: 180px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 0.6rem 0.7rem;
    border-radius: 16px;
    background: rgba(5, 9, 30, 0.96);
    border: 1px solid rgba(132, 150, 255, 0.7);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    z-index: 3000;
    backdrop-filter: blur(10px);
}

.a11y-panel.a11y-hidden {
    display: none;
}

.a11y-title {
    margin: 0 0 0.45rem;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: right;
}

.a11y-btn {
    width: 100%;
    margin-bottom: 0.25rem;
    padding: 0.25rem 0.4rem;
    border-radius: 10px;
    border: 1px solid rgba(132, 150, 255, 0.7);
    background: rgba(9, 13, 40, 0.95);
    color: #e0e4ff;
    font-size: 0.8rem;
    text-align: right;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-start;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.a11y-btn:hover {
    background: rgba(18, 26, 80, 0.98);
    border-color: #18ffff;
    transform: translateY(-1px);
}

.a11y-btn:active {
    transform: translateY(1px);
}

.a11y-reset {
    margin-top: 0.35rem;
    background: linear-gradient(135deg, #ff5252, #ffb74d);
    border-color: rgba(255, 255, 255, 0.6);
    color: #1b1b1b;
}

/* אייקון בתוך כפתור נגישות */
.a11y-icon {
    margin-left: 4px;
    font-size: 0.95rem;
}

/* כפתור צף לפתיחה/סגירה של הלוח */
.a11y-toggle {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid rgba(132, 150, 255, 0.8);
    background: radial-gradient(circle at top, #18ffff, #7c4dff);
    color: #061019;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3100;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.7);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.a11y-toggle:hover {
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.8);
    filter: brightness(1.05);
}

.a11y-toggle:active {
    transform: translateY(1px) scale(0.98);
}

/* התאמה למסכים קטנים יותר */
@media (max-width: 720px) {
    .a11y-panel {
        width: 150px;
        right: 0.25rem;
        padding: 0.5rem;
    }
}

/* מצבי נגישות בפועל */

/* מונוכרום */
body.a11y-monochrome {
    filter: grayscale(100%);
}

/* ניגודיות גבוהה */
body.a11y-high-contrast {
    background: #000 !important;
    color: #ffffff !important;
}

body.a11y-high-contrast .app-root,
body.a11y-high-contrast .glass,
body.a11y-high-contrast .table-wrapper {
    background: #000 !important;
    color: #ffffff !important;
    border-color: #ffffff !important;
}

/* הדגשת קישורים */
body.a11y-highlight-links a {
    outline: 2px solid #ffeb3b;
    outline-offset: 2px;
    text-decoration: underline;
}

/* גופן קריא */
body.a11y-readable-font {
    font-family: Arial, Helvetica, sans-serif;
}

/* ניווט מקלדת – פוקוס מודגש */
body.a11y-keyboard-nav *:focus {
    outline: 2px solid #ffeb3b !important;
    outline-offset: 3px;
}

/* חסימת אנימציות */
body.a11y-no-animations * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* סמן גדול */
body.a11y-big-cursor,
body.a11y-big-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><polygon points="0,0 0,32 8,24 14,30 18,26 12,20 20,20" fill="white" stroke="black" stroke-width="1"/></svg>') 0 0, auto !important;
}


/* נקודה מונפשת בכותרת הראשית */
.brand-dot {
    display: inline-block;
    padding: 0 2px;
    color: #18ffff;
    animation: pulse 1.8s infinite;
    transform-origin: center;
}

/* 🏆 קופה מובילה בטבלה */
.funds-table tr.best-fund td[data-label="שם קופה"]::after,
.funds-table tr.best-fund td:nth-child(2)::after {
    content: " 🏆";
    font-size: 1.1rem;
    margin-right: 6px;
    filter: drop-shadow(0 0 6px gold);
}

/* רקע עדין לכל השורה המובילה */
.funds-table tr.best-fund {
    background: linear-gradient(
        90deg,
        rgba(255, 215, 0, 0.08),
        rgba(255, 215, 0, 0.02)
    ) !important;
}

/* טול־טיפ לקופה המובילה – על תא "שם קופה" */
.funds-table tr.best-fund td:nth-child(2) {
    position: relative;
}

/* הבועה עצמה */
.funds-table tr.best-fund td:nth-child(2)::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    right: 0;
    transform: translateY(-6px);
    background: rgba(5, 9, 30, 0.96);
    color: #e0e4ff;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    border: 1px solid rgba(132, 150, 255, 0.7);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.6);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 20;
}

/* הצגת הטול־טיפ בהובר */
.funds-table tr.best-fund td:nth-child(2):hover::before {
    opacity: 1;
    transform: translateY(-10px);
}
