/* Stiluri pentru modulul de portofoliu */

/* Header modul — titlu + buton refresh */
.module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.module-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.portfolio-last-updated {
    font-size: 0.72rem;
    color: var(--text-secondary, #64748b);
    white-space: nowrap;
}

.portfolio-refresh-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    background: var(--card-bg, #fff);
    color: var(--text-primary, #1e293b);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.portfolio-refresh-btn:hover:not(:disabled) {
    background: var(--primary-color, #4CAF50);
    border-color: var(--primary-color, #4CAF50);
    color: #fff;
}

.portfolio-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Animatie rotire icon refresh */
@keyframes portfolio-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 0; /* Eliminat padding pentru a ocupa lățimea completă */
    width: 100%; /* Lățime completă */
    margin: 0 0 1rem 0; /* Margin doar jos pentru spacing */
}

.portfolio-card {
    background: var(--card-bg, #ffffff);
    border-radius: 8px;
    padding: 0; /* Schimbat pentru a acomoda header + content */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: visible; /* Schimbat din hidden - pentru a vedea butoanele */
    transition: all 0.3s ease;
    width: 100%; /* Lățime completă */
    margin: 0 0 1rem 0; /* Margin doar jos pentru spacing între carduri standalone */
}

/* Card Header - conține titlul și butonul de collapse */
.portfolio-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    padding-bottom: 1rem;
    background: transparent;
    border-bottom: 2px solid var(--primary-color, #4CAF50);
    overflow: visible; /* Asigură că butonul e vizibil */
    width: 100%;
}

.portfolio-card .card-header h3 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-primary, #333);
    border-bottom: none; /* Eliminăm border-ul vechi de pe h3 */
    padding-bottom: 0;
}

/* Collapse Button - stilizare similar cu Dashboard */
.portfolio-card .collapse-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #666);
    min-width: 32px;
    min-height: 32px;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.portfolio-card .collapse-btn svg {
    width: 20px;
    height: 20px;
    transition: opacity 0.2s ease; /* ✅ Doar opacity, nu mai rotim */
    display: block;
    stroke: currentColor;
}

.portfolio-card .collapse-btn svg path {
    stroke: currentColor;
}

.portfolio-card .collapse-btn:hover {
    background: var(--hover-bg, rgba(0, 0, 0, 0.1));
    color: var(--primary-color, #4CAF50);
    border-color: var(--primary-color, #4CAF50);
}

/* Card Content - partea care se collapse/expand */
.portfolio-card .card-content {
    padding: 1.5rem;
    max-height: none;
    overflow: hidden; /* Overflow doar pe content, nu pe card */
    transition: max-height 0.3s ease, padding 0.3s ease;
}

/* Card în stare collapsed */
.portfolio-card.collapsed .card-content {
    max-height: 0 !important;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

/* ✅ Nu mai rotim SVG-ul, simbolurile +/- se schimbă prin JavaScript */

/* Compatibility cu vechiul cod - h3 direct în card (fără header) */
.portfolio-card h3 {
    margin: 0 0 1.5rem;
    font-size: 1.3rem;
    color: var(--text-primary, #333);
    border-bottom: 2px solid var(--primary-color, #4CAF50);
    padding-bottom: 0.5rem;
}

/* Portfolio Summary Card - Ocupă întreaga lățime */
.portfolio-summary-card {
    grid-column: 1 / -1;
}

.portfolio-summary-grid {
    display: grid;
    grid-template-columns: 1fr; /* ✅ FIX (08 Feb 2026): Întotdeauna pe verticală (o coloană) */
    gap: 2rem;
}

.account-section {
    padding: 0.75rem;
    border-radius: 8px;
    background: var(--section-bg, #f8f9fa);
    position: relative; /* Pentru poziționarea butonului collapse */
    transition: padding 0.3s ease; /* ✅ Animație smooth pentru padding când se face collapse */
}

/* Section Header - conține titlul și butoanele de collapse + move */
.account-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    position: relative;        /* necesar pentru progress bar absolut */
    padding-bottom: 2px;       /* spatiu pentru progress bar */
}

/* Progress bar loading — apare la baza section-header, pe toata latimea */
.section-loading-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.section-loading-bar.visible {
    opacity: 1;
}

.section-loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--primary-color, #4CAF50) 40%,
        var(--primary-color, #4CAF50) 60%,
        transparent 100%
    );
    animation: portfolio-progress-slide 1.2s ease-in-out infinite;
}

@keyframes portfolio-progress-slide {
    0%   { left: -40%; }
    100% { left: 100%; }
}

.account-section h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #333);
    padding-bottom: 0;
    border-bottom: none; /* Eliminăm border-ul vechi */
    flex: 1; /* Ocupă tot spațiul disponibil */
}

/* Section Header Actions - container pentru butoane */
.section-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem; /* Spațiu între butoane */
}

/* Move Section Buttons - butoane pentru mutare stânga/dreapta */
.move-section-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.3rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #666);
    min-width: 26px;
    min-height: 26px;
    flex-shrink: 0;
}

.move-section-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
    display: block;
    stroke: currentColor;
}

.move-section-btn:hover:not(:disabled) {
    background: var(--hover-bg, rgba(0, 0, 0, 0.1));
    color: var(--primary-color, #4CAF50);
    border-color: var(--primary-color, #4CAF50);
}

.move-section-btn:hover:not(:disabled) svg {
    transform: scale(1.1);
}

.move-section-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.02);
}

.move-section-btn:disabled:hover {
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-secondary, #666);
    border-color: rgba(0, 0, 0, 0.1);
}

/* Section Collapse Button - buton mic pentru secțiuni (aceeași dimensiune cu move buttons) */
.section-collapse-btn {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.3rem;           /* ✅ Redus de la 0.35rem la 0.3rem */
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #666);
    min-width: 26px;           /* ✅ Redus de la 28px la 26px */
    min-height: 26px;          /* ✅ Redus de la 28px la 26px */
    flex-shrink: 0;
}

.section-collapse-btn svg {
    width: 14px;               /* ✅ Redus de la 16px la 14px */
    height: 14px;              /* ✅ Redus de la 16px la 14px */
    transition: opacity 0.2s ease; /* ✅ Doar opacity, nu mai rotim */
    display: block;
    stroke: currentColor;
}

.section-collapse-btn:hover {
    background: var(--hover-bg, rgba(0, 0, 0, 0.1));
    color: var(--primary-color, #4CAF50);
    border-color: var(--primary-color, #4CAF50);
}

/* Section Content - partea care se collapse/expand */
.account-section .section-content {
    max-height: none;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

/* Section în stare collapsed */
.account-section.collapsed .section-content {
    max-height: 0 !important;
    opacity: 0;
    overflow: hidden;
}

/* ✅ Reduce padding-ul top și bottom când secțiunea este collapsed */
.account-section.collapsed {
    padding-top: 2px;
    padding-bottom: 2px;
    transition: padding 0.3s ease;
}

/* ✅ Nu mai rotim SVG-ul, simbolurile +/- se schimbă prin JavaScript */

/* Păstrăm h4 pentru compatibilitate (secțiuni fără header) */
.account-section h4 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, #333);
}

/* SPOT Section - Layout special cu grafic */
.spot-section h4 {
    color: #2196F3;
}

.spot-content {
    display: flex;
    flex-wrap: nowrap; /* Previne wrap - totul pe un singur rând */
    gap: 1rem;
    align-items: stretch; /* STRETCH - face toate copiii să aibă aceeași înălțime */
    justify-content: space-between;
    width: 100%;
    overflow: visible; /* Permite tooltip să iasă din container */
}

.spot-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 0 0 auto;
    min-width: fit-content;
}

.spot-metrics .summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.spot-metrics .summary-item:last-child {
    margin-bottom: 0;
}

.spot-metrics .summary-item .label {
    font-size: 0.75rem;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.spot-metrics .summary-item .value {
    font-size: 14px;
    font-weight: 600;
    text-align: right;
    flex: 0 0 auto;
}

.spot-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Aliniere sus pentru consistență cu spot-metrics */
    flex: 1 1 auto; /* Permite extindere pentru a ține chart + legendă */
    min-width: 200px; /* Spațiu pentru chart (100px) + legendă (100px) */
    max-width: 400px; /* Limită maximă */
    perspective: 1000px; /* Activează perspectiva 3D */
    height: 100%; /* CRITICAL: Ia întreaga înălțime a containerului (spot-content) */
    min-height: fit-content; /* Asigură că minimul este conținutul */
}

/* Fallback pentru canvas (dacă încă există) */
.spot-chart canvas {
    width: 100px !important;
    height: 100px !important;
    transform: rotateX(15deg) rotateY(-5deg);
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

.spot-chart canvas:hover {
    transform: rotateX(20deg) rotateY(-10deg) scale(1.05);
}

/* FUTURES Section - Layout similar cu SPOT */
.futures-section h4 {
    color: #9C27B0;
}

.futures-content {
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem;
    align-items: stretch;
    justify-content: space-between;
    width: 100%;
    overflow: visible;
}

.futures-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 0 0 auto;
    min-width: fit-content;
}

.futures-metrics .summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.futures-metrics .summary-item:last-child {
    margin-bottom: 0;
}

.futures-metrics .summary-item .label {
    font-size: 0.75rem;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.futures-metrics .summary-item .value {
    font-size: 14px;
    font-weight: 600;
    text-align: right;
    flex: 0 0 auto;
}

.futures-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex: 1 1 auto;
    min-width: 200px;
    max-width: 400px;
    perspective: 1000px;
    height: 100%;
    min-height: fit-content;
}

.total-section h4 {
    color: #4CAF50;
}

.total-section {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.01) 0%, rgba(76, 175, 80, 0.01) 100%);
    border: 2px solid rgba(76, 175, 80, 0.3);
}

.summary-item {
    display: flex;
    flex-direction: row;           /* Horizontal: label stânga, value dreapta */
    align-items: center;           /* Aliniere verticală centrată */
    justify-content: space-between; /* Spațiu între label și value */
    gap: 1rem;                     /* Spațiu între label și value */
    margin-bottom: 0.75rem;
}

.summary-item:last-child {
    margin-bottom: 0;
}

.summary-item .label {
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
    margin-bottom: 0;              /* Elimină margin pentru layout horizontal */
    flex: 0 0 auto;                /* Nu se extinde */
    text-align: left;              /* Aliniere stânga */
}

.summary-item .value {
    font-size: 14px;               /* EXACT 14px */
    font-weight: 600;              /* Bold */
    color: var(--text-primary, #333);
    text-align: right;             /* Aliniere dreapta */
    flex: 0 0 auto;                /* Nu se extinde */
}

.summary-item .total-value {
    font-size: 14px;               /* EXACT 14px (consistent cu .value) */
    font-weight: 700;              /* Extra bold pentru TOTAL */
    color: #4CAF50;
    text-align: right;             /* Aliniere dreapta */
    flex: 0 0 auto;                /* Nu se extinde */
}

.value.positive {
    color: var(--color-success, #28a745);
}

.value.negative {
    color: var(--color-danger, #dc3545);
}

/* Responsive */
@media (max-width: 1200px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
    
    .portfolio-summary-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Responsive pentru SPOT section - grafic sub metrici pe ecrane mici */
@media (max-width: 768px) {
    .spot-content {
        flex-direction: column;
        align-items: center;
    }
    
    .spot-metrics {
        width: 100%;
    }
    
    .spot-chart {
        margin-top: 1rem;
    }
    
    /* Responsive pentru FUTURES section */
    .futures-content {
        flex-direction: column;
        align-items: center;
    }
    
    .futures-metrics {
        width: 100%;
    }
    
    .futures-chart {
        margin-top: 1rem;
    }
}

.chart-container {
    width: 100%;
    height: 300px;
    margin-top: 1rem;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ⚠️ IMPORTANT: Aplica doar pentru canvas-urile Chart.js din portofoliu, NU pentru Lightweight Charts! */
.chart-container canvas {
    width: 100% !important;
    height: 300px !important;
    max-height: 300px !important;
    aspect-ratio: 16/9;
}

#portfolio-distribution,
#portfolio-performance {
    height: 400px;
    max-height: 400px;
    display: flex;
    flex-direction: column;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color, #eee);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item .label {
    color: var(--text-secondary, #666);
}

.table-container {
    overflow-x: auto;
    margin-top: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color, #eee);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary, #666);
    background: var(--table-header-bg, #f8f9fa);
}

.position-side {
    text-transform: uppercase;
    font-weight: 600;
}

.position-side.long {
    color: var(--color-success, #28a745);
}

.position-side.short {
    color: var(--color-danger, #dc3545);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-danger {
    background-color: var(--color-danger, #dc3545);
    color: white;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg, #ffffff);
    border-radius: 8px;
    padding: 1rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary, #666);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

@media (max-width: 1200px) {
    .portfolio-summary-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 0.9rem;
    }
    
    .summary-item .value {
        font-size: 14px;  /* Păstrează 14px și pe mobile */
    }
    
    .summary-item .total-value {
        font-size: 14px;  /* Consistent cu .value */
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .portfolio-card {
        --card-bg: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #aaaaaa;
        --border-color: #444444;
        --table-header-bg: #333333;
    }
}

/* ============================================
   🎨 ANIMATED RING CHART SVG STYLES
   ============================================ */

.svg-ring-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0;
}

.svg-ring-container {
    display: flex;
    flex-direction: row; /* Horizontal layout: chart la stânga, legendă la dreapta */
    align-items: flex-start; /* Aliniere sus */
    gap: 1rem;
    width: 100%;
    max-width: 100%; /* Folosește tot spațiul disponibil */
    position: relative; /* Context pentru poziționare */
    z-index: 1; /* Asigură că container-ul are propriul stacking context */
    overflow: visible; /* Permite overflow pentru efecte vizuale */
}

.svg-ring-empty {
    text-align: center;
    padding: 1rem;
}

.ring-chart {
    width: 100px;
    height: 100px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.05)); /* Umbră mai subtilă - 50% opacitate */
    transition: transform 0.3s ease;
    position: relative; /* Pentru stacking context */
    z-index: 10; /* Deasupra legendei dar sub tooltip */
    overflow: visible !important; /* CRITICAL: Permite tooltip să iasă din bounds */
}

.ring-chart:hover {
    transform: scale(1.02);
}

/* Ring segments - interactive */
.ring-segment {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.ring-segment:hover {
    stroke-width: 12 !important;
    filter: url(#ring-glow) url(#ring-shadow) !important;
}

/* Ring Legend - listă interactivă (alături de chart) */
.ring-legend {
    display: flex;
    flex-direction: column;
    gap: 0; /* FĂRĂ spațiu între items pentru layout compact */
    flex: 1; /* Ia spațiul rămas */
    min-width: 0; /* Permite shrink dacă necesar */
    margin-top: 0; /* Elimină margin-top - e pe același rând */
    max-height: 120px; /* Limită înălțime pentru a se potrivi cu chart-ul */
    overflow-y: auto; /* Scroll dacă sunt prea multe items */
    padding-right: 0.25rem; /* Spațiu pentru scrollbar */
    position: relative; /* Pentru stacking context */
    z-index: 5; /* Sub chart și tooltip, dar deasupra background */
}

/* Scrollbar stilizat pentru ring-legend */
.ring-legend::-webkit-scrollbar {
    width: 4px;
}

.ring-legend::-webkit-scrollbar-track {
    background: transparent;
}

.ring-legend::-webkit-scrollbar-thumb {
    background: var(--border-color, #cbd5e1);
    border-radius: 2px;
}

.ring-legend::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary, #94a3b8);
}

.ring-legend-item {
    display: grid;
    grid-template-columns: 12px auto 1fr auto; /* Reduced pentru layout compact */
    gap: 0.5rem;
    align-items: center;
    padding: 0.35rem 0.5rem; /* Padding mai mic pentru compact */
    border-radius: 4px;
    background: var(--section-bg, #f8f9fa);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-size: 0.7rem; /* Text mai mic pentru layout compact */
}

.ring-legend-item:hover {
    background: var(--hover-bg, #e9ecef);
    transform: translateX(2px); /* Reduced pentru layout compact */
    border-color: var(--border-color, #dee2e6);
}

.ring-legend-item.active {
    background: var(--primary-color-light, #e8f5e9);
    border-color: var(--primary-color, #4CAF50);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

/* Legend color indicator */
.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.legend-symbol {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
    white-space: nowrap;
}

.legend-percentage {
    font-size: 0.65rem;
    color: var(--text-secondary, #64748b);
    text-align: right;
    font-family: 'Courier New', monospace;
}

.legend-value {
    font-size: 0.65rem;
    color: var(--text-secondary, #64748b);
    text-align: right;
    white-space: nowrap;
}

/* Assets inactive (cu valoare 0) - stil atenuated */
.ring-legend-item.inactive {
    opacity: 0.65; /* Crescut de la 0.5 pentru mai multă vizibilitate */
    cursor: default;
}

/* Assets active (valoare > 0) - bold pentru vizibilitate */
.ring-legend-item:not(.inactive) .legend-symbol,
.ring-legend-item:not(.inactive) .legend-percentage,
.ring-legend-item:not(.inactive) .legend-value {
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

.ring-legend-item.inactive:hover {
    background: var(--section-bg, #f8f9fa);
    transform: none;
    border-color: transparent;
}

.ring-legend-item.inactive .legend-symbol,
.ring-legend-item.inactive .legend-percentage,
.ring-legend-item.inactive .legend-value {
    color: var(--text-tertiary, #64748b); /* Gri mai închis pentru mai bună citire */
}

/* Animații pentru counter */
#ring-total-value {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-variant-numeric: tabular-nums;
}

/* Responsive pentru ring chart */
@media (max-width: 768px) {
    .svg-ring-container {
        flex-direction: column; /* Pe mobile revine la layout vertical */
        align-items: center;
        max-width: 100%;
    }
    
    .ring-chart {
        width: 90px;
        height: 90px;
    }
    
    .ring-legend {
        width: 100%;
        max-height: none; /* Elimină limita pe mobile */
    }
    
    .ring-legend-item {
        grid-template-columns: 12px auto 1fr auto;
        gap: 0.5rem;
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
    
    .legend-color {
        width: 12px;
        height: 12px;
    }
    
    .spot-chart {
        min-width: 100%;
        max-width: 100%;
    }
}

/* Dark theme pentru ring chart */
@media (prefers-color-scheme: dark) {
    .ring-legend-item {
        background: #333;
        color: #fff;
    }
    
    .ring-legend-item:hover {
        background: #444;
    }
    
    .ring-legend-item.active {
        background: #2d5a2f;
        border-color: #4CAF50;
    }
    
    .legend-symbol {
        color: #fff;
    }
    
    .legend-percentage,
    .legend-value {
        color: #aaa;
    }
}

/* ============================================
   ORDERS TABS — SPOT / FUTURES
   ============================================ */

.orders-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem 0;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    margin-bottom: 0;
}

.orders-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.25rem;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    bottom: -1px;
}

.orders-tab:hover {
    background: var(--hover-bg, #f1f5f9);
    color: var(--text-primary, #1e293b);
}

.orders-tab.active {
    background: var(--card-bg, #fff);
    color: var(--primary-color, #4CAF50);
    border-color: var(--border-color, #e2e8f0);
    border-bottom-color: var(--card-bg, #fff);
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--border-color, #e2e8f0);
    color: var(--text-secondary, #64748b);
    font-size: 0.68rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.orders-tab.active .tab-badge {
    background: var(--primary-color, #4CAF50);
    color: #fff;
}

.tab-badge:not(:empty):not([data-value="0"]) {
    background: var(--primary-color, #4CAF50);
    color: #fff;
}

/* Panouri de continut */
.orders-panel {
    display: none;
    padding: 0;
}

.orders-panel.active {
    display: block;
}

/* Tabel compact pentru ordine SPOT / FUTURES */
.orders-panel .data-table {
    font-size: 0.72rem;
}

.orders-panel .data-table thead th {
    padding: 0.4rem 0.5rem;
    font-size: 0.68rem;
    white-space: nowrap;
}

.orders-panel .data-table tbody td {
    padding: 0.3rem 0.5rem;
    line-height: 1.3;
}

/* Stiluri specifice coloane tabel ordine */
.position-side.side-buy {
    color: #10b981;
    font-weight: 700;
}

.position-side.side-sell {
    color: #ef4444;
    font-weight: 700;
}

/* Rol tranzactie: Maker / Taker */
.trade-role {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
}

.trade-role.role-maker {
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
}

.trade-role.role-taker {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

/* Coloana Profit din tabelul Istoric Futures — fundal transparent 80% */
#futures-history-table td.positive {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #10b981;
    font-weight: 700;
}

#futures-history-table td.negative {
    background-color: rgba(239, 68, 68, 0.05) !important;
    color: #ef4444;
    font-weight: 700;
}

.order-status {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
}

.order-status.status-new {
    background: rgba(59, 130, 246, 0.12);
    color: #3b82f6;
}

.order-status.status-partially_filled {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.order-status.status-filled {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}

/* ============================================
   MODAL CONVERSIE CRYPTO → USDT
   ============================================ */

.sell-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(3px);
    animation: sell-fade-in 0.15s ease;
}

@keyframes sell-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.sell-modal {
    background: var(--card-bg, #fff);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 420px;
    max-width: 95vw;
    animation: sell-slide-in 0.2s ease;
    overflow: hidden;
}

@keyframes sell-slide-in {
    from { transform: translateY(-20px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* Header */
.sell-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.25rem 0.9rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.sell-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary, #1e293b);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sell-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    padding: 4px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.sell-modal-close:hover {
    background: var(--hover-bg, #f1f5f9);
    color: var(--text-primary, #1e293b);
}

/* Info rapida */
.sell-modal-info {
    padding: 0.75rem 1.25rem;
    background: var(--section-bg, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.sell-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.sell-info-label {
    color: var(--text-secondary, #64748b);
}

.sell-info-value {
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.sell-info-row.highlight .sell-info-value {
    color: var(--primary-color, #4CAF50);
    font-size: 0.9rem;
}

/* PNL nerealizat in modal Futures — fundal semi-transparent, text mic */
/* Suprascrie color-picker.js care aplica background-color pe .positive/.negative */
#fm-pnl {
    font-size: 0.7rem !important;
    background-color: transparent !important;
    opacity: 0.85;
}

#fm-pnl.positive {
    background-color: transparent !important;
    color: var(--color-success, #10b981);
}

#fm-pnl.negative {
    background-color: transparent !important;
    color: var(--color-danger, #ef4444);
}

/* Body */
.sell-modal-body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sell-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sell-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Tab-uri MARKET / LIMIT */
.sell-type-tabs {
    display: flex;
    gap: 0.4rem;
}

.sell-type-btn {
    flex: 1;
    padding: 0.4rem 0;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sell-type-btn.active {
    background: var(--primary-color, #4CAF50);
    border-color: var(--primary-color, #4CAF50);
    color: #fff;
}

/* Row cantitate */
.sell-qty-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sell-input {
    flex: 1;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 6px;
    background: var(--input-bg, #fff);
    color: var(--text-primary, #1e293b);
    font-size: 0.85rem;
    transition: border-color 0.15s ease;
}

.sell-input:focus {
    outline: none;
    border-color: var(--primary-color, #4CAF50);
}

.sell-unit {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    white-space: nowrap;
}

.sell-max-btn {
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--primary-color, #4CAF50);
    border-radius: 5px;
    background: transparent;
    color: var(--primary-color, #4CAF50);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sell-max-btn:hover {
    background: var(--primary-color, #4CAF50);
    color: #fff;
}

/* Slider */
.sell-slider {
    width: 100%;
    accent-color: var(--primary-color, #4CAF50);
    cursor: pointer;
    height: 4px;
}

.sell-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-secondary, #64748b);
    margin-top: 2px;
}

/* Footer */
.sell-modal-footer {
    padding: 0.85rem 1.25rem 1.1rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.sell-warning {
    font-size: 0.72rem;
    color: var(--warning-color, #f59e0b);
    text-align: center;
}

.sell-actions {
    display: flex;
    gap: 0.6rem;
}

.sell-btn-cancel {
    flex: 1;
    padding: 0.55rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary, #64748b);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sell-btn-cancel:hover {
    background: var(--hover-bg, #f1f5f9);
    color: var(--text-primary, #1e293b);
}

.sell-btn-confirm {
    flex: 2;
    padding: 0.55rem;
    border: none;
    border-radius: 7px;
    background: var(--danger-color, #ef4444);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sell-btn-confirm:hover:not(:disabled) {
    background: #dc2626;
}

.sell-btn-confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Ecran confirmare success */
.sell-modal-success {
    padding: 2rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.sell-success-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.sell-modal-success h3 {
    font-size: 1.1rem;
    color: var(--primary-color, #4CAF50);
    margin: 0 0 0.5rem;
}

.sell-modal-success p {
    font-size: 0.85rem;
    color: var(--text-secondary, #64748b);
    margin: 0.1rem 0;
}

.sell-modal-success strong {
    color: var(--text-primary, #1e293b);
}

/* Dot indicator pret live in modal */
.sm-live-dot {
    font-size: 0.6rem;
    color: var(--primary-color, #4CAF50);
    animation: sm-pulse 3s ease-in-out infinite;
    vertical-align: middle;
    margin-left: 3px;
}

@keyframes sm-pulse {
    0%   { opacity: 1;   transform: scale(1.3); }
    15%  { opacity: 0.5; transform: scale(1);   }
    100% { opacity: 1;   transform: scale(1);   }
}

/* Hover pe randuri pozitii Futures (click pentru modal) */
.futures-position-row:hover {
    background: var(--hover-bg, #f1f5f9);
    transition: background 0.15s ease;
}

/* ✅ FIX (15 Mar 2026): color-picker.js aplica background-color pe .positive/.negative global
   Suprascrierea previne colorarea fundalului celulelor din tabelul Futures
   Pastram doar culoarea textului (verde/rosu), fara background */
#futures-orders-tbody td.positive,
#futures-orders-tbody td.negative {
    background-color: transparent !important;
}

#futures-orders-tbody td.positive {
    color: var(--color-success, #10b981);
    font-weight: 600;
}

#futures-orders-tbody td.negative {
    color: var(--color-danger, #ef4444);
    font-weight: 600;
}

/* Cursor pointer pe legend items active din SPOT */
.ring-legend-item:not(.inactive) {
    cursor: pointer;
}

/* ============================================
   FIX pentru DUPLICATE IDs din Dashboard
   ============================================ */
/* Dashboard creează elemente cu aceleași ID-uri ca Portfolio
   Ascundem elementele din Dashboard când suntem în Portfolio module */
#portfolio-module div.stat-value#total-assets,
#portfolio-module div.stat-value#total-balance {
    display: none !important;
}

/* Forțăm afișarea elementelor corecte din Portfolio */
#portfolio-module span.value.total-value#total-assets,
#portfolio-module span.value.total-value#total-balance,
#portfolio-module span.value.total-value#total-equity {
    display: inline !important;
}
