/* Main styles for BTC Trading Dashboard */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

h1 {
    color: #2c3e50;
}

h2 {
    font-size: 1.2rem;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.status {
    font-weight: 500;
}

/* Connection status styling with glowing dot */
#connection-status {
    position: relative;
    padding-left: 20px;
    font-weight: bold;
}

    #connection-status:before {
        content: "";
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 12px;
        height: 12px;
        border-radius: 50%;
        background-color: #ccc;
    }

    #connection-status.connected {
        color: #4caf50;
    }

        #connection-status.connected:before {
            background-color: #4caf50;
            box-shadow: 0 0 10px rgba(76, 175, 80, 0.7);
            animation: pulse 2s infinite;
        }

    #connection-status.disconnected {
        color: #f44336;
    }

        #connection-status.disconnected:before {
            background-color: #f44336;
        }

    #connection-status.connecting {
        color: #ff9800;
    }

        #connection-status.connecting:before {
            background-color: #ff9800;
            animation: pulse 1s infinite;
        }

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

.connected {
    color: #4caf50;
}

.disconnected {
    color: #f44336;
}

.connecting, .reconnecting {
    color: #ff9800;
}

.error {
    color: #f44336;
}

.loading {
    color: #2196f3;
}

.refresh-button {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

    .refresh-button:hover {
        background-color: #45a049;
    }

.chart-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    background-color: #fff;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.time-window-selector {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

    .time-window-selector span {
        margin-right: 10px;
        font-weight: 500;
    }

.time-btn {
    background-color: #f1f1f1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 12px;
    margin-right: 5px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

    .time-btn:hover {
        background-color: #e0e0e0;
    }

    .time-btn[data-selected="true"], .time-btn.active {
        background-color: #2196f3;
        color: white;
        border-color: #2196f3;
    }

.chart-container {
    height: 400px;
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    position: relative;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .data-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .data-grid {
        grid-template-columns: 1fr;
    }
}

.data-card {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

    .data-card h3 {
        color: #555;
        font-size: 1rem;
        margin-bottom: 10px;
    }

.data-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
}

.change-value {
    margin-top: 5px;
    font-weight: 500;
}

.positive {
    color: #4caf50;
}

.negative {
    color: #f44336;
}

/* Panel layouts - UPDATED */
.panels {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Two column layout for WebSocket and Memory panels */
@media (min-width: 768px) {
    .panels {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile optimizations */
@media (max-width: 767px) {
    .panels {
        grid-template-columns: 1fr;
    }
}

.panel {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.full-width {
    grid-column: 1 / -1;
}

.half-width {
    grid-column: span 1;
}

/* Info panels */
.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.info-label {
    font-weight: 500;
}

.info-value {
    color: #2c3e50;
}

/* Buttons */
.cache-button {
    background-color: #ff9800;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    font-weight: 500;
    transition: background-color 0.3s;
}

    .cache-button:hover {
        background-color: #f57c00;
    }

/* Signal History Styles - UPDATED */
.signal-history-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #fafafa;
}

.signal-list {
    padding: 5px;
}

.signal-row {
    display: grid;
    grid-template-columns: 180px 60px 1fr;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #eee;
    background-color: #fff;
    border-radius: 4px;
    margin-bottom: 5px;
}

    .signal-row:last-child {
        margin-bottom: 0;
    }

.signal-timestamp {
    font-size: 0.85rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.signal-type {
    font-weight: bold;
    text-align: center;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.9rem;
}

.signal-reason {
    font-size: 0.9rem;
    color: #333;
    line-height: 1.4;
}

/* Signal colors */
.buy {
    color: #4caf50;
}

.sell {
    color: #f44336;
}

.hold {
    color: #2196f3;
}

.neutral {
    color: #757575;
}

/* Memory status colors */
.high {
    color: #f44336;
}

.medium {
    color: #ff9800;
}

.low {
    color: #4caf50;
}

/* WebSocket panel */
.ws-info {
    padding: 10px;
    background-color: #fafafa;
    border-radius: 4px;
    border: 1px solid #eee;
}

/* Memory panel */
.memory-info {
    padding: 10px;
    background-color: #fafafa;
    border-radius: 4px;
    border: 1px solid #eee;
}

/* Technical indicators panel */
.indicators-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

    .indicators-table th,
    .indicators-table td {
        padding: 8px;
        text-align: center;
        border-bottom: 1px solid #eee;
    }

    .indicators-table th {
        background-color: #f5f5f5;
        font-weight: 500;
        color: #555;
    }

    .indicators-table tr:last-child td {
        border-bottom: none;
    }

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #aaa;
    border-radius: 4px;
}

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

/* Loading indicator */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 10px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

    .loading-indicator.active {
        display: block;
    }

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(33, 150, 243, 0.3);
    border-radius: 50%;
    border-top-color: #2196f3;
    animation: spin 1s ease-in-out infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error display */
.error-display {
    background-color: #ffebee;
    color: #d32f2f;
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    display: none;
}

    .error-display.active {
        display: block;
    }

/* Additional specific signal styling */
.signal-row:hover {
    background-color: #f5f5f5;
}

.buy-signal {
    background-color: rgba(76, 175, 80, 0.1);
}

.sell-signal {
    background-color: rgba(244, 67, 54, 0.1);
}

.hold-signal {
    background-color: rgba(33, 150, 243, 0.1);
}

/* No data message */
.no-data {
    text-align: center;
    padding: 20px;
    color: #757575;
    font-style: italic;
}

/* RSI coloring */
.overbought {
    color: #f44336;
}

.oversold {
    color: #4caf50;
}

.neutral {
    color: #757575;
}

/* Table styling for indicators */
.tech-indicators {
    width: 100%;
    border-collapse: collapse;
}

    .tech-indicators th,
    .tech-indicators td {
        padding: 8px;
        text-align: center;
        border-bottom: 1px solid #eee;
    }

    .tech-indicators th {
        background-color: #f5f5f5;
        font-weight: 500;
        color: #555;
        position: sticky;
        top: 0;
    }

    .tech-indicators tbody tr:hover {
        background-color: #f9f9f9;
    }

    .tech-indicators tr:last-child td {
        border-bottom: none;
    }

/* Time formatting */
.time-display {
    font-family: monospace;
    padding: 2px 4px;
    background-color: #f5f5f5;
    border-radius: 3px;
    font-size: 0.9em;
}

/* Mobile optimizations */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    .chart-container {
        height: 300px;
    }

    .signal-row {
        grid-template-columns: 100px 50px 1fr;
    }

    .time-btn {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    .data-value {
        font-size: 1.2rem;
    }

    .signal-timestamp {
        font-size: 0.75rem;
    }

    .signal-reason {
        font-size: 0.8rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
        color: #e0e0e0;
    }

    header, .status-bar, .chart-container, .data-card, .panel, .signal-row {
        background-color: #1e1e1e;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    }

    h1, h2, h3, .data-value {
        color: #e0e0e0;
    }

    .info-value, .signal-reason {
        color: #b0b0b0;
    }

    .signal-timestamp {
        color: #909090;
    }

    .time-btn {
        background-color: #2a2a2a;
        border-color: #333;
        color: #e0e0e0;
    }

        .time-btn:hover {
            background-color: #333;
        }

    .signal-history-container, .ws-info, .memory-info {
        background-color: #1a1a1a;
        border-color: #333;
    }

    .tech-indicators th {
        background-color: #2a2a2a;
        color: #b0b0b0;
    }

    .tech-indicators tbody tr:hover {
        background-color: #252525;
    }

    ::-webkit-scrollbar-track {
        background: #2a2a2a;
    }

    ::-webkit-scrollbar-thumb {
        background: #555;
    }

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

    /* Maintain color coding in dark mode */
    .positive {
        color: #81c784;
    }

    .negative {
        color: #e57373;
    }
}
