/* ============================================================================
   Charts
   - Chart containers and wrappers
   - Chart titles and toggles
   - Chart filtered state
   ============================================================================ */

/* Charts Row - Two charts side by side */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 25px;
}

.charts-row .chart-container {
    margin-bottom: 0;
}

.chart-container {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px var(--shadow);
    border: 1px solid var(--border-color);
    transition: background 0.3s;
}

.chart-title {
    color: var(--text-primary);
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 20px;
}

.chart-wrapper {
    position: relative;
    height: 300px;
}

.chart-toggle {
    display: inline-flex;
    background: rgba(15, 23, 34, 0.6);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    padding: 4px;
}

.toggle-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    color: #475569;
    transition: all 0.3s;
}

.toggle-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* Filtered chart container highlight */
.chart-container.filtered {
    border: 1px solid rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.2);
    background: rgba(102, 126, 234, 0.03);
}

/* Tablet/Medium screens - Stack charts into rows */
@media (max-width: 1100px) {
    .charts-row {
        grid-template-columns: 1fr;
    }

    .charts-row .chart-container {
        margin-bottom: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chart-wrapper {
        height: 250px;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .charts-row .chart-container {
        margin-bottom: 0;
    }
}

/* ============================================================================
   Time/Day Charts Row Layout
   ============================================================================ */

.time-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.time-charts-row .chart-container {
    margin-bottom: 0;
}

/* Stack charts vertically under 1300px */
@media (max-width: 1300px) {
    .time-charts-row {
        grid-template-columns: 1fr;
    }
}

/* Time Charts Mobile Responsive */
@media (max-width: 768px) {
    .time-charts-row {
        gap: 15px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .time-charts-row .chart-container {
        padding: 15px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    /* Constrain chart wrapper and canvas */
    .time-charts-row .chart-wrapper,
    #hourlyChartView,
    #dailyChartView {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .time-charts-row canvas {
        max-width: 100% !important;
    }

    /* Reduce chart heights on mobile */
    #hourlyPerformanceContainer .chart-wrapper,
    #dailyPerformanceContainer .chart-wrapper,
    #hourlyChartView,
    #dailyChartView {
        height: 250px !important;
        min-height: 200px;
    }

    /* Control buttons wrap better on mobile */
    #hourlyPerformanceContainer > div:first-child,
    #dailyPerformanceContainer > div:first-child {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }

    /* Toggle buttons stack on mobile */
    #hourlyPerformanceContainer > div:first-child > div:last-child {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    /* Smaller toggle button text */
    #hourlyPerformanceContainer button,
    #dailyPerformanceContainer button {
        padding: 6px 10px;
        font-size: 0.8em;
    }

    /* Table scroll on mobile */
    #hourlyTableView,
    #dailyTableView {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #hourlyPerformanceTable,
    #dailyPerformanceTable {
        font-size: 0.85em;
        min-width: 500px;
    }

    #hourlyPerformanceTable th,
    #hourlyPerformanceTable td,
    #dailyPerformanceTable th,
    #dailyPerformanceTable td {
        padding: 8px 6px;
        white-space: nowrap;
    }
}

/* Time Charts Very Small Screens */
@media (max-width: 480px) {
    .time-charts-row .chart-container {
        padding: 12px;
    }

    #hourlyPerformanceContainer .chart-wrapper,
    #dailyPerformanceContainer .chart-wrapper,
    #hourlyChartView,
    #dailyChartView {
        height: 200px !important;
    }

    .time-charts-row .chart-title {
        font-size: 1em;
    }
}

/* ============================================================================
   Month Calendar Styles
   ============================================================================ */

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-header {
    text-align: center;
    padding: 10px;
    font-weight: 600;
    color: #94a3b8;
    font-size: 0.85em;
}

.calendar-day-cell {
    min-height: 80px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
}

.calendar-day-empty {
    opacity: 0.3;
}

.calendar-day-positive {
    background: rgba(72, 187, 120, 0.1);
}

.calendar-day-negative {
    background: rgba(245, 101, 101, 0.1);
}

.calendar-day-today {
    border: 2px solid #667eea;
}

.calendar-day-clickable {
    cursor: pointer;
}

.calendar-day-clickable:hover {
    border-color: #667eea;
}

.calendar-day-number {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9em;
}

.calendar-day-number.today {
    color: #667eea;
}

.calendar-day-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
}

.calendar-day-no-trades {
    color: #64748b;
    font-size: 0.7em;
}

.calendar-day-trades {
    font-size: 0.75em;
    color: #94a3b8;
}

.calendar-day-pnl {
    font-weight: 600;
    font-size: 0.85em;
    color: #94a3b8;
}

.calendar-day-pnl.positive {
    color: #48bb78;
}

.calendar-day-pnl.negative {
    color: #f56565;
}

/* Calendar Summary */
.calendar-summary {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.calendar-summary-item {
    text-align: center;
}

.calendar-summary-label {
    color: #94a3b8;
    font-size: 0.85em;
    margin-bottom: 4px;
}

.calendar-summary-value {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-primary);
}

.calendar-summary-value.positive {
    color: #48bb78;
}

.calendar-summary-value.negative {
    color: #f56565;
}

/* Calendar Header */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-title {
    color: var(--text-primary);
    font-size: 1.3em;
    font-weight: 600;
    margin: 0;
}

/* Calendar Navigation Buttons */
.calendar-nav-btn {
    background: transparent;
    color: #94a3b8;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
}

.calendar-nav-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

/* Calendar Mobile Responsive - Tablet */
@media (max-width: 768px) {
    .calendar-header {
        margin-bottom: 15px;
    }

    .calendar-title {
        font-size: 1.1em;
    }

    .calendar-grid {
        gap: 3px;
        width: 100%;
    }

    .calendar-day-header {
        padding: 8px 4px;
        font-size: 0.8em;
        min-width: 0;
        overflow: hidden;
    }

    .calendar-day-cell {
        min-height: 65px;
        padding: 6px;
        min-width: 0;
        overflow: hidden;
    }

    .calendar-day-number {
        font-size: 0.85em;
    }

    .calendar-day-trades {
        font-size: 0.7em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .calendar-day-pnl {
        font-size: 0.65em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .calendar-summary {
        gap: 24px;
        padding: 14px;
    }

    .calendar-summary-label {
        font-size: 0.8em;
    }

    .calendar-summary-value {
        font-size: 1.1em;
    }

    .calendar-nav-btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .calendar-nav-btn .nav-text {
        display: none;
    }
}

/* Calendar Mobile Responsive - Small Screens */
@media (max-width: 480px) {
    .calendar-header {
        margin-bottom: 12px;
    }

    .calendar-title {
        font-size: 1em;
    }

    .calendar-grid {
        gap: 2px;
    }

    .calendar-day-header {
        padding: 6px 2px;
        font-size: 0.75em;
    }

    /* Show abbreviated day names on small screens */
    .calendar-day-header::after {
        content: attr(data-short);
    }

    .calendar-day-header {
        font-size: 0;
    }

    .calendar-day-header::after {
        font-size: 0.75rem;
    }

    .calendar-day-cell {
        min-height: 55px;
        padding: 4px;
        border-radius: 4px;
    }

    .calendar-day-number {
        font-size: 0.75em;
    }

    .calendar-day-content {
        gap: 1px;
    }

    .calendar-day-trades {
        font-size: 0.55em;
    }

    .calendar-day-pnl {
        font-size: 0.55em;
    }

    .calendar-day-no-trades {
        font-size: 0.6em;
    }

    .calendar-summary {
        gap: 12px;
        padding: 12px 8px;
        margin-top: 15px;
    }

    .calendar-summary-item {
        min-width: 60px;
    }

    .calendar-summary-label {
        font-size: 0.7em;
        white-space: nowrap;
    }

    .calendar-summary-value {
        font-size: 0.95em;
    }

    .calendar-nav-btn {
        padding: 6px 10px;
    }

    .calendar-nav-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* Calendar Mobile Responsive - Very Small Screens */
@media (max-width: 360px) {
    .calendar-header {
        margin-bottom: 10px;
    }

    .calendar-title {
        font-size: 0.9em;
    }

    .calendar-day-cell {
        min-height: 48px;
        padding: 3px;
    }

    .calendar-day-number {
        font-size: 0.7em;
    }

    .calendar-day-trades {
        font-size: 0.5em;
    }

    .calendar-day-pnl {
        font-size: 0.5em;
    }

    .calendar-summary {
        gap: 8px;
        padding: 10px 6px;
    }

    .calendar-summary-item {
        min-width: 50px;
    }

    .calendar-summary-label {
        font-size: 0.65em;
    }

    .calendar-summary-value {
        font-size: 0.85em;
    }

    .calendar-nav-btn {
        padding: 5px 8px;
    }

    .calendar-nav-btn svg {
        width: 12px;
        height: 12px;
    }
}
