/* =========================================
   CUBA STUDIO LAYOUT
   ========================================= */
.cuba-main { 
    max-width: 1100px; 
    margin: 0 auto; 
    overflow-x: hidden; /* Stops horizontal mobile scrolling */
}

/* Global Components */
.cuba-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    border: none;
    padding: 24px;
    margin-bottom: 24px;
    width: 100%;
    box-sizing: border-box;
}

.cuba-btn-primary {
    background: var(--primary); color: white; border: none; padding: 8px 18px;
    border-radius: 8px; font-weight: 500; cursor: pointer; transition: 0.2s; font-family: inherit;
}
.cuba-btn-primary:hover { background: #6054e6; transform: translateY(-1px); }

/* Top Grid (Purple Card + Stats) */
.cuba-top-grid {
    display: flex; flex-direction: column; gap: 24px; margin-bottom: 24px;
}

@media (min-width: 768px) {
    .cuba-top-grid { flex-direction: row; }
    .cuba-purple-card { flex: 1.5; }
    .cuba-stats-col { flex: 1; display: flex; flex-direction: column; gap: 24px; }
    .cuba-stats-col .cuba-card { margin-bottom: 0; flex: 1; }
}

/* The Signature Purple Card */
.cuba-purple-card {
    background: linear-gradient(135deg, var(--primary) 0%, #8e83ff 100%);
    border-radius: var(--radius-lg);
    padding: 30px; color: white; position: relative; overflow: hidden;
    box-shadow: 0 10px 20px rgba(115, 102, 255, 0.3);
    width: 100%; box-sizing: border-box;
}
.cuba-purple-card::after { content: ''; position: absolute; right: -50px; top: -50px; width: 200px; height: 200px; background: rgba(255,255,255,0.1); border-radius: 50%; }
.cuba-purple-card::before { content: ''; position: absolute; right: 80px; bottom: -30px; width: 100px; height: 100px; background: rgba(255,255,255,0.1); border-radius: 50%; }
.purple-card-content { position: relative; z-index: 2; }
.purple-card-content h3 { margin: 0 0 5px 0; font-size: 1.5rem; font-weight: 600; }
.purple-card-content p { color: rgba(255,255,255,0.8); margin: 0 0 20px 0; font-size: 0.95rem; line-height: 1.4; }
.wallet-amount { font-size: 2.5rem; font-weight: 700; margin-bottom: 20px; line-height: 1; }
.wallet-amount small { font-size: 1rem; font-weight: 400; opacity: 0.8; }
.purple-card-btn { background: white; color: var(--primary); border: none; padding: 10px 24px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.purple-card-btn:hover { background: #f8f9fe; }

/* Small White Stat Cards */
.stat-card { display: flex; align-items: center; gap: 20px; padding: 20px 24px; }
.stat-icon { min-width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.stat-details p { margin: 0 0 5px 0; color: var(--text-muted); font-size: 0.9rem; font-weight: 500; text-transform: uppercase; }
.stat-details h4 { margin: 0; font-size: 1.6rem; color: var(--text-dark); font-weight: 600; }

/* =========================================
   BULLETPROOF CHART CONTAINERS 
   ========================================= */
.chart-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; gap: 15px; }
.chart-header h3 { margin: 0 0 5px 0; font-size: 1.2rem; color: var(--text-dark); }
.chart-header p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.cuba-tabs { display: flex; background: var(--bg-body); padding: 4px; border-radius: 8px; }
.cuba-tab { background: transparent; border: none; padding: 6px 16px; border-radius: 6px; font-weight: 500; color: var(--text-muted); cursor: pointer; transition: 0.2s; font-family: inherit; }
.cuba-tab.active { background: white; color: var(--primary); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* CRITICAL: Relative positioning and fixed height forces Chart.js to scale properly */
.chart-container { height: 280px; width: 100%; position: relative; }
.panel-chart-wrapper { height: 200px; width: 100%; position: relative; margin-top: 10px; }

/* Article List */
.article-container { display: flex; flex-direction: column; gap: 12px; }
.article-row { display: flex; align-items: center; justify-content: space-between; padding: 16px; border: 1px solid var(--border-color); border-radius: 12px; transition: 0.2s; cursor: pointer; background: white; }
.article-row:hover { border-color: var(--primary-light); background: #fdfdff; transform: translateY(-2px); box-shadow: var(--shadow-soft); }

/* Prevents long article titles from blowing out the screen width */
.row-info { flex: 1; min-width: 0; padding-right: 15px; }
.row-info h4 { margin: 0 0 4px 0; color: var(--text-dark); font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-info p { margin: 0; color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-action-btn { width: 36px; height: 36px; border-radius: 8px; border: none; background: var(--bg-body); color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.icon-action-btn:hover { background: var(--primary-light); color: var(--primary); }
.icon-action-btn.delete:hover { background: #ffe5e5; color: var(--secondary); }

/* Badges */
.cuba-badge { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-pending { background: #fff5e5; color: #f59e0b; }
.badge-success { background: #e5f8ed; color: var(--success); }

/* Slide-in Analytics Panel */
.cuba-side-panel {
    position: fixed; top: 0; right: 0; width: 100%; max-width: 400px; height: 100vh;
    background: var(--bg-body); box-shadow: -10px 0 30px rgba(8, 21, 66, 0.08);
    z-index: 2000; display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.hidden-panel { transform: translateX(100%); }
.active-panel { transform: translateX(0); }

.panel-header { padding: 24px; background: white; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.panel-header h3 { margin: 0 0 4px 0; color: var(--text-dark); font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.panel-header p { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.close-btn { background: var(--bg-body); border: none; width: 32px; height: 32px; border-radius: 8px; color: var(--text-dark); cursor: pointer; transition: 0.2s; }
.close-btn:hover { background: var(--secondary); color: white; }

.panel-body { padding: 20px; overflow-y: auto; overflow-x: hidden; flex: 1; padding-bottom: 50px; }
.text-muted { color: var(--text-muted); }

/* =========================================
   MOBILE RESPONSIVENESS OVERRIDES
   ========================================= */
@media (max-width: 600px) {
    .cuba-card { padding: 16px; margin-bottom: 16px; }
    .cuba-purple-card { padding: 20px; }
    .wallet-amount { font-size: 2rem; }
    .stat-card { padding: 16px; gap: 15px; }
    .stat-icon { min-width: 40px; height: 40px; font-size: 1.2rem; }
    .stat-details h4 { font-size: 1.3rem; }
    .row-actions { gap: 4px; }
    .icon-action-btn { width: 32px; height: 32px; font-size: 0.9rem; }
    .chart-container { height: 220px; }
    .panel-body { padding: 15px; }
}