/**
 * ============================================================================
 * FINANCIAL CARDS SYSTEM V3.0 - UNIVERSAL CSS
 * ============================================================================
 * 
 * DESKTOP LAYOUT TYPES:
 * - Type 1: 3 coloane date + 3 insight boxes full width pe același rând
 * - Type 2: 3 coloane date + 4+ insight boxes cu scroll orizontal
 * - Type 3: 1/3 date stânga + 2/3 insight boxes dreapta (în același card)
 * 
 * MOBILE: Toate cardurile au același comportament (expand/collapse)
 * 
 * ============================================================================
 */

/* ===== RESET & GLOBALS ===== */

* {
    -webkit-tap-highlight-color: transparent;
}

/* ===== TITLURI SECȚIUNE ===== */

.fin-section-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 4rem 0 0.75rem 0;
    color: #ffffff;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.fin-section-intro {
    font-size: 0.98rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 0 1.5rem 0;
    max-width: 100%;
}

/* Highlight pentru nume companie */
.company-highlight {
    color: #2ada49;
    position: relative;
    display: inline;
    transition: all 0.3s ease;
}

.company-highlight::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #2ada49, transparent);
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.company-highlight:hover {
    color: #3fef5c;
}

.company-highlight:hover::after {
    opacity: 1;
}

/* ===== CARD PRINCIPAL - STRUCTURĂ COMUNĂ ===== */

.fin-card {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    border: 0;
    border-radius: 16px;
    padding: 2rem;
    color: #f1f1f1;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    position: relative;
    transition: all 0.4s ease;
    margin-bottom: 1.5rem;
    z-index: 20;
}

/* ===== HEADER CARD ===== */

.fin-card__header {
    margin-bottom: 1.5rem;
}

.fin-card__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.fin-card__title-icon {
    color: #2ada49;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
}

/* ===== BODY CARD - WRAPPER PENTRU CONȚINUT ===== */

.fin-card__body {
    position: relative;
    overflow: visible;
    transition: max-height 0.5s ease;
}

/* ===== FOOTER CARD ===== */

.fin-card__footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.fin-card__footer svg {
    flex-shrink: 0;
    opacity: 0.6;
}

/* ===== TYPE 1: 3 COLOANE DATE + 3 INSIGHTS FULL WIDTH ===== */

.fin-card--type-1 .fin-card__data-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
    align-items: flex-start;
}

/* ===== TYPE 2: 3 COLOANE DATE + 4+ INSIGHTS CU SCROLL ===== */

.fin-card--type-2 .fin-card__data-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
    align-items: flex-start;
}

/* ===== TYPE 3: 1/3 DATE + 2/3 INSIGHTS ÎN ACELAȘI CARD ===== */

.fin-card--type-3 .fin-card__layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 3rem;
    align-items: flex-start;
}

.fin-card--type-3 .fin-card__data-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.fin-card--type-3 .fin-card__insights-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===== COLOANE DE DATE ===== */

.fin-data-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ===== SECȚIUNE DATE ===== */

.fin-data-section {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.fin-data-section__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #2ada49;
    letter-spacing: 0.02em;
    margin: 0 0 0.5rem 0;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(42, 218, 73, 0.2);
}

/* ===== ITEM DATE ===== */

.fin-data-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    gap: 1rem;
}

.fin-data-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border-bottom-color: transparent;
}

.fin-data-item--highlight .fin-data-item__value {
    color: #2ada49;
    font-size: 1.05rem;
    font-weight: 700;
}

/* Label + Value */

.fin-data-item__label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    flex: 0 1 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    position: relative;
}

.fin-data-item__value {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    text-align: right;
    flex: 0 0 auto;
}

/* Stiluri speciale pentru valori */

.fin-data-item__value--dividend {
    color: #5b9aff;
}

.fin-data-item__value--debt {
    color: #ff6b6b;
}

.fin-data-item__value--cash {
    color: #2ada49;
}

.fin-data-item__value--ratio {
    color: #ffa500;
}

.fin-data-item__value--performance {
    color: #2ada49;
}

.fin-data-item__value--recommendation {
    text-transform: uppercase;
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    background: rgba(42, 218, 73, 0.15);
    border: 1px solid rgba(42, 218, 73, 0.3);
    border-radius: 12px;
    color: #2ada49;
    font-weight: 600;
}

/* ===== INFO ICON + TOOLTIP ===== */

.fin-info-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: #28292a;
    color: #ffffff;
    font-size: 0.7rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.fin-info-icon:hover,
.fin-info-icon:focus-visible {
    background: #333436;
    color: #ffffff;
    outline: none;
}

.fin-info-tooltip {
    position: absolute;
    left: 0;
    bottom: calc(100% + 0.5rem);
    transform: translateY(4px);
    margin: 0;
    background: #28292a;
    border-radius: 10px;
    border: none;
    padding: 0.7rem 0.9rem;
    font-size: 0.78rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.9);
    min-width: 240px;
    max-width: min(380px, calc(100vw - 32px));
    z-index: 999;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    white-space: normal;
    overflow-wrap: anywhere;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.fin-info-tooltip::before {
    content: "";
    position: absolute;
    bottom: -6px;
    left: 14px;
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #28292a transparent transparent transparent;
}

/* Afișare tooltip */

.fin-data-item__label:hover .fin-info-tooltip,
.fin-data-item__label:focus-within .fin-info-tooltip,
.fin-info-icon[aria-expanded="true"] + .fin-info-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ===== INSIGHT BOXES - CONTAINER ===== */

/* Container sub card pentru Type 1 & Type 2 */
.fin-insights-container {
    margin-top: 1.5rem;
    position: relative;
    width: 100%;
    z-index: 10;
}

/* Container în card pentru Type 3 */
.fin-card--type-3 .fin-insights-container {
    margin-top: 0;
}

/* ===== INSIGHT BOXES - TYPE 1 (3 insights full width) ===== */

.fin-insights-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* ===== INSIGHT BOXES - TYPE 2 (4+ insights cu scroll) ===== */

.fin-insights-scroll {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 1rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.fin-insights-scroll::-webkit-scrollbar {
    display: none;
}

/* Scrollbar custom DOAR când există clasa .has-scrollbar (4+ insights) */

@media (min-width: 1024px) {
    .fin-insights-scroll.has-scrollbar {
        scrollbar-width: thin;
        scrollbar-color: rgba(42, 218, 73, 0.4) rgba(255, 255, 255, 0.05);
    }

    .fin-insights-scroll.has-scrollbar::-webkit-scrollbar {
        height: 8px;
        display: block;
    }

    .fin-insights-scroll.has-scrollbar::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 10px;
    }

    .fin-insights-scroll.has-scrollbar::-webkit-scrollbar-thumb {
        background: rgba(42, 218, 73, 0.4);
        border-radius: 10px;
        transition: background 0.3s;
    }

    .fin-insights-scroll.has-scrollbar::-webkit-scrollbar-thumb:hover {
        background: rgba(42, 218, 73, 0.6);
    }
}

/* Pentru Type 2: fiecare insight ~30% width => scroll */
.fin-insights-scroll .fin-insight-box {
    flex: 0 0 30%;
    min-width: 30%;
    max-width: 30%;
}

/* ===== INSIGHT BOXES - TYPE 3 (în coloana din dreapta) ===== */

.fin-card--type-3 .fin-insight-box {
    flex: 1 1 auto;
    min-width: 0;
}

/* ===== INSIGHT BOX - STILURI COMUNE ===== */

.fin-insight-box {
    background: rgba(255, 255, 255, 0.03);
    border: none;
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.fin-insight-box:hover,
.fin-insight-box:active,
.fin-insight-box:focus {
    background: rgba(255, 255, 255, 0.06);
}

/* Header insight */

.fin-insight-box__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.fin-insight-box__icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, rgba(42, 218, 73, 0.2), rgba(42, 218, 73, 0.05));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #2ada49;
}

.fin-insight-box__title {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    margin: 0;
    line-height: 1.3;
}

/* Text insight */

.fin-insight-box__text-wrapper {
    position: relative;
    overflow: hidden;
    max-height: 6.5em;
    transition: max-height 0.4s ease;
}

.fin-insight-box.is-expanded .fin-insight-box__text-wrapper {
    max-height: 1000px;
}

.fin-insight-box__text {
    font-size: 0.875rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

/* Buton Read More */

.fin-insight-box__read-more {
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: none;
    color: #ffffff !important;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0 0 0;
    margin-top: 0.5rem;
    transition: all 0.2s ease;
    font-family: inherit;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.fin-insight-box__read-more-text {
    color: #ffffff !important;
}

.fin-insight-box__read-more-arrow {
    display: inline-block;
    transition: transform 0.2s ease;
    color: #ffffff !important;
}

.fin-insight-box__read-more:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

.fin-insight-box__read-more:hover .fin-insight-box__read-more-arrow {
    transform: translateX(3px);
}

/* Când e expanded, rotim săgeata */

.fin-insight-box.is-expanded .fin-insight-box__read-more-arrow {
    transform: rotate(-90deg);
}

/* ===== MOBILE CONTROLS (expand/collapse card) ===== */

.fin-card__fade-overlay,
.fin-card__expand-btn,
.fin-card__close-btn {
    display: none;
}

/* ===== TABLET RESPONSIVE (1024px - 1199px) ===== */

@media (max-width: 1199px) and (min-width: 769px) {
    .fin-card--type-1 .fin-card__data-grid,
    .fin-card--type-2 .fin-card__data-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }

    .fin-data-column {
        gap: 1.5rem;
    }

    /* Type 3 păstrează 1/3 + 2/3 pe tablet */
}

/* ===== MOBILE RESPONSIVE (<= 768px) ===== */

@media (max-width: 768px) {
    .fin-section-title {
        font-size: 1.5rem;
        margin-top: 2.5rem;
    }

    .fin-section-intro {
        font-size: 0.9rem;
        margin-bottom: 1.25rem;
    }

    /* CARD PRINCIPAL */

    .fin-card {
        padding: 1.5rem;
        min-height: 270px;
    }

    .fin-card.is-expanded {
        min-height: auto;
    }

    .fin-card__body {
        max-height: 230px;
        overflow: hidden;
    }

    .fin-card.is-expanded .fin-card__body,
    .fin-card.has-tooltip-open .fin-card__body {
        max-height: 5000px;
        overflow: visible;
    }

    /* TOATE tipurile devin 1 coloană pe mobile */

    .fin-card--type-1 .fin-card__data-grid,
    .fin-card--type-2 .fin-card__data-grid,
    .fin-card--type-3 .fin-card__layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .fin-data-column {
        gap: 1.5rem;
    }

    .fin-data-section {
        gap: 0.25rem;
    }

    .fin-data-item {
        padding: 0.4rem 0.4rem;
    }

    .fin-info-tooltip {
        min-width: 210px;
        max-width: min(320px, calc(100vw - 24px));
        font-size: 0.75rem;
    }

    /* FADE OVERLAY pentru expand/collapse */

    .fin-card__fade-overlay {
        display: block;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 120px;
        background: linear-gradient(to bottom, transparent 0%, rgba(51, 52, 53, 0.5) 50%, rgba(51, 52, 53, 0.85) 100%);
        pointer-events: none;
        opacity: 1;
        transition: opacity 0.3s ease;
        z-index: 5;
        border-radius: 0 0 16px 16px;
    }

    .fin-card.is-expanded .fin-card__fade-overlay {
        opacity: 0;
    }

    /* EXPAND BUTTON */

    .fin-card__expand-toggle {
        display: block;
        position: absolute;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        z-index: 10;
    }

    .fin-card.is-expanded .fin-card__expand-toggle {
        display: none;
    }

    .fin-card__expand-btn {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        background: rgba(42, 218, 73, 0.1);
        border: 1px solid rgba(42, 218, 73, 0.3);
        color: #2ada49;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        font-size: 0.85rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.3s ease;
        font-family: inherit;
    }

    .fin-card__expand-btn:hover {
        background: rgba(42, 218, 73, 0.15);
        border-color: #2ada49;
        transform: translateY(-1px);
    }

    /* CLOSE BUTTON */

    .fin-card__close-toggle {
        display: none;
        position: absolute;
        bottom: 1rem;
        right: 1rem;
        z-index: 10;
    }

    .fin-card.is-expanded .fin-card__close-toggle {
        display: block;
    }

    .fin-card__close-btn {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        background: rgba(42, 218, 73, 0.1);
        border: 1px solid rgba(42, 218, 73, 0.3);
        color: #2ada49;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        font-size: 0.85rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.3s ease;
        font-family: inherit;
    }

    .fin-card__close-btn:hover {
        background: rgba(42, 218, 73, 0.15);
        border-color: #2ada49;
        transform: translateY(-1px);
    }

    /* CARD HEADER mobile */

    .fin-card__title {
        font-size: 1.5rem;
        gap: 0.6rem;
    }

    .fin-card__title-icon {
        width: 24px;
        height: 24px;
    }

    /* INSIGHTS pe mobile - devin scroll orizontal */

    .fin-insights-container {
        margin-top: 1.25rem;
    }

    /* Type 1: 3 insights => scroll pe mobile */
    .fin-insights-row {
        display: flex;
        gap: 1rem;
        overflow-x: auto;
        overflow-y: visible;
        padding-bottom: 0.5rem;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        grid-template-columns: none; /* override grid */
    }

    .fin-insights-row::-webkit-scrollbar {
        display: none;
    }

    .fin-insights-row .fin-insight-box,
    .fin-insights-scroll .fin-insight-box,
    .fin-card--type-3 .fin-insight-box {
        flex: 0 0 calc(85% - 0.5rem);
        min-width: 260px;
        max-width: none;
        padding: 1rem;
    }

    /* Type 2 & Type 3 rămân la fel - scroll orizontal */

    .fin-insights-scroll {
        gap: 1rem;
        padding-bottom: 0.5rem;
    }

    .fin-insight-box__text {
        font-size: 0.85rem;
        line-height: 1.5;
    }
}

/* ===== MOBILE MIC (<= 480px) ===== */

@media (max-width: 480px) {
    .fin-card {
        padding: 1rem;
        min-height: 260px;
    }

    .fin-card__body {
        max-height: 210px;
    }

    .fin-card__fade-overlay {
        height: 100px;
    }

    .fin-card__title {
        font-size: 1.35rem;
        margin-bottom: 1rem;
        gap: 0.5rem;
    }

    .fin-data-item {
        padding: 0.35rem 0.3rem;
        gap: 0.5rem;
    }

    .fin-data-section__title {
        margin-bottom: 0.35rem;
        padding-bottom: 0.3rem;
        font-size: 0.85rem;
    }

    .fin-data-item__label {
        font-size: 0.85rem;
    }

    .fin-data-item__value {
        font-size: 0.9rem;
    }

    .fin-insights-row .fin-insight-box,
    .fin-insights-scroll .fin-insight-box,
    .fin-card--type-3 .fin-insight-box {
        flex: 0 0 calc(87% - 0.5rem);
        min-width: 240px;
        padding: 0.9rem;
    }

    .fin-insight-box__text {
        font-size: 0.825rem;
    }

    .fin-insight-box__read-more {
        font-size: 0.75rem;
    }
}

/* ===== UTILITIES ===== */

.fin-card--type-3 .fin-card__data-column .fin-data-column:last-child {
    margin-bottom: 0;
}
