/*
 * Fondsportalen - Premium Design
 * Professional fintech aesthetic with punch
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Brand Colors */
    --navy: #0a1628;
    --navy-600: #0f2847;
    --navy-500: #1a3a5c;
    --magenta: #FF2B83;
    --magenta-dark: #e0256f;

    /* Neutrals */
    --white: #ffffff;
    --gray-25: #fcfcfd;
    --gray-50: #f9fafb;
    --gray-100: #f2f4f7;
    --gray-200: #e4e7ec;
    --gray-300: #d0d5dd;
    --gray-400: #98a2b3;
    --gray-500: #667085;
    --gray-600: #475467;
    --gray-700: #344054;
    --gray-800: #1d2939;
    --gray-900: #101828;

    /* Semantic - WCAG AA compliant */
    --green: #027a48;
    --green-light: #ecfdf3;
    --red: #b42318;
    --red-light: #fef3f2;
    --amber: #b54708;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(16,24,40,0.05);
    --shadow-sm: 0 1px 3px rgba(16,24,40,0.1), 0 1px 2px rgba(16,24,40,0.06);
    --shadow-md: 0 4px 8px -2px rgba(16,24,40,0.1), 0 2px 4px -2px rgba(16,24,40,0.06);
    --shadow-lg: 0 12px 16px -4px rgba(16,24,40,0.08), 0 4px 6px -2px rgba(16,24,40,0.03);
    --shadow-xl: 0 20px 24px -4px rgba(16,24,40,0.08), 0 8px 8px -4px rgba(16,24,40,0.03);
    --shadow-2xl: 0 24px 48px -12px rgba(16,24,40,0.18);
    --shadow-card: 0 1px 3px rgba(16,24,40,0.1), 0 1px 2px rgba(16,24,40,0.06), 0 0 0 1px rgba(16,24,40,0.05);
    --shadow-card-hover: 0 12px 24px -4px rgba(16,24,40,0.12), 0 0 0 1px rgba(16,24,40,0.08);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    position: relative;
    overscroll-behavior-x: none;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== NAVIGATION ===== */
.globalnav {
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--gray-200);
}

.globalnav-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.globalnav-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.globalnav-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--navy);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    color: var(--white);
}

.globalnav-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.globalnav-links {
    display: flex;
    gap: 4px;
}

.globalnav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    text-decoration: none;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    transition: all 0.15s;
}

.globalnav-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* ===== HERO - Clean & Light ===== */
.hero-section {
    background: var(--white);
    text-align: center;
    padding: 64px 24px 48px;
    border-bottom: 1px solid var(--gray-200);
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.hero-eyebrow::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--green);
    border-radius: 50%;
}

.hero-headline {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--gray-900);
    margin-bottom: 12px;
    line-height: 1.1;
}

.hero-subhead {
    font-size: 18px;
    color: var(--gray-500);
    max-width: 440px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ===== STATS ===== */
.stats-section {
    background: var(--white);
    padding: 0 24px 40px;
    border-bottom: 1px solid var(--gray-200);
}

.stats-grid {
    max-width: 600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 32px;
    text-align: center;
}

.stat-item {
    padding: 16px 0;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-value.accent {
    color: var(--green);
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== TOOLBAR ===== */
.toolbar-section {
    background: var(--white);
    padding: 20px 0;
    margin-top: 32px;
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
}

.toolbar-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.search-field {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-field-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--gray-400);
}

.search-field-input {
    width: 100%;
    height: 48px;
    padding: 0 20px 0 48px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    font-size: 15px;
    font-family: inherit;
    color: var(--gray-900);
    transition: all 0.2s;
}

.search-field-input::placeholder {
    color: var(--gray-400);
}

.search-field-input:focus {
    outline: none;
    border-color: var(--navy);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(10,22,40,0.08);
}

.filter-group {
    display: flex;
    gap: 8px;
}

.select-field {
    height: 48px;
    padding: 0 40px 0 16px;
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    transition: all 0.2s;
}

.select-field:focus {
    outline: none;
    border-color: var(--navy);
    background-color: var(--white);
    box-shadow: 0 0 0 4px rgba(10,22,40,0.08);
}

/* ===== TABLE ===== */
.table-section {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 100px;
}

.table-card {
    background: var(--white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.table-risk-notice {
    font-size: 11px;
    color: var(--gray-500);
    text-align: center;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-100);
    margin: 0;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--gray-50);
}

th {
    padding: 16px 20px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--gray-200);
}

th.num { text-align: right; }

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

th.sortable:hover {
    color: var(--gray-900);
}

th.sortable .th-content {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

th.sortable .sort-icon {
    width: 14px;
    height: 14px;
    opacity: 0.3;
    transition: opacity 0.15s, transform 0.15s;
    flex-shrink: 0;
}

th.sortable:hover .sort-icon {
    opacity: 0.5;
}

th.sortable.sort-active {
    color: var(--gray-900);
}

th.sortable.sort-active .sort-icon {
    opacity: 1;
    color: var(--primary);
}

th.sortable.sort-asc .sort-icon path:last-child {
    opacity: 0.2;
}

th.sortable.sort-desc .sort-icon path:first-child {
    opacity: 0.2;
}

td {
    padding: 0 20px;
    height: 80px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 15px;
}

tbody tr {
    transition: background 0.15s;
}

tbody tr:hover {
    background: var(--gray-25);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Fund Cell */
.fund-cell {
    display: flex;
    align-items: center;
    gap: 14px;
}

.fund-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.fund-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.fund-icon span {
    font-size: 12px;
    font-weight: 700;
    color: var(--gray-500);
}

.fund-info {
    min-width: 0;
}

.fund-name-link {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-900);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    transition: color 0.15s;
}

.fund-name-link:hover {
    color: var(--magenta);
}

.fund-name-link span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.fund-isin {
    font-size: 12px;
    color: var(--gray-500);
    font-family: ui-monospace, 'SF Mono', monospace;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* Values */
.value-positive {
    color: var(--green);
}

.value-negative {
    color: var(--red);
}

.value-neutral {
    color: var(--gray-500);
}

/* Stars */
.stars {
    display: inline-flex;
    gap: 2px;
}

.stars svg {
    width: 18px;
    height: 18px;
    fill: var(--gray-200);
}

.stars svg.filled {
    fill: var(--amber);
}

/* Buttons */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.th-ad-label {
    display: block;
    font-size: 9px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius-lg);
    transition: all 0.2s;
    cursor: pointer;
    border: none;
}

.btn-logo {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.btn-nordnet {
    background: var(--navy);
    color: var(--white);
}

.btn-nordnet:hover {
    background: var(--navy-600);
}

.btn-kron {
    background: #FF2B83;
    color: var(--white);
}

.btn-kron:hover {
    background: #e0256f;
}

/* Checkbox */
.th-select, .td-select {
    width: 52px;
    text-align: center;
}

.fund-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    transition: all 0.15s;
}

.fund-checkbox:checked {
    background: var(--navy);
    border-color: var(--navy);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

.fund-checkbox:hover {
    border-color: var(--navy);
}

/* Pagination */
.pagination-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.pagination-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 20px;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn svg {
    width: 18px;
    height: 18px;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-300);
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    padding: 0 16px;
}

/* Compare Bar */
.compare-bar {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    background: var(--navy);
    padding: 16px 24px;
    border-radius: var(--radius-2xl);
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: var(--shadow-2xl);
}

.compare-bar:not([hidden]) {
    transform: translateX(-50%) translateY(0);
}

.compare-bar-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.compare-bar-funds {
    display: flex;
    gap: 8px;
}

.compare-bar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.compare-count {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
}

.btn-compare-clear {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--white);
    padding: 10px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-compare-clear:hover {
    background: rgba(255,255,255,0.15);
}

.btn-compare {
    background: var(--magenta);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-compare:hover {
    background: var(--magenta-dark);
}

/* Footer */
.footer {
    background: var(--gray-900);
    padding: 40px 24px;
    margin-top: auto;
}

.footer-content {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-legal {
    font-size: 14px;
    color: var(--gray-400);
}

.footer-links {
    display: flex;
    gap: 32px;
}

.footer-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-400);
    text-decoration: none;
    transition: color 0.15s;
}

.footer-link:hover {
    color: var(--white);
}

/* Loading */
.loading-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--gray-500);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--navy);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 16px;
}

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

/* Utility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .globalnav-logo-text { display: none; }
    .globalnav-content { padding: 0 16px; }

    .hero-section { padding: 60px 16px 56px; }
    .hero-headline { font-size: 36px; }
    .hero-subhead { font-size: 16px; }

    .stats-section { margin-top: -32px; }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-item { padding: 20px 12px; }
    .stat-value { font-size: 26px; }

    .toolbar-section { margin-top: 24px; padding: 20px 16px; }
    .toolbar-content { flex-direction: column; padding: 0; }
    .search-field { min-width: 100%; width: 100%; }
    .filter-group { width: 100%; flex-wrap: wrap; }
    .select-field { flex: 1; min-width: 0; }

    .table-section { padding: 24px 16px 80px; }

    .compare-bar {
        left: 16px;
        right: 16px;
        transform: translateX(0) translateY(150%);
    }
    .compare-bar:not([hidden]) {
        transform: translateX(0) translateY(0);
    }
    .compare-bar-content {
        flex-direction: column;
        gap: 14px;
    }

    .footer-content {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .fund-name-link span { max-width: 160px; }
    .actions { flex-direction: column; gap: 6px; }
    .btn {
        padding: 12px 14px;
        font-size: 13px;
        min-height: 44px;
        min-width: 44px;
    }

    /* Prevent horizontal scroll */
    .table-card { margin: 0 -16px; border-radius: 0; }
    .table-scroll { padding: 0 16px; }

    /* Ensure all interactive elements are touch-friendly */
    .select-field { min-height: 48px; }
    .search-field-input { min-height: 48px; }
    .pagination-btn { min-height: 48px; padding: 0 16px; }
}
