:root {
    --bg-color: #0d1117;
    --card-bg: #161b22;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --accent-color: #1f6feb;
    --border-color: #30363d;
    --up-color: #238636;
    --down-color: #da3633;
    --header-height: 60px;
    --grid-gap: 8px;
}

[data-theme="light"] {
    --bg-color: #ffffff;
    --card-bg: #f6f8fa;
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --accent-color: #0969da;
    --border-color: #d0d7de;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    font-size: 14px;
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* Header */
header {
    height: var(--header-height);
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-controls {
    display: flex;
    gap: 12px;
}

button.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

button.icon-btn:hover {
    background-color: rgba(128, 128, 128, 0.1);
}

.time-controls {
    display: inline-flex; /* Use inline-flex for better alignment in settings */
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-right: 0; /* Remove header-specific margin */
    overflow: hidden;
}

.time-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 4px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-right: 1px solid var(--border-color);
}

.time-btn:last-child {
    border-right: none;
}

.time-btn:hover {
    background-color: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
}

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

/* Main Grid */
main {
    padding: var(--grid-gap);
    min-height: calc(100vh - var(--header-height));
}

#chart-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols, 2), 1fr);
    gap: var(--grid-gap);
}

/* TradingView Widget Container */
.widget-container {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    height: 300px; /* Default height */
    display: flex;
    flex-direction: column;
}

.widget-header {
    background-color: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tradingview-widget-container {
    width: 100%;
    flex: 1; /* Fill remaining height */
    position: relative;
    overflow: hidden; /* Hide overflow from scaling */
}

/* 
 * Direct font size control is not supported by TradingView API.
 * Using CSS transform to visually scale down the widget (including text).
 * scale(0.85) roughly creates a smaller font look.
 * Width/Height are compensated (100/0.85 ≈ 117.6%) to fill the container.
 */
.tradingview-widget-container tv-mini-chart {
    display: block;
    width: 117.6% !important; 
    height: 117.6% !important;
    transform: scale(0.85) !important;
    transform-origin: top left !important;
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 400px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.current-time {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.footer-bottom{
    padding: 16px 8px;
    text-align: center;
}
.footer-bottom a{
    color: white;
}

.gads{
    margin-top: 12px;
    margin-bottom: 12px;
    text-align: center;
}
/* Responsive */
@media (max-width: 768px) {
    #chart-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* Force 2 columns on mobile */
    }
    .widget-container {
        height: 200px; /* Reduce height on mobile to show more widgets */
    }
}
