/* ============================================================
   PHASE 7 : Dashboard CSS
   Design moderne, responsive, mobile-first
   ============================================================ */

:root {
    /* Couleurs */
    --bg-primary: #0f0f1e;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-card-hover: #1e2a47;
    
    --text-primary: #ffffff;
    --text-secondary: #b8b8d1;
    --text-muted: #7f7f9f;
    
    --accent-primary: #f97316;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;
    
    --bitcoin-color: #f7931a;
    
    /* Espacements */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Bordures */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 11px; /* Taille de base très condensée pour mobile */
}

h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 1.2rem; }
h2 { font-size: 1rem; margin-bottom: var(--spacing-md); }
h3 { font-size: 0.95rem; margin-bottom: var(--spacing-sm); }

/* ============================================================
   LAYOUT
   ============================================================ */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.main {
    flex: 1;
    padding: var(--spacing-lg) 0;
}

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

.header {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--accent-primary);
    padding: var(--spacing-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo {
    color: var(--bitcoin-color);
    font-size: 2rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.header h1 {
    font-size: 1.2rem;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================================
   ICON REFRESH BUTTON (Header)
   ============================================================ */

.icon-refresh-btn {
    background: transparent;
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: var(--spacing-sm);
}

.icon-refresh-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.1);
}

.icon-refresh-btn:active {
    transform: scale(0.95);
}

.icon-refresh-btn i {
    font-size: 0.875rem;
    transition: transform 0.6s ease;
}

.icon-refresh-btn:hover i {
    transform: rotate(360deg);
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-success);
    animation: blink 2s infinite;
}

.status-indicator.error {
    background: var(--accent-danger);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================================
   SECTIONS
   ============================================================ */

.section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

.section h2 {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--accent-primary);
}

/* ============================================================
   CARDS
   ============================================================ */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    transition: all 0.3s ease;
    border: 2px solid transparent;
    position: relative;
}

.card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-highlight {
    border-color: var(--accent-primary);
}

.card-success {
    border-color: var(--accent-success);
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 1.1rem;  /* Encore plus réduit pour condensation */
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.card-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ============================================================
   CHART
   ============================================================ */

.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: var(--spacing-md);
    /* Pleine largeur de l'écran */
    width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding-left: var(--spacing-sm);
    padding-right: var(--spacing-sm);
}

.price-info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.price-current {
    text-align: center;
}

.price-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.price-value {
    display: block;
    font-size: 1.4rem;  /* Très réduit selon demande utilisateur */
    font-weight: 700;
    color: var(--bitcoin-color);
}

/* ============================================================
   CAPITAL INFO
   ============================================================ */

.capital-info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.capital-item {
    text-align: center;
}

.capital-label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.capital-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
}

.profit-highlight {
    color: var(--accent-success);
}

/* ============================================================
   POSITIONS TABLE
   ============================================================ */

.positions-container h3 {
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

/* Grille visuelle des positions */
.positions-grid {
    /* Conteneur pour les 3 lignes de pools */
    display: block;
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    width: 100%;
}

.position-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    position: relative;
}

.position-card.active {
    border-color: var(--accent-success);
    background: rgba(34, 197, 94, 0.1);
}

.position-card.inactive {
    border-color: #4b5563;
    background: rgba(75, 85, 99, 0.1);
    opacity: 0.6;
}

.position-card.blocked {
    border-color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.1);
}

.position-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.position-card .pool-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 4px;
}

.position-card .position-id {
    font-size: 0.7rem;
    font-weight: 600;
}

.position-card .profit {
    font-size: 0.65rem;
    margin-top: 4px;
}

.position-card .profit.positive {
    color: var(--accent-success);
}

.position-card .profit.negative {
    color: var(--accent-danger);
}

/* Légende */
.positions-legend {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid;
}

.legend-dot.active {
    border-color: var(--accent-success);
    background: rgba(34, 197, 94, 0.2);
}

.legend-dot.inactive {
    border-color: #4b5563;
    background: rgba(75, 85, 99, 0.2);
}

.legend-dot.blocked {
    border-color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.2);
}

.positions-grid .loading {
    text-align: center;
    color: var(--text-muted);
    padding: var(--spacing-lg);
}

.pool-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.pool-badge.pool-1 {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.pool-badge.pool-2 {
    background: rgba(249, 115, 22, 0.2);
    color: #fb923c;
}

.pool-badge.pool-3 {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

/* ============================================================
   FILTRES TEMPORELS
   ============================================================ */

.time-filters {
    display: flex;
    gap: 5px;  /* Réduit pour mobile */
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Filtres temporels entre les deux graphiques */
.time-filters-between {
    margin-top: 30px;
    margin-bottom: 30px;
}

/* Icônes discrètes pour les titres de graphiques */
.chart-icon {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-right: 8px;
}

.filter-btn {
    padding: 6px 12px;  /* Réduit pour mobile */
    background: #16213e;
    border: 2px solid #2d3e5f;
    color: #7f7f9f;
    border-radius: 15px;  /* Réduit */
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.7rem;  /* Plus petit */
    min-width: auto;
    font-weight: 600;
}

.filter-btn:hover {
    border-color: #f7931a;
    color: #f7931a;
    transform: translateY(-2px);
}

.filter-btn.active {
    background: #f7931a;
    border-color: #f7931a;
    color: #0f1729;
}

.price-change, .portfolio-change {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    margin-left: 10px;
}

.text-success {
    color: #4caf50 !important;
}

.text-danger {
    color: #f44336 !important;
}

/* ============================================================
   TABS
   ============================================================ */

.tabs {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}

.tab-button {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.tab-button:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.tab-button.active {
    background: var(--accent-primary);
    color: var(--text-primary);
}

/* ============================================================
   LOGS
   ============================================================ */

.logs-container {
    background: #0a0a0f;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.logs-content {
    padding: var(--spacing-md);
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    color: #50fa7b;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

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

.footer {
    background: var(--bg-secondary);
    border-top: 2px solid var(--accent-primary);
    padding: var(--spacing-md) 0;
    margin-top: auto;
}

.footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.footer p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .header h1 {
        font-size: 1rem;
    }
    
    .cards {
        grid-template-columns: 1fr 1fr;  /* 2 colonnes pour mobile portrait */
        gap: 0.5rem;
    }
    
    .card {
        padding: 0.6rem;
    }
    
    .card-label {
        font-size: 0.65rem;
    }
    
    .card-value {
        font-size: 0.85rem;
    }
    
    .card-sub {
        font-size: 0.6rem;
    }
    
    h2 {
        font-size: 0.9rem;
    }
    
    h3 {
        font-size: 0.85rem;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .price-value {
        font-size: 1.2rem;
    }
    
    .positions-table {
        font-size: 0.75rem;
    }
    
    .positions-table th,
    .positions-table td {
        padding: var(--spacing-xs);
    }
    
    .logs-content {
        font-size: 0.7rem;
        max-height: 300px;
    }
}

/* ============================================================
   SCROLLBAR CUSTOM
   ============================================================ */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ea6105;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.5s ease-out;
}

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

.text-success { color: var(--accent-success); }
.text-warning { color: var(--accent-warning); }
.text-danger { color: var(--accent-danger); }
.text-info { color: var(--accent-info); }
.text-muted { color: var(--text-muted); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* ============================================================
   PHASE 6 : CONFIGURATION EDITOR
   ============================================================ */

/* Header avec boutons actions */
.config-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: #ea580c;
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(127, 127, 159, 0.2);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(127, 127, 159, 0.3);
}

.config-status {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-muted);
}

/* Sections collapsibles */
.config-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    overflow: hidden;
}

.collapsible-header {
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(127, 127, 159, 0.1);
    transition: background 0.2s;
}

.collapsible-header:hover {
    background: rgba(127, 127, 159, 0.15);
}

.collapsible-header i {
    font-size: 12px;
    transition: transform 0.3s;
}

.collapsible.collapsed .collapsible-header i {
    transform: rotate(0deg);
}

.collapsible:not(.collapsed) .collapsible-header i {
    transform: rotate(90deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s;
    padding: 0 20px;
}

.collapsible:not(.collapsed) .collapsible-content {
    max-height: none; /* Pas de limite de hauteur */
    overflow: visible; /* Permettre overflow visible */
    padding: 20px;
}

/* Groupes de paramètres */
.config-group {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(127, 127, 159, 0.15);
}

.config-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.config-group h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Sous-groupes collapsibles (pour pools, positions, etc.) */
.config-subgroup {
    margin-top: 16px;
    padding: 12px;
    background: rgba(127, 127, 159, 0.05);
    border-radius: var(--radius-sm);
}

.config-subgroup.collapsible {
    background: var(--bg-secondary);
}

.config-subgroup h5 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.config-subgroup h5:hover {
    background: rgba(127, 127, 159, 0.1);
}

.config-subgroup h5 i {
    font-size: 10px;
    transition: transform 0.3s;
}

/* Labels et inputs */
.config-group label {
    display: block;
    margin: 14px 0;
}

.config-group strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 4px;
}

.config-group .tech-name {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    display: block;
    margin-bottom: 6px;
}

.config-group input[type="number"],
.config-group input[type="text"],
.config-group select {
    background: rgba(127, 127, 159, 0.1);
    border: 1px solid rgba(127, 127, 159, 0.3);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: 200px;
    transition: all 0.2s;
}

.config-group input:focus,
.config-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(249, 115, 22, 0.1);
}

.config-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin-right: 8px;
    vertical-align: middle;
}

/* Liste de positions */
.positions-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.position-item {
    background: rgba(127, 127, 159, 0.08);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(127, 127, 159, 0.15);
}

.position-item strong {
    display: block;
    font-size: 12px;
    color: var(--accent-primary);
    margin-bottom: 8px;
}

/* Liste de paliers (thresholds) */
.thresholds-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.threshold-item {
    background: rgba(127, 127, 159, 0.08);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.threshold-item strong {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 6px;
}

/* Timeline versions */
.versions-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.version-item {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.version-item:hover {
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

.version-info {
    flex: 1;
}

.version-id {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.version-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.version-comment {
    font-size: 13px;
    color: var(--text-secondary);
}

.version-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(127, 127, 159, 0.2);
    color: var(--text-primary);
}

.btn-small:hover {
    background: rgba(127, 127, 159, 0.3);
    transform: translateY(-1px);
}

.btn-small.btn-restore {
    background: var(--accent-success);
    color: white;
}

.btn-small.btn-restore:hover {
    background: #16a34a;
}

/* Responsive */
@media (max-width: 768px) {
    .config-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .config-header button {
        width: 100%;
        justify-content: center;
    }
    
    .config-status {
        margin-left: 0;
        margin-top: 8px;
        text-align: center;
    }
    
    .positions-list,
    .thresholds-list {
        grid-template-columns: 1fr;
    }
    
    .config-group input[type="number"],
    .config-group input[type="text"],
    .config-group select {
        width: 100%;
        max-width: 100%;
    }
    
    .config-group label {
        display: block;
        width: 100%;
        overflow-wrap: break-word;
    }
    
    .config-group .tech-name {
        word-break: break-all;
    }
    
    .position-item,
    .threshold-item {
        width: 100%;
        box-sizing: border-box;
    }
    
    .version-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .version-actions {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .collapsible-header {
        font-size: 14px;
        padding: 12px 16px;
    }
    
    .config-section {
        margin-bottom: 12px;
    }
}

