:root {
    --background-color: #D76A03;
    --widget-background: #1a1a1a;
    --text-color: #F1F5F9;
    --accent-color: #fd8f41;
    --shadow-color: rgba(0, 0, 0.2);
    --positive-change: #00c781;
    --negative-change: #ff4d4d;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'SF Pro Display', 'Inter', sans-serif;
    margin: 0;
    padding: 0px;
    background-image: radial-gradient(circle, #000 1px, transparent 1px);
    background-size: 16px 16px;
    background-position: center;
    min-height: 100vh;
    letter-spacing: -0.02em;
    overflow-x: hidden;
}

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

.widget {
    background-color: var(--widget-background);
    border-radius: 20px;
    padding: 20px;
    width: 240px;
    height: 240px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-sizing: border-box;
    position: relative;
}

.widget:hover {
    transform: scale(1.05);
}

.widget-header {
    font-size: 14px;
    text-transform: uppercase;
    color: #aaa;
    margin-bottom: 4px;
}

.widget-value {
    font-size: 28px;
    font-weight: bold;
    margin-top: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    line-height: 1.2;
    flex-shrink: 0;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.metrics-container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.metrics-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.market-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.market-open {
    background-color: var(--positive-change);
}

.market-closed {
    background-color: var(--negative-change);
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.slider-container input[type="range"] {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    height: 6px;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
}

.slider-container input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: none;
}

.slider-container label {
    color: #fff;
    font-size: 0.9em;
    white-space: nowrap;
}

/* Dropdown styles */
select {
    background-color: var(--widget-background);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9em;
    outline: none;
}

select:focus {
    border-color: var(--accent-color);
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .container {
        padding: 6px;
    }
    
    .widget {
        width: 100%;
        height: auto;
        min-height: 200px;
    }
    
    .metrics-container {
        flex-direction: column;
        gap: 12px;
    }
    
    .slider-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .slider-container input[type="range"] {
        width: 100%;
        max-width: 220px;
    }
    
    #price-in-mnav-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .widget {
        padding: 16px;
    }
    
    .widget-header {
        font-size: 12px;
    }
    
    .widget-value {
        font-size: 20px;
    }
    
    .slider-container label {
        font-size: 0.8em;
    }
}

/* Mobile Responsive - Copy from styles.css */
@media (max-width: 430px) {
    .container {
        padding: 6px;
    }
    
    .compact-news {
        max-height: none !important;
        overflow: visible !important;
    }
    
    .widget,
    .main-content,
    .container {
        overflow: visible !important;
    }
    
    #theme-image {
        width: 100%;
    }
    
    .main-content {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(160px, auto));
        gap: 16px;
        padding: 0 6px 10px;
        min-height: calc(100vh - 150px);
        grid-auto-rows: 180px;
        justify-content: center;
        align-items: start;
    }
    
    .widget {
        width: 180px;
        height: 180px !important;
        padding: 16px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .widget-header {
        font-size: 12px;
    }
    
    .widget-value {
        font-size: 18px;
        white-space: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }
    
    .change {
        font-size: 10px !important;
    }
    
    .change-period {
        font-size: 10px !important;
    }
    
    .news-scroll-wrapper {
        max-height: 4em;
        overflow-y: auto;
        padding-right: 6px;
        margin-top: 8px;
        transition: max-height 0.3s ease;
    }
    
    /* Fix market notification container on mobile */
    #market-notification {
        padding: 8px 4px;
        font-size: 0.8em;
        line-height: 1.4;
    }
    
    #market-notification > div {
        gap: 6px !important;
        flex-direction: column !important;
        justify-content: center;
        align-items: center;
        min-height: auto;
        width: 100%;
    }
    
    #market-notification > div > div {
        line-height: 1.4;
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
        justify-content: center;
        padding: 2px 0;
    }
    
    #market-notification .market-icon {
        width: 12px;
        height: 12px;
        flex-shrink: 0;
        min-width: 12px;
    }
    
    #market-notification span {
        white-space: nowrap;
        flex-shrink: 0;
        line-height: 1.4;
        overflow: visible;
        text-overflow: unset;
        max-width: none;
    }
}

@media (max-width: 375px) {
    .main-content {
        grid-template-columns: repeat(auto-fit, minmax(130px, auto));
        grid-auto-rows: 160px;
    }
    
    /* Additional market notification fixes for very small screens */
    #market-notification {
        padding: 6px 2px;
        font-size: 0.75em;
    }
    
    #market-notification > div {
        gap: 4px !important;
        flex-direction: column !important;
    }
    
    #market-notification > div > div {
        width: 100%;
        padding: 1px 0;
        gap: 4px;
    }
    
    #market-notification .market-icon {
        width: 10px;
        height: 10px;
        min-width: 10px;
    }
    
    #market-notification span {
        max-width: none;
        font-size: 0.7em;
    }
    
    .widget {
        width: 160px;
        height: 160px !important;
        padding: 16px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .widget-header {
        font-size: 11px;
    }
    
    .change {
        font-size: 12px;
    }
    
    #news-container.expanded .news-scroll-wrapper {
        max-height: 500px;
        overflow-y: auto;
    }
}

/* Custom legend positioning */
#custom-legend {
    position: absolute !important;
    top: 24px !important;
    left: 32px !important;
    z-index: 10 !important;
    background: rgba(20,20,20,0.95) !important;
    border-radius: 8px !important;
    padding: 10px 18px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    align-items: flex-start !important;
    min-width: 160px !important;
}

/* More specific rule to ensure it overrides */
.widget #custom-legend,
.graph-container #custom-legend,
.main-content #custom-legend {
    left: 60px !important;
}

@media (max-width: 768px) {
    .graph-container {
        max-width: 100vw !important;
        width: 100% !important;
        height: calc(100vh - 80px) !important;
        min-height: 400px !important;
        margin: 4px auto !important;
        padding: 0.5vw !important;
        transform: none !important;
    }
    .metrics-container {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .slider-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 10px !important;
        margin: 6px 0 !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    .slider-container input[type="range"] {
        width: 120px !important;
        min-width: 80px !important;
        max-width: 140px !important;
    }
    .slider-container label {
        font-size: 0.95em !important;
        margin-left: 0 !important;
        min-width: 0 !important;
        white-space: nowrap !important;
    }
    #custom-legend {
        font-size: 0.7em !important;
        padding: 2px 4px !important;
        min-width: 20px !important;
        left: 4px !important;
        top: 8px !important;
        color: #fff !important;
        line-height: 1.2 !important;
    }
}

@media (max-width: 480px) {
    .graph-container {
        padding: 4px !important;
        margin: 2px auto !important;
        min-height: 400px !important;
        height: calc(100vh - 60px) !important;
    }
    .slider-container {
        gap: 6px !important;
    }
    .slider-container input[type="range"] {
        width: 90px !important;
        max-width: 100px !important;
    }
    #custom-legend {
        font-size: 0.6em !important;
        padding: 1px 2px !important;
        min-width: 10px !important;
        left: 2px !important;
        top: 4px !important;
        color: #fff !important;
        line-height: 1.2 !important;
    }
}

@media (max-width: 480px) {
  #live-stock-prices {
    flex-direction: column !important;
    gap: 4px !important;
    padding: 6px !important;
    align-items: stretch !important;
  }
  #live-stock-prices .stock-item {
    font-size: 0.95em !important;
    padding: 4px 0 !important;
    min-width: 0 !important;
  }
  #live-stock-prices .stock-name,
  #live-stock-prices .stock-price {
    font-size: 1em !important;
  }
  /* Move log scale toggle below graph and center it */
  .graph-container > div[style*='position: absolute'] {
    position: static !important;
    margin: 12px auto 0 auto !important;
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
  }
}

@media (max-width: 375px) {
  #live-stock-prices {
    font-size: 0.85em !important;
  }
}

/* --- FORCE MOBILE LEGEND OVERRIDE --- */
@media (max-width: 768px) {
  .graph-container #custom-legend,
  #custom-legend,
  #custom-legend * {
    font-size: 0.7em !important;
    padding: 2px 4px !important;
    min-width: 20px !important;
    left: 4px !important;
    top: 8px !important;
    color: #fff !important;
    line-height: 1.2 !important;
  }
}
@media (max-width: 480px) {
  .graph-container #custom-legend,
  #custom-legend,
  #custom-legend * {
    font-size: 0.6em !important;
    padding: 1px 2px !important;
    min-width: 10px !important;
    left: 2px !important;
    top: 4px !important;
    color: #fff !important;
    line-height: 1.2 !important;
  }
}


/* Mobile touch support */
@media (max-width: 768px) {
    .widget-handle,
    .widget-remove,
    .widget-restore {
        font-size: 40px;
        width: 60px;
        height: 60px;
    }
    
    .edit-btn,
    .view-toggle-btn,
    .info-btn,
    .currency-toggle-btn,
    .theme-toggle-btn,
    .time-filter-btn {
        width: 36px;
        height: 36px;
        font-size: 0.8em;
    }
}

/* Small mobile support for 400px screens */
@media (min-width: 361px) and (max-width: 400px) {
    .widget-handle,
    .widget-remove,
    .widget-restore {
        font-size: 36px;
        width: 50px;
        height: 50px;
    }
    
    .edit-btn,
    .view-toggle-btn,
    .info-btn,
    .currency-toggle-btn,
    .theme-toggle-btn,
    .time-filter-btn {
        width: 30px;
        height: 30px;
        font-size: 0.7em;
    }
}

/* Extra small mobile support for 360px screens */
@media (max-width: 360px) {
    .widget-handle,
    .widget-remove,
    .widget-restore {
        font-size: 28px;
        width: 42px;
        height: 42px;
    }
    
    .edit-btn,
    .view-toggle-btn,
    .info-btn,
    .currency-toggle-btn,
    .theme-toggle-btn,
    .time-filter-btn {
        width: 28px;
        height: 28px;
        font-size: 0.6em;
    }
    
    /* Make market notification text bigger on 360px screens */
    #market-notification {
        font-size: 0.9em !important;
        padding: 4px 6px;
        line-height: 1.5;
    }
    
    #market-notification > div {
        gap: 0px !important;
    }
    
    #market-notification > div > div {
        line-height: 1.5;
        gap: 0px;
        padding: 3px 0;
    }
    
    #market-notification span {
        font-size: 0.9em;
        line-height: 1.5;
    }
} 