* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 13.4px;
}

#container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20.1px;
    width: 100%;
    max-width: 100%;
    padding: 0 26.8px;
}

#patternButtons, #chartContainer, #controls {
    background-color: var(--card-background);
    border-radius: 10.05px;
    box-shadow: 0 6.7px 20.1px var(--shadow-color);
    padding: 20.1px;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

#patternButtons:hover, #controls:hover {
    box-shadow: 0 10.05px 26.8px var(--shadow-color);
    transform: translateY(-3.35px);
}

#chartContainer:hover {
    box-shadow: 0 10.05px 26.8px var(--shadow-color);
}

#chartContainer {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h3 {
    font-size: 16.08px;
    color: var(--primary-color);
    margin-bottom: 16.75px;
    border-bottom: 2.01px solid var(--primary-color);
    padding-bottom: 10.05px;
    text-transform: uppercase;
    letter-spacing: 0.67px;
}

#chart {
    width: 100%;
    height: 75vh;
    min-height: 402px;
    background-color: var(--background-color);
    border: 1.34px solid var(--border-color);
    border-radius: 6.7px;
    position: relative;
    margin-bottom: 20.1px;
    overflow: hidden;
    white-space: nowrap;
    transition: border-color 0.3s ease;
    padding: 13.4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}

#chartZoomContainer {
    position: relative;
    transform-origin: center center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    height: 100%;
}

/* Custom scrollbar styling */
#chart::-webkit-scrollbar {
    height: 8.04px;
}

#chart::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 6.7px;
    margin: 0 6.7px;
}

#chart::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 6.7px;
    border: 1.34px solid var(--background-color);
}

#chart::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #2980b9, #27ae60);
}

#chart:hover {
    border-color: var(--primary-color);
}

/* Library pattern isolation box */
.library-pattern-group {
    position: absolute;
    border: 1.34px dashed #f0ad4e;
    background: rgba(255, 243, 205, 0.2);
    border-radius: 5.36px;
    padding: 3.35px;
    z-index: 1;
    pointer-events: auto; /* Enable hover detection */
    transition: all 0.3s ease;
    cursor: pointer; /* Show pointer cursor to indicate clickable */
}

.library-pattern-group:hover {
    background: rgba(255, 243, 205, 0.5);
    border-color: #e67e22;
    border-width: 1.68px;
    transform: scale(1.02);
    box-shadow: 0 1.34px 5.36px rgba(230, 126, 34, 0.3);
    z-index: 10; /* Bring to front on hover */
}

.library-pattern-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8.04px;
    color: #e67e22;
    background: rgba(255, 255, 255, 0.95);
    padding: 2.68px 8.04px;
    border-radius: 8.04px;
    font-weight: 600;
    z-index: 100;
    box-shadow: 0 1.34px 4.02px rgba(0,0,0,0.2);
    text-transform: uppercase;
    opacity: 0; /* Hidden by default */
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    white-space: nowrap; /* Prevent text wrapping */
    pointer-events: none; /* Don't block mouse events */
}

.library-pattern-group:hover .library-pattern-label {
    opacity: 1;
    visibility: visible;
    letter-spacing: 0.34px;
}

/* Small corner indicator for library pattern boxes */
.library-pattern-group::after {
    content: "";
    position: absolute;
    top: 3.35px;
    right: 3.35px;
    width: 5.36px;
    height: 5.36px;
    background: #f0ad4e;
    border-radius: 50%;
    opacity: 0.5;
    transition: opacity 0.3s ease;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 0.5; }
}

.library-pattern-group:hover::after {
    opacity: 0.8;
    animation: none;
}

/* Highlight library pattern candlesticks */
.candlestick.library-pattern {
    /* Add any special styling for library pattern candlesticks if needed */
}

/* Pattern tooltip at bottom of screen */
#patternTooltip {
    position: fixed;
    bottom: 13.4px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6.7px 13.4px;
    border-radius: 16.75px;
    font-size: 9.38px;
    font-weight: 600;
    box-shadow: 0 2.68px 10.05px rgba(0,0,0,0.2);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.67px;
}

#patternTooltip.visible {
    opacity: 1;
}

/* Interactive candlestick feature popup */
.candlestick-feature-popup {
    position: absolute;
    background: white;
    border: 1.34px solid var(--primary-color);
    border-radius: 8.04px;
    padding: 10.05px;
    box-shadow: 0 5.36px 16.75px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 167.5px;
    max-width: 268px;
    max-height: 335px;
    overflow-y: auto;
    display: none;
    animation: popupFadeIn 0.3s ease;
    user-select: none;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-6.7px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.candlestick-feature-popup.active {
    display: block;
}

.candlestick-feature-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10.05px;
    padding-bottom: 6.7px;
    border-bottom: 1.34px solid var(--border-color);
    cursor: move;
}

.candlestick-feature-popup-title {
    font-size: 10.72px;
    font-weight: 600;
    color: var(--primary-color);
}

.candlestick-feature-popup-close {
    background: none;
    border: none;
    font-size: 13.4px;
    color: var(--text-color);
    cursor: pointer;
    padding: 0;
    width: 16.08px;
    height: 16.08px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.candlestick-feature-popup-close:hover {
    background-color: var(--hover-color);
}

.candlestick-feature-list {
    max-height: 268px;
    overflow-y: auto;
    padding-right: 3.35px;
}

.candlestick-feature-item {
    display: flex;
    align-items: center;
    padding: 5.36px 6.7px;
    margin: 3.35px 0;
    background-color: var(--background-color);
    border-radius: 5.36px;
    transition: background-color 0.3s, transform 0.2s;
    cursor: pointer;
}

.candlestick-feature-item:hover {
    background-color: var(--hover-color);
    transform: translateX(3.35px);
}

.candlestick-feature-item input[type="checkbox"] {
    margin-right: 6.7px;
    cursor: pointer;
    transform: scale(1.2);
}

.candlestick-feature-item label {
    cursor: pointer;
    font-size: 9.38px;
    color: var(--text-color);
    user-select: none;
    flex: 1;
}

/* Selected candlestick highlight */
/* Removed duplicate - using enhanced version below */

.candlestick {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 1.34px 2.68px var(--candle-shadow));
}

.candlestick:hover:not(.selected) {
    filter: drop-shadow(0 2.68px 8.04px rgba(0,0,0,0.25));
    z-index: 100;
}

.candlestick:active {
    transform: translateY(-2.01px) scale(1.02);
    transition: transform 0.1s;
}

#valueDisplay {
    display: none; /* Hidden - using centered OHLC display instead */
    justify-content: space-evenly;
    width: 100%;
    background-color: var(--card-background);
    padding: 13.4px;
    border-radius: 6.7px;
    box-shadow: 0 3.35px 10.05px var(--shadow-color);
    margin-bottom: 20.1px;
}

.value-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6.7px;
}

.value-input label {
    font-size: 10.72px;
    color: var(--text-color);
    margin-bottom: 5.36px;
    font-weight: 600;
}

.value-input input {
    width: 80.4px;
    padding: 6.7px;
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    text-align: center;
    font-size: 12.06px;
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: var(--background-color);
}

.value-input input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2.01px rgba(52, 152, 219, 0.3);
}

#controls, #patternButtons {
    display: none;
    flex-direction: column;
    align-items: stretch;
}

button {
    border: none;
    padding: 9.38px;
    font-size: 10.72px;
    border-radius: 5.36px;
    cursor: pointer;
    margin: 5.36px 0;
    transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.67px;
}

button:hover {
    transform: translateY(-1.34px);
    box-shadow: 0 3.35px 10.05px var(--shadow-color);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1.34px 3.35px var(--shadow-color);
}

#addBullish {
    background-color: var(--secondary-color);
}

#addBullish:hover {
    background-color: #27ae60;
}

#addBearish {
    background-color: var(--tertiary-color);
}

#addBearish:hover {
    background-color: #c0392b;
}

#deleteCandlestick {
    background-color: #95a5a6;
}

#deleteCandlestick:hover {
    background-color: #7f8c8d;
}

#controlCandlestick {
    width: 67px;
    height: 167.5px;
    position: relative;
    margin: 26.8px auto;
    background-color: var(--background-color);
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    transition: border-color 0.3s ease;
}

#controlCandlestick:hover {
    border-color: var(--primary-color);
}

.control-handle {
    width: 16.08px;
    height: 16.08px;
    background-color: var(--primary-color);
    border: 2.01px solid white;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    transform: translate(-50%, 50%);
    cursor: ns-resize;
    transition: bottom 0.6s ease-out, box-shadow 0.3s;
}

.control-handle:hover {
    box-shadow: 0 0 0 3.35px rgba(52, 152, 219, 0.3);
}

/* Interactive candlestick parts when selected */
.candlestick.selected .candlestick-wick {
    cursor: ns-resize;
    transition: width 0.1s ease, background-color 0.1s ease;
}

/* Ghost handle for upper wick - appears at top */
.candlestick.selected .candlestick-wick.upper::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

/* Ghost handle for lower wick - appears at bottom */
.candlestick.selected .candlestick-wick.lower::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

/* Show ghost handles on wick hover */
.candlestick.selected .candlestick-wick:hover::after {
    opacity: 1;
}

.candlestick.selected .candlestick-wick:hover {
    width: 2.5px;
}

/* Directional drag colors for wicks */
.candlestick.selected .candlestick-wick.dragging-up {
    background-color: var(--candle-bullish);
    width: 2.5px;
}

.candlestick.selected .candlestick-wick.dragging-up::after {
    opacity: 1;
    background: var(--candle-bullish);
    border-color: var(--candle-bullish-border);
}

.candlestick.selected .candlestick-wick.dragging-down {
    background-color: var(--candle-bearish);
    width: 2.5px;
}

.candlestick.selected .candlestick-wick.dragging-down::after {
    opacity: 1;
    background: var(--candle-bearish);
    border-color: var(--candle-bearish-border);
}

.candlestick.selected .candlestick-body {
    cursor: ns-resize;
    transition: box-shadow 0.1s ease;
}

/* Ghost handles for body - top and bottom edges */
.candlestick.selected .candlestick-body::before,
.candlestick.selected .candlestick-body::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.candlestick.selected .candlestick-body::before {
    top: 2px;
}

.candlestick.selected .candlestick-body::after {
    bottom: 2px;
}

/* Show ghost handles on body hover */
.candlestick.selected .candlestick-body:hover::before,
.candlestick.selected .candlestick-body:hover::after {
    opacity: 1;
}

/* Subtle body glow on hover */
.candlestick.selected .candlestick-body:hover {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

/* Body dragging - subtle directional feedback */
.candlestick.selected .candlestick-body.dragging-up {
    box-shadow: 0 0 0 1px var(--candle-bullish);
}

.candlestick.selected .candlestick-body.dragging-up::before,
.candlestick.selected .candlestick-body.dragging-up::after {
    opacity: 1;
    background: var(--candle-bullish);
}

.candlestick.selected .candlestick-body.dragging-down {
    box-shadow: 0 0 0 1px var(--candle-bearish);
}

.candlestick.selected .candlestick-body.dragging-down::before,
.candlestick.selected .candlestick-body.dragging-down::after {
    opacity: 1;
    background: var(--candle-bearish);
}

/* Hide old wick drag handles - not using them */
.candlestick .wick-drag-handle {
    display: none !important;
}

/* Value tooltip during drag */
.drag-value-tooltip {
    position: fixed;
    padding: 6px 10px;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'Segoe UI', monospace;
    pointer-events: none;
    z-index: 10001;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: none;
}

.drag-value-tooltip .tooltip-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.drag-value-tooltip .tooltip-value {
    font-size: 14px;
    font-weight: 700;
}

.drag-value-tooltip .tooltip-delta {
    font-size: 10px;
    margin-left: 6px;
}

.drag-value-tooltip .tooltip-delta.positive {
    color: var(--candle-bullish);
}

.drag-value-tooltip .tooltip-delta.negative {
    color: var(--candle-bearish);
}

body.dark-mode .drag-value-tooltip {
    background: rgba(22, 33, 62, 0.98);
    border: 1px solid var(--border-color);
}

/* Body half overlays for drag indication */
.body-drag-overlay {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease-out;
    z-index: 999;
}

.body-drag-overlay.top {
    top: 0;
    background: linear-gradient(to bottom,
        rgba(52, 152, 219, 0.65),
        rgba(52, 152, 219, 0.35));
    border-top: 1.34px solid rgba(52, 152, 219, 0.8);
    border-left: 1.34px solid rgba(52, 152, 219, 0.6);
    border-right: 1.34px solid rgba(52, 152, 219, 0.6);
    border-top-left-radius: 2.01px;
    border-top-right-radius: 2.01px;
    box-shadow: inset 0 0.67px 2.01px rgba(52, 152, 219, 0.5);
}

.body-drag-overlay.bottom {
    bottom: 0;
    background: linear-gradient(to top,
        rgba(52, 152, 219, 0.65),
        rgba(52, 152, 219, 0.35));
    border-bottom: 1.34px solid rgba(52, 152, 219, 0.8);
    border-left: 1.34px solid rgba(52, 152, 219, 0.6);
    border-right: 1.34px solid rgba(52, 152, 219, 0.6);
    border-bottom-left-radius: 2.01px;
    border-bottom-right-radius: 2.01px;
    box-shadow: inset 0 -0.67px 2.01px rgba(52, 152, 219, 0.5);
}

.body-drag-overlay.active {
    opacity: 1;
}

/* Different colors for bearish (red) candlesticks */
.candlestick[data-type="bearish"] .body-drag-overlay.top {
    background: linear-gradient(to bottom,
        rgba(255, 152, 0, 0.65),
        rgba(255, 152, 0, 0.35));
    border-top: 1.34px solid rgba(255, 152, 0, 0.8);
    border-left: 1.34px solid rgba(255, 152, 0, 0.6);
    border-right: 1.34px solid rgba(255, 152, 0, 0.6);
    box-shadow: inset 0 0.67px 2.01px rgba(255, 152, 0, 0.5);
}

.candlestick[data-type="bearish"] .body-drag-overlay.bottom {
    background: linear-gradient(to top,
        rgba(255, 152, 0, 0.65),
        rgba(255, 152, 0, 0.35));
    border-bottom: 1.34px solid rgba(255, 152, 0, 0.8);
    border-left: 1.34px solid rgba(255, 152, 0, 0.6);
    border-right: 1.34px solid rgba(255, 152, 0, 0.6);
    box-shadow: inset 0 -0.67px 2.01px rgba(255, 152, 0, 0.5);
}

.candlestick {
    position: absolute;
    width: 20.1px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.candlestick-body {
    position: absolute;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 1.34px;
    box-shadow: 0 0.67px 2.01px var(--candle-shadow);
}

/* Make candlestick body narrower and centered in control containers */
#controlCandlestick .candlestick-body,
.popup-control-candlestick .candlestick-body {
    width: 20.1px;
    left: 50%;
    transform: translateX(-50%);
}

.candlestick-wick {
    position: absolute;
    width: 1.34px;
    background-color: var(--wick-color);
    left: 50%;
    transform: translateX(-50%);
    transition: all 0.3s ease;
    border-radius: 0.67px;
}

/* Enhanced hover states for different candlestick types */
.candlestick[data-type="bullish"]:hover .candlestick-body {
    background-color: var(--candle-bullish-hover) !important;
    box-shadow: 0 2.68px 8.04px rgba(38, 166, 154, 0.4);
    transform: scaleX(1.1);
}

.candlestick[data-type="bearish"]:hover .candlestick-body {
    background-color: var(--candle-bearish-hover) !important;
    box-shadow: 0 2.68px 8.04px rgba(239, 83, 80, 0.4);
    transform: scaleX(1.1);
}

.candlestick[data-type="neutral"]:hover .candlestick-body {
    background-color: #bdbdbd !important;
    box-shadow: 0 2.68px 8.04px rgba(158, 158, 158, 0.4);
    transform: scaleX(1.1);
}

.candlestick:hover .candlestick-wick {
    width: 2.01px;
    background-color: #37474f;
}

/* Enhanced selected state - blue dashed style */
.candlestick.selected {
    outline: 1.34px dashed #3498db;
    outline-offset: 5.36px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 5.36px;
}

.candlestick.selected:hover {
    outline-color: #2980b9;
    outline-width: 1.68px;
    outline-offset: 5.36px;
    background: rgba(52, 152, 219, 0.15);
}

/* Chart Control Popup - appears on chart when candlestick is selected */
.chart-control-popup {
    position: fixed;
    background: white;
    border: 1.34px solid var(--primary-color);
    border-radius: 8.04px;
    padding: 10.05px;
    box-shadow: 0 5.36px 16.08px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
}

.chart-control-popup-header {
    padding: 8.04px 10.72px;
    margin: -10.05px -10.05px 10.05px -10.05px;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 9.38px;
    border-radius: 6.7px 6.7px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.chart-control-popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 16.08px;
    cursor: pointer;
    padding: 0;
    width: 16.08px;
    height: 16.08px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2.68px;
    transition: background 0.2s;
}

.chart-control-popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.popup-control-candlestick {
    position: relative;
    width: 100.5px;
    height: 134px;
    margin: 26.8px auto;
    background: var(--background-color);
    border-radius: 5.36px;
    padding: 6.7px;
}

/* Candlestick option buttons - positioned at top right when candlestick selected */
.candlestick-options {
    position: absolute;
    bottom: 10.72px;
    left: 10.72px;
    display: flex;
    gap: 5.36px;
    z-index: 1000;
    pointer-events: all;
}

.candlestick-option-btn {
    width: 36px;
    height: 36px;
    background: white;
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2.68px 8.04px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.candlestick-option-btn:hover:not(:disabled) {
    background: var(--primary-color);
    transform: translateY(-1.34px);
    box-shadow: 0 4.02px 10.72px rgba(0, 0, 0, 0.2);
}

.candlestick-option-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f5f5f5;
    border-color: #ccc;
    pointer-events: none;
}

/* Wrapper for disabled button to capture clicks */
#generatePatternWrapper {
    cursor: not-allowed;
}

.tab {
    display: flex;
    justify-content: space-around;
    margin-top: 20.1px;
    background-color: var(--background-color);
    border-radius: 6.7px 6.7px 0 0;
    overflow: hidden;
    box-shadow: 0 -3.35px 10.05px var(--shadow-color);
}

.tab button {
    background-color: var(--background-color);
    border: none;
    outline: none;
    cursor: pointer;
    padding: 10.05px 13.4px;
    transition: 0.3s;
    font-size: 10.72px;
    color: var(--text-color);
    flex-grow: 1;
    border-bottom: 2.01px solid transparent;
}

.tab button:hover {
    background-color: var(--hover-color);
}

.tab button.active {
    background-color: var(--card-background);
    color: var(--primary-color);
    border-bottom: 2.01px solid var(--primary-color);
}

.tabcontent {
    display: none;
    padding: 20.1px;
    background-color: var(--card-background);
    border-radius: 0 0 6.7px 6.7px;
    box-shadow: 0 3.35px 10.05px var(--shadow-color);
}

.tabcontent.active {
    display: block;
    animation: fadeEffect 1s;
}

@keyframes fadeEffect {
    from {opacity: 0;}
    to {opacity: 1;}
}

#featuresList h3 {
    font-size: 13.4px;
    margin-bottom: 10.05px;
    color: var(--text-color);
}

.features-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10.05px;
}

.feature-item {
    display: flex;
    align-items: center;
    padding: 6.7px 10.05px;
    background-color: var(--background-color);
    border-radius: 16.75px;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 1.34px 3.35px var(--shadow-color);
}

.feature-item:hover {
    background-color: var(--hover-color);
    transform: translateY(-1.34px);
}

.feature-item input[type="checkbox"] {
    margin-right: 6.7px;
    transform: scale(1.2);
}

.dropdown-container {
    margin-bottom: 13.4px;
}

.dropdown-title {
    font-size: 10.72px;
    font-weight: 600;
    margin-bottom: 5.36px;
    color: var(--text-color);
}

select {
    width: 100%;
    padding: 8.04px;
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    background-color: var(--card-background);
    transition: border-color 0.3s, box-shadow 0.3s;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23333" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 6.7px top 50%;
    background-size: 13.4px auto;
    font-size: 10.72px;
}

select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2.01px rgba(52, 152, 219, 0.2);
}

.action-button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 8.04px 13.4px;
    border-radius: 5.36px;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.3s ease, transform 0.2s;
    margin-top: 10.05px;
    font-size: 12.06px;
    font-weight: 600;
}

.action-button:hover {
    background-color: #27ae60;
    transform: translateY(-1.34px);
}

#ExportPineScript {
    width: 100%;
    height: 268px;
    display: flex;
    flex-direction: column;
}

#output {
    width: 100%;
    height: 100%;
    padding: 10.05px;
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    resize: none;
    font-size: 9.38px;
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--card-background);
    color: var(--text-color);
    transition: border-color 0.3s, box-shadow 0.3s;
    overflow: auto;
}

#output:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2.01px rgba(52, 152, 219, 0.2);
}

/* Tablet: 514.56px - 686.08px */
@media (max-width: 686.08px) and (min-width: 515.23px) {
    #container {
        grid-template-columns: 1fr 2.5fr 1fr;
        gap: 13.4px;
    }

    #chart {
        height: 268px;
        padding: 10.05px;
    }

    .candlestick {
        width: 16.75px;
    }
}

/* Mobile & Small Tablet: max 514.56px */
@media (max-width: 514.56px) {
    #container {
        grid-template-columns: 1fr;
        gap: 10.05px;
    }

    #chart {
        height: 201px;
        padding: 6.7px;
        overflow-x: scroll;
    }

    .candlestick {
        width: 13.4px;
    }

    button {
        font-size: 9.38px;
        padding: 6.7px;
    }

    #valueDisplay {
        flex-wrap: wrap;
    }

    .value-input {
        flex: 1 1 45%;
        min-width: 93.8px;
    }

    #candlestickCounter {
        font-size: 7.37px;
        padding: 4.02px 8.04px;
    }
}

/* Extra small mobile: max 321.6px */
@media (max-width: 321.6px) {
    #chart {
        height: 167.5px;
        padding: 5.36px;
    }

    .candlestick {
        width: 12.06px;
    }

    .value-input {
        flex: 1 1 100%;
    }

    button {
        padding: 5.36px;
        font-size: 8.71px;
    }
}

#multiCandleComparisons {
    display: flex;
    flex-direction: column;
    gap: 13.4px;
}

.comparison-row {
    display: flex;
    align-items: center;
    gap: 10.05px;
}

.comparison-row select, .comparison-row input {
    flex: 1;
}

#comparisonResults {
    margin-top: 16.75px;
    padding: 13.4px;
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    background-color: var(--background-color);
}

.comparison-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6.7px;
    padding: 10.05px;
    background-color: var(--card-background);
    border-radius: 5.36px;
    transition: background-color 0.3s;
    box-shadow: 0 1.34px 3.35px var(--shadow-color);
}

.comparison-item:hover {
    background-color: var(--hover-color);
}

.delete-comparison {
    background-color: var(--tertiary-color);
    color: white;
    border: none;
    padding: 5.36px 8.04px;
    border-radius: 3.35px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.delete-comparison:hover {
    background-color: #c0392b;
}

#generatedPatternList {
    margin-top: 16.75px;
    max-height: 201px;
    overflow-y: auto;
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    padding: 13.4px;
    background-color: var(--background-color);
}

.generated-condition {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6.7px;
    padding: 8.04px;
    background-color: var(--card-background);
    border-radius: 5.36px;
    transition: background-color 0.3s, transform 0.2s;
    box-shadow: 0 1.34px 3.35px var(--shadow-color);
}

.generated-condition:hover {
    background-color: var(--hover-color);
    transform: translateY(-1.34px);
}

.delete-condition {
    background-color: var(--tertiary-color);
    color: white;
    border: none;
    padding: 3.35px 6.7px;
    border-radius: 3.35px;
    cursor: pointer;
    font-size: 9.38px;
    transition: background-color 0.3s, transform 0.2s;
}

.delete-condition:hover {
    background-color: #c0392b;
    transform: scale(1.05);
}

#libraryButton {
    background-color: var(--secondary-color);
    color: white;
    padding: 6.7px 10.05px;
    border: none;
    border-radius: 2.68px;
    cursor: pointer;
    margin-top: 6.7px;
    transition: background-color 0.3s, transform 0.2s;
}

#libraryButton:hover {
    background-color: #27ae60;
    transform: translateY(-1.34px);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content {
    background-color: var(--card-background);
    margin: 5% auto;
    padding: 13.4px;
    border: 0.67px solid var(--border-color);
    border-radius: 6.7px;
    width: 80%;
    max-width: 804px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2.68px 13.4px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-33.5px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    color: #aaa;
    float: right;
    font-size: 18.76px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover,
.close:focus {
    color: var(--text-color);
    text-decoration: none;
}

#librarySearch {
    width: 100%;
    padding: 8.04px;
    margin-bottom: 13.4px;
    box-sizing: border-box;
    border: 0.67px solid var(--border-color);
    border-radius: 3.35px;
    font-size: 10.72px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#librarySearch:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 1.34px rgba(52, 152, 219, 0.2);
}

        .library-container {
            display: flex;
            gap: 13.4px;
            height: 335px;
        }

.category-list {
    width: 134px;
    border-right: 0.67px solid var(--border-color);
    padding-right: 13.4px;
    overflow-y: auto;
}

.category-list ul {
    list-style-type: none;
    padding: 0;
}

.category-list li {
    cursor: pointer;
    padding: 8.04px;
    border-radius: 5.36px;
    transition: background-color 0.3s, color 0.3s;
}

.category-list li:hover {
    background-color: var(--primary-color);
    color: white;
}

.pattern-list {
    flex-grow: 1;
    overflow-y: auto;
    padding-left: 13.4px;
    padding-right: 13.4px;
}

.selected-patterns-container {
    width: 167.5px;
    border-left: 0.67px solid var(--border-color);
    padding-left: 13.4px;
    display: flex;
    flex-direction: column;
}

#selectedPatternsList {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 13.4px;
    list-style: none;
    padding: 0;
}

#selectedPatternsList li {
    margin-bottom: 6.7px;
    background-color: var(--background-color);
    padding: 6.7px 10.05px;
    border-radius: 5.36px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s;
}

#selectedPatternsList li:hover {
    background-color: var(--hover-color);
}

.remove-pattern {
    background-color: var(--tertiary-color);
    color: white;
    border: none;
    padding: 3.35px 6.7px;
    border-radius: 3.35px;
    cursor: pointer;
    font-size: 8.04px;
    transition: background-color 0.3s, transform 0.2s;
}

.remove-pattern:hover {
    background-color: #c0392b;
    transform: scale(1.05);
}

#applyPatternsButton {
    margin-top: auto;
}

/* Commented out - sidebars are now hidden
#patternButtons {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: visible;
}
*/

#patternButtons button {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 6.7px;
    padding: 8.04px 12.06px;
    background-color: var(--background-color);
    color: var(--text-color);
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    font-size: 10.72px;
    line-height: 1.4;
    transition: background-color 0.3s, color 0.3s, box-shadow 0.3s, transform 0.2s;
    overflow: visible;
    white-space: normal;
    height: auto;
    min-height: 33.5px;
}

#patternButtons button:hover {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 3.35px 10.05px rgba(0, 0, 0, 0.1);
    transform: translateY(-1.34px);
}

.pattern-category {
    margin-bottom: 13.4px;
}


#dojiOptions,
#singleCandleOptions,
#bodyTypeOptions,
#wickTypeOptions {
    display: none;
    margin-left: 13.4px;
}

#dojiOptions button,
#singleCandleOptions button,
#bodyTypeOptions button,
#wickTypeOptions button {
    background-color: var(--background-color);
    border-left: 2.68px solid var(--primary-color);
    padding-left: 10.05px;
    transition: background-color 0.3s ease, transform 0.2s;
}

#dojiOptions button:hover,
#singleCandleOptions button:hover,
#bodyTypeOptions button:hover,
#wickTypeOptions button:hover {
    background-color: #e8f4fd;
    transform: translateX(3.35px);
}

/* Ensure text is visible */
#patternButtons button span,
#patternButtons button:before,
#patternButtons button:after {
    display: inline-block;
    vertical-align: middle;
}

/* Reset any potential interfering styles */
#patternButtons button * {
    visibility: visible;
    opacity: 1;
}

.comparison-containers {
    display: flex;
    justify-content: space-between;
    gap: 20.1px;
}

.comparison-container {
    width: 48%;
    margin-top: 16.75px;
    padding: 13.4px;
    border: 1.34px solid var(--border-color);
    border-radius: 6.7px;
    background-color: var(--card-background);
    height: 234.5px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 3.35px 10.05px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s, transform 0.2s;
}

.comparison-container:hover {
    box-shadow: 0 6.7px 16.75px rgba(0, 0, 0, 0.15);
    transform: translateY(-3.35px);
}

.comparison-container h4 {
    margin-top: 0;
    margin-bottom: 13.4px;
    color: var(--primary-color);
    font-size: 13.4px;
}

.comparison-container button {
    margin-top: 0;
    margin-bottom: 13.4px;
}

#comparisonList, #checkComparisonList {
    flex-grow: 1;
    overflow-y: auto;
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    padding: 10.05px;
    background-color: var(--background-color);
    margin-top: 10.05px;
}

#checkComparisonButton {
    background-color: #f39c12;
    color: white;
}

#checkComparisonButton:hover {
    background-color: #e67e22;
}

.comparison-true {
    background-color: #d4edda;
    color: #155724;
    padding: 6.7px;
    border-radius: 4.02px;
    margin-bottom: 5.36px;
    transition: transform 0.2s;
}

.comparison-false {
    background-color: #f8d7da;
    color: #721c24;
    padding: 6.7px;
    border-radius: 4.02px;
    margin-bottom: 5.36px;
    transition: transform 0.2s;
}

.comparison-true:hover,
.comparison-false:hover {
    transform: translateX(3.35px);
}

.pattern-item {
    position: relative;
    padding: 10.05px;
    border: 0.67px solid var(--border-color);
    border-radius: 5.36px;
    margin-bottom: 10.05px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.pattern-item:hover {
    background-color: #f5f5f5;
    box-shadow: 0 2.68px 6.7px rgba(0, 0, 0, 0.1);
}

.pattern-preview {
    display: none;
    position: absolute;
    width: 107.2px;
    height: 134px;
    background-color: var(--card-background);
    border: 0.67px solid var(--border-color);
    border-radius: 3.35px;
    padding: 6.7px;
    box-shadow: 0 1.34px 6.7px rgba(0, 0, 0, 0.1);
    z-index: 1100;
    pointer-events: none;
    transform: translate(20%, -50%); /* Center the preview around the cursor */
}
.pattern-item:hover .pattern-preview {
    display: block;
}

#previewContainer {
    position: fixed;
    display: none;
    width: 40.2px;
    height: 80.4px;
    background-color: var(--card-background);
    border: 0.67px solid var(--border-color);
    border-radius: 3.35px;
    padding: 3.35px;
    z-index: 1000;
    box-shadow: 0 1.34px 6.7px rgba(0, 0, 0, 0.1);
}

#previewCandlestick {
    width: 100%;
    height: 100%;
    position: relative;
}
.candlestick {
    position: absolute;
}

.candlestick-body, .candlestick-wick {
    position: absolute;
    width: 100%;
}

.candlestick-wick {
    width: 1.34px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-color);
}

.pattern-item {
    position: relative;
    padding: 10.05px;
    border: 0.67px solid var(--border-color);
    border-radius: 5.36px;
    margin-bottom: 10.05px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.pattern-item:hover {
    background-color: #f5f5f5;
    box-shadow: 0 2.68px 6.7px rgba(0, 0, 0, 0.1);
}

.pattern-item.selected {
    background-color: #e6f3ff;
    border-color: var(--primary-color);
}

.pattern-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
}

.pattern-item label {
    display: block;
    padding-left: 20.1px;
    position: relative;
    cursor: pointer;
}

.pattern-item label::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1.34px;
    width: 13.4px;
    height: 13.4px;
    border: 1.34px solid var(--primary-color);
    border-radius: 2.68px;
    background-color: #fff;
    transition: background-color 0.3s, border-color 0.3s;
}

.pattern-item input[type="checkbox"]:checked + label::before {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.pattern-item input[type="checkbox"]:checked + label::after {
    content: '\2714';
    position: absolute;
    left: 3.35px;
    top: 0.67px;
    color: #fff;
    font-size: 9.38px;
}

.pattern-name {
    font-weight: bold;
    display: block;
    margin-bottom: 3.35px;
    color: var(--primary-color);
}

.pattern-description {
    font-size: 0.9em;
    color: var(--text-color);
    margin: 0;
    line-height: 1.4;
}

.pattern-preview {
    margin-top: 10.05px;
}


#applyPatternsButton {
    margin-top: 16.75px;
    background-color: var(--secondary-color);
    color: white;
    padding: 8.04px 13.4px;
    border: none;
    border-radius: 5.36px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    font-size: 10.72px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.67px;
}

#applyPatternsButton:hover {
    background-color: #27ae60;
    transform: translateY(-1.34px);
}

/* Improve scrollbar appearance */
::-webkit-scrollbar {
    width: 6.7px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 3.35px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3.35px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

/* Add some helper classes for general use */
.mt-10 { margin-top: 6.7px; }
.mt-20 { margin-top: 13.4px; }
.mb-10 { margin-bottom: 6.7px; }
.mb-20 { margin-bottom: 13.4px; }

/* Improve form element styling */
input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 8.04px;
    margin-bottom: 10.05px;
    border: 1.34px solid var(--border-color);
    border-radius: 5.36px;
    font-size: 10.72px;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2.01px rgba(52, 152, 219, 0.2);
}

/* Add a subtle animation to buttons */
button {
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3.35px;
    height: 3.35px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 1;
    }
    20% {
        transform: scale(25, 25);
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: scale(40, 40);
    }
}

button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

/* Improve tooltip appearance */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5.36px 8.04px;
    background-color: var(--text-color);
    color: white;
    font-size: 9.38px;
    border-radius: 2.68px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Removed scale transform to prevent popup positioning issues */

/* Improve the appearance of the generated pattern list */
#generatedPatternList {
    border: 1.34px solid var(--border-color);
    border-radius: 6.7px;
    padding: 13.4px;
    max-height: 268px;
    overflow-y: auto;
}

.generated-condition {
    background-color: var(--background-color);
    border: 0.67px solid var(--border-color);
    border-radius: 5.36px;
    padding: 8.04px 10.05px;
    margin-bottom: 6.7px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.generated-condition:hover {
    transform: translateX(3.35px);
    box-shadow: 0 1.34px 3.35px rgba(0, 0, 0, 0.1);
}


.modal.show .modal-content {
    transform: scale(1);
    opacity: 1;
}

/* Improve the appearance of the library button */
#libraryButton {
    display: inline-block;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

#libraryButton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: all 0.6s;
}

#libraryButton:hover::before {
    left: 100%;
}

/* Add a pulsating effect to the add buttons */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6.7px rgba(46, 204, 113, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

#addBullish,
#addBearish {
    animation: pulse 2s infinite;
}

/* Improve the appearance of the control candlestick */
#controlCandlestick {
    transition: all 0.3s ease;
}

#controlCandlestick:hover {
    transform: scale(1.05);
    box-shadow: 0 3.35px 10.05px rgba(0, 0, 0, 0.1);
}

/* Add a subtle animation to the tab buttons */
.tab button {
    transition: all 0.3s ease;
}

.tab button:hover {
    transform: translateY(-1.34px);
}

/* Improve the appearance of the feature items */
.feature-item {
    transition: all 0.3s ease;
}

.feature-item:hover {
    transform: translateY(-1.34px);
    box-shadow: 0 3.35px 10.05px rgba(0, 0, 0, 0.1);
}

/* Add a subtle animation to the candlesticks */
.candlestick {
    transition: all 0.3s ease;
}

.candlestick:hover {
    transform: scale(1.1);
    z-index: 10;
}

/* Improve the appearance of the comparison containers */
.comparison-container {
    transition: all 0.3s ease;
}

.comparison-container:hover {
    transform: translateY(-3.35px);
    box-shadow: 0 6.7px 13.4px rgba(0, 0, 0, 0.1);
}



/* Improve the appearance of the preview container */
#previewContainer {
    transition: all 0.3s ease;
}

#previewContainer:hover {
    transform: scale(1.1);
    box-shadow: 0 3.35px 10.05px rgba(0, 0, 0, 0.2);
}

/* Add a subtle animation to the value inputs */
.value-input input {
    transition: all 0.3s ease;
}

.value-input input:focus {
    transform: scale(1.05);
}

/* Improve the appearance of the output textarea */
#output {
    transition: all 0.3s ease;
}

#output:focus {
    transform: translateY(-1.34px);
    box-shadow: 0 3.35px 10.05px rgba(0, 0, 0, 0.1);
}
    
    
    
    
            /* Add styles for the new save pattern button and modal */
        #savePatternButton {
            background-color: #9b59b6;
            color: white;
            padding: 6.7px 10.05px;
            border: none;
            border-radius: 2.68px;
            cursor: pointer;
            margin-top: 6.7px;
            transition: background-color 0.3s, transform 0.2s;
        }

        #savePatternButton:hover {
            background-color: #8e44ad;
            transform: translateY(-1.34px);
        }

        #savePatternModal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0,0,0,0.4);
            animation: fadeIn 0.3s;
        }

        #savePatternModal .modal-content {
            background-color: var(--card-background);
            margin: 15% auto;
            padding: 13.4px;
            border: 0.67px solid var(--border-color);
            border-radius: 6.7px;
            width: 50%;
            max-width: 335px;
            animation: slideDown 0.3s ease-out;
        }

        #savePatternModal input[type="text"] {
            width: 100%;
            padding: 6.7px;
            margin: 6.7px 0;
            border: 0.67px solid var(--border-color);
            border-radius: 2.68px;
        }

        #savePatternModal button {
            margin-top: 6.7px;
        }

        /* Save Pattern Modal - Type Selection Styles */
        .save-type-subtitle {
            color: var(--text-secondary, #888);
            margin-bottom: 16px;
            font-size: 0.9em;
        }

        .save-type-options {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-bottom: 16px;
        }

        .save-type-btn {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            padding: 16px;
            background: var(--card-background);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            text-align: left;
        }

        .save-type-btn:hover {
            border-color: var(--accent-color, #9b59b6);
            background: rgba(155, 89, 182, 0.1);
            transform: translateY(-2px);
        }

        .save-type-btn i {
            font-size: 24px;
            color: var(--accent-color, #9b59b6);
            margin-bottom: 8px;
        }

        .save-type-title {
            font-weight: 600;
            font-size: 14px;
            color: var(--text-primary, #fff);
            margin-bottom: 4px;
        }

        .save-type-desc {
            font-size: 12px;
            color: var(--text-secondary, #888);
        }

        #savePatternModal .cancel-btn {
            background: transparent;
            border: 1px solid var(--border-color);
            color: var(--text-secondary, #888);
            padding: 8px 16px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s ease;
            width: 100%;
        }

        #savePatternModal .cancel-btn:hover {
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-primary, #fff);
        }

        .modal-buttons {
            display: flex;
            gap: 8px;
            margin-top: 12px;
        }

        .modal-buttons button {
            flex: 1;
            padding: 10px 16px;
            border-radius: 4px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.2s ease;
        }

        #saveCustomPatternButton,
        #saveStrategyButton {
            background: var(--accent-color, #9b59b6);
            border: none;
            color: white;
        }

        #saveCustomPatternButton:hover,
        #saveStrategyButton:hover {
            filter: brightness(1.1);
        }


            .pattern-actions {
        display: flex;
        justify-content: space-between;
        margin-top: 6.7px;
    }

    .update-pattern, .delete-pattern {
        padding: 3.35px 6.7px;
        font-size: 8.04px;
        cursor: pointer;
    }

    .update-pattern {
        background-color: #3498db;
        color: white;
        border: none;
        border-radius: 2.01px;
    }

    .delete-pattern {
        background-color: #e74c3c;
        color: white;
        border: none;
        border-radius: 2.01px;
    }

    /* ============================================
       AI IMAGE IMPORT STYLES
       ============================================ */

    /* Upload Zone */
    .ai-upload-zone {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 26.8px 13.4px;
        border: 1.34px dashed #ddd;
        border-radius: 5.36px;
        background-color: #f9f9f9;
        cursor: pointer;
        transition: all 0.3s ease;
        min-height: 134px;
    }

    .ai-upload-zone:hover {
        border-color: #4CAF50;
        background-color: #f0f9f0;
    }

    .upload-icon {
        font-size: 32.16px;
        margin-bottom: 6.7px;
    }

    .ai-upload-zone p {
        margin: 6.7px 0;
        color: #666;
    }

    /* Image Preview */
    .ai-preview-container {
        margin-top: 13.4px;
    }

    .ai-preview-container h4 {
        margin-bottom: 6.7px;
        color: #333;
    }

    .ai-image-wrapper {
        border: 0.67px solid #ddd;
        border-radius: 3.35px;
        padding: 6.7px;
        background-color: #fff;
        max-height: 268px;
        overflow: auto;
    }

    /* Processing Status */
    .ai-processing {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 26.8px 13.4px;
        min-height: 134px;
    }

    .ai-spinner {
        width: 33.5px;
        height: 33.5px;
        border: 3.35px solid #f3f3f3;
        border-top: 3.35px solid #4CAF50;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-bottom: 13.4px;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }

    .ai-processing p {
        color: #666;
        text-align: center;
        max-width: 268px;
    }

    /* Results */
    .ai-results {
        margin-top: 13.4px;
    }

    .ai-results h4 {
        margin-bottom: 6.7px;
        color: #333;
    }

    #aiResultsSummary {
        margin-bottom: 10.05px;
        color: #4CAF50;
        font-weight: bold;
    }

    .ai-results-table-container {
        max-height: 201px;
        overflow-y: auto;
        border: 0.67px solid #ddd;
        border-radius: 3.35px;
        margin-bottom: 13.4px;
    }

    .ai-results-table {
        width: 100%;
        border-collapse: collapse;
        background-color: #fff;
    }

    .ai-results-table th,
    .ai-results-table td {
        padding: 6.7px;
        text-align: left;
        border-bottom: 0.67px solid #eee;
    }

    .ai-results-table th {
        background-color: #f5f5f5;
        font-weight: bold;
        position: sticky;
        top: 0;
        z-index: 1;
    }

    .ai-results-table tr:hover {
        background-color: #f9f9f9;
    }

    .candle-type {
        padding: 2.01px 5.36px;
        border-radius: 2.01px;
        font-size: 8.04px;
        font-weight: bold;
        text-transform: uppercase;
    }

    .candle-type.bullish {
        background-color: #e8f5e9;
        color: #2e7d32;
    }

    .candle-type.bearish {
        background-color: #ffebee;
        color: #c62828;
    }

    .candle-type.neutral {
        background-color: #f5f5f5;
        color: #666;
    }

    /* Actions */
    .ai-actions {
        display: flex;
        gap: 6.7px;
        justify-content: center;
        margin-top: 13.4px;
    }

    .action-button.primary {
        background-color: #4CAF50;
        color: white;
        font-weight: bold;
    }

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

    /* Responsive */
    @media (max-width: 514.56px) {
        .ai-upload-zone {
            padding: 20.1px 10.05px;
            min-height: 100.5px;
        }

        .upload-icon {
            font-size: 24.12px;
        }

        .ai-results-table-container {
            max-height: 134px;
        }

        .ai-actions {
            flex-direction: column;
        }

        .ai-actions button {
            width: 100%;
        }
    }


/* ============================================
   UNDO/REDO AND HISTORY STYLES
   ============================================ */

/* Undo/Redo Buttons */
#undoButton, #redoButton {
    min-width: 53.6px;
    padding: 5.36px 10.05px;
}

#undoButton:disabled, #redoButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* AI History List */
.ai-history-list {
    max-height: 201px;
    overflow-y: auto;
    border: 0.67px solid #ddd;
    border-radius: 3.35px;
    padding: 6.7px;
}

.ai-history-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6.7px;
    margin-bottom: 5.36px;
    background-color: #f9f9f9;
    border: 0.67px solid #e0e0e0;
    border-radius: 3.35px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-history-entry:hover {
    background-color: #e8f5e9;
    border-color: #4CAF50;
    transform: translateX(1.34px);
}

.ai-history-info {
    display: flex;
    flex-direction: column;
    gap: 2.68px;
}

.ai-history-time {
    font-size: 8.04px;
    color: #666;
}

.ai-history-model {
    font-size: 7.37px;
    color: #999;
    font-style: italic;
}

.ai-history-restore {
    padding: 3.35px 8.04px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 2.68px;
    cursor: pointer;
    font-size: 8.71px;
}

.ai-history-restore:hover {
    background-color: #45a049;
}

/* Dark Mode Support for Dynamic Elements */

/* OHLC Display */
#ohlcDisplay {
    background: var(--card-background) !important;
    border: 0.67px solid var(--border-color) !important;
    box-shadow: 0 1.34px 8.04px var(--shadow-color) !important;
}

#ohlcDisplay span {
    color: var(--text-color) !important;
}

#ohlcDisplay input {
    background: var(--background-color) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode #ohlcDisplay input:focus {
    border-color: var(--primary-color) !important;
}

/* Chart Toolbar */
#chartToolbar {
    background: var(--card-background) !important;
    box-shadow: 0 2.68px 13.4px var(--shadow-color), 0 0 0 0.67px var(--border-color) !important;
}

/* Candlestick Counter */
#candlestickCounter {
    background: var(--card-background) !important;
    color: var(--primary-color) !important;
    box-shadow: 0 1.34px 5.36px var(--shadow-color) !important;
    border: 0.67px solid var(--border-color) !important;
}

#candlestickCounter span {
    color: var(--text-color) !important;
}

/* Candlestick Options Buttons */
.candlestick-options {
    background: var(--card-background) !important;
    border: 0.67px solid var(--border-color) !important;
    box-shadow: 0 1.34px 5.36px var(--shadow-color) !important;
}

.candlestick-options button {
    background: var(--background-color) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

.candlestick-options button:hover {
    background: var(--hover-color) !important;
}


/* ==========================================================================
   Popup Dark Mode Styles (Chart Control & Feature Popups)
   ========================================================================== */

/* Chart Control Popup (Adjust Candlestick) */
html[data-theme="dark"] .chart-control-popup,
html body.dark-mode .chart-control-popup,
body[data-theme="dark"] .chart-control-popup,
body.dark-mode .chart-control-popup {
    background: #1e293b !important;
    border-color: rgba(99, 102, 241, 0.5) !important;
    box-shadow: 0 5.36px 16.08px rgba(0, 0, 0, 0.5) !important;
}

html[data-theme="dark"] .chart-control-popup-header,
html body.dark-mode .chart-control-popup-header,
body[data-theme="dark"] .chart-control-popup-header,
body.dark-mode .chart-control-popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
}

html[data-theme="dark"] .popup-control-candlestick,
html body.dark-mode .popup-control-candlestick,
body[data-theme="dark"] .popup-control-candlestick,
body.dark-mode .popup-control-candlestick {
    background: #0f172a !important;
    border: 0.67px solid rgba(51, 65, 85, 0.5) !important;
}

/* Candlestick Feature Popup */
html[data-theme="dark"] .candlestick-feature-popup,
html body.dark-mode .candlestick-feature-popup,
body[data-theme="dark"] .candlestick-feature-popup,
body.dark-mode .candlestick-feature-popup {
    background: #1e293b !important;
    border-color: rgba(99, 102, 241, 0.5) !important;
    color: #e2e8f0 !important;
    box-shadow: 0 5.36px 16.75px rgba(0, 0, 0, 0.5) !important;
}

html[data-theme="dark"] .candlestick-feature-popup-header,
html body.dark-mode .candlestick-feature-popup-header,
body[data-theme="dark"] .candlestick-feature-popup-header,
body.dark-mode .candlestick-feature-popup-header {
    border-bottom-color: rgba(51, 65, 85, 0.5) !important;
}

html[data-theme="dark"] .candlestick-feature-popup-title,
html body.dark-mode .candlestick-feature-popup-title,
body[data-theme="dark"] .candlestick-feature-popup-title,
body.dark-mode .candlestick-feature-popup-title {
    color: #818cf8 !important;
}

html[data-theme="dark"] .candlestick-feature-popup-close,
html body.dark-mode .candlestick-feature-popup-close,
body[data-theme="dark"] .candlestick-feature-popup-close,
body.dark-mode .candlestick-feature-popup-close {
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .candlestick-feature-popup-close:hover,
html body.dark-mode .candlestick-feature-popup-close:hover,
body[data-theme="dark"] .candlestick-feature-popup-close:hover,
body.dark-mode .candlestick-feature-popup-close:hover {
    background-color: rgba(51, 65, 85, 0.5) !important;
}

html[data-theme="dark"] .candlestick-feature-list,
html body.dark-mode .candlestick-feature-list,
body[data-theme="dark"] .candlestick-feature-list,
body.dark-mode .candlestick-feature-list {
    background-color: transparent !important;
}

html[data-theme="dark"] .candlestick-feature-item,
html body.dark-mode .candlestick-feature-item,
body[data-theme="dark"] .candlestick-feature-item,
body.dark-mode .candlestick-feature-item {
    background-color: rgba(30, 41, 59, 0.5) !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .candlestick-feature-item:hover,
html body.dark-mode .candlestick-feature-item:hover,
body[data-theme="dark"] .candlestick-feature-item:hover,
body.dark-mode .candlestick-feature-item:hover {
    background-color: rgba(99, 102, 241, 0.2) !important;
    border-color: #818cf8 !important;
}

html[data-theme="dark"] .candlestick-feature-item.selected,
html body.dark-mode .candlestick-feature-item.selected,
body[data-theme="dark"] .candlestick-feature-item.selected,
body.dark-mode .candlestick-feature-item.selected {
    background-color: rgba(99, 102, 241, 0.3) !important;
    border-color: #818cf8 !important;
}

html[data-theme="dark"] #featureSearchInput,
html body.dark-mode #featureSearchInput,
body[data-theme="dark"] #featureSearchInput,
body.dark-mode #featureSearchInput {
    background: #0f172a !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] #featureSearchInput::placeholder,
html body.dark-mode #featureSearchInput::placeholder,
body[data-theme="dark"] #featureSearchInput::placeholder,
body.dark-mode #featureSearchInput::placeholder {
    color: #64748b !important;
}

html[data-theme="dark"] .candlestick-feature-list h4,
html body.dark-mode .candlestick-feature-list h4,
body[data-theme="dark"] .candlestick-feature-list h4,
body.dark-mode .candlestick-feature-list h4 {
    color: #cbd5e1 !important;
    border-bottom-color: rgba(51, 65, 85, 0.5) !important;
}

html[data-theme="dark"] .candlestick-feature-popup div[style*="border-bottom"],
html body.dark-mode .candlestick-feature-popup div[style*="border-bottom"],
body[data-theme="dark"] .candlestick-feature-popup div[style*="border-bottom"],
body.dark-mode .candlestick-feature-popup div[style*="border-bottom"] {
    border-bottom-color: rgba(51, 65, 85, 0.5) !important;
}

/* Value Display (OHLC inputs) */
html[data-theme="dark"] #valueDisplay,
html body.dark-mode #valueDisplay,
body[data-theme="dark"] #valueDisplay,
body.dark-mode #valueDisplay {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .value-input label,
html body.dark-mode .value-input label,
body[data-theme="dark"] .value-input label,
body.dark-mode .value-input label {
    color: #cbd5e1 !important;
}

html[data-theme="dark"] .value-input input,
html body.dark-mode .value-input input,
body[data-theme="dark"] .value-input input,
body.dark-mode .value-input input {
    background-color: #0f172a !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
    color: #e2e8f0 !important;
}

html[data-theme="dark"] .value-input input:focus,
html body.dark-mode .value-input input:focus,
body[data-theme="dark"] .value-input input:focus,
body.dark-mode .value-input input:focus {
    border-color: #818cf8 !important;
    box-shadow: 0 0 0 2.01px rgba(129, 140, 248, 0.2) !important;
}

/* ==========================================================================
   AI Image Analysis Dark Mode
   ========================================================================== */

/* Base styles for light mode */
.ai-disclaimer {
    margin-top: 10.05px;
    padding: 8.04px 10.72px;
    background-color: #fff3cd;
    border: 0.67px solid #ffc107;
    border-left: 2.68px solid #ffc107;
    border-radius: 4.02px;
    color: #856404;
    font-size: 8.71px;
    line-height: 1.5;
}

.ai-disclaimer strong {
    font-weight: 600;
}

.ai-description {
    color: #666;
}

.ai-history-empty {
    color: #999;
}

/* Dark mode styles */
[data-theme="dark"] .ai-upload-zone,
body.dark-mode .ai-upload-zone {
    background-color: #1e293b !important;
    border-color: rgba(99, 102, 241, 0.3) !important;
}

[data-theme="dark"] .ai-upload-zone:hover,
body.dark-mode .ai-upload-zone:hover {
    border-color: #667eea !important;
    background-color: rgba(99, 102, 241, 0.1) !important;
}

[data-theme="dark"] .ai-upload-zone p,
body.dark-mode .ai-upload-zone p {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-preview-container h4,
body.dark-mode .ai-preview-container h4 {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .ai-image-wrapper,
body.dark-mode .ai-image-wrapper {
    background-color: #1e293b !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

[data-theme="dark"] .ai-processing,
body.dark-mode .ai-processing {
    background-color: #1e293b !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

[data-theme="dark"] .ai-processing p,
body.dark-mode .ai-processing p {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-results,
[data-theme="dark"] .ai-results-container,
body.dark-mode .ai-results,
body.dark-mode .ai-results-container {
    background-color: transparent !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

[data-theme="dark"] .ai-results h4,
[data-theme="dark"] .ai-results-container h4,
body.dark-mode .ai-results h4,
body.dark-mode .ai-results-container h4 {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .ai-results p,
body.dark-mode .ai-results p {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-results-summary,
body.dark-mode .ai-results-summary {
    background-color: rgba(99, 102, 241, 0.1) !important;
    border-color: rgba(99, 102, 241, 0.3) !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .ai-results-table-container,
body.dark-mode .ai-results-table-container {
    background-color: #0f172a !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

[data-theme="dark"] .ai-results-table,
body.dark-mode .ai-results-table {
    color: #e2e8f0 !important;
}

[data-theme="dark"] .ai-results-table th,
body.dark-mode .ai-results-table th {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

[data-theme="dark"] .ai-results-table td,
body.dark-mode .ai-results-table td {
    border-color: rgba(51, 65, 85, 0.3) !important;
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-results-table tr:hover,
body.dark-mode .ai-results-table tr:hover {
    background-color: rgba(99, 102, 241, 0.05) !important;
}

[data-theme="dark"] .candle-type,
body.dark-mode .candle-type {
    font-weight: bold;
}

[data-theme="dark"] .candle-type.bullish,
body.dark-mode .candle-type.bullish {
    background-color: rgba(34, 197, 94, 0.2) !important;
    color: #34d399 !important;
}

[data-theme="dark"] .candle-type.bearish,
body.dark-mode .candle-type.bearish {
    background-color: rgba(239, 68, 68, 0.2) !important;
    color: #f87171 !important;
}

[data-theme="dark"] .candle-type.neutral,
body.dark-mode .candle-type.neutral {
    background-color: rgba(148, 163, 184, 0.2) !important;
    color: #94a3b8 !important;
}

[data-theme="dark"] .ai-actions,
body.dark-mode .ai-actions {
    background-color: transparent !important;
}

[data-theme="dark"] .ai-history-section,
body.dark-mode .ai-history-section {
    background-color: transparent !important;
}

[data-theme="dark"] .ai-history-section h4,
body.dark-mode .ai-history-section h4 {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .ai-history-list,
body.dark-mode .ai-history-list {
    background-color: #0f172a !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

[data-theme="dark"] .ai-history-list p,
body.dark-mode .ai-history-list p {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-history-entry,
body.dark-mode .ai-history-entry {
    background-color: #1e293b !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .ai-history-entry:hover,
body.dark-mode .ai-history-entry:hover {
    background-color: rgba(99, 102, 241, 0.1) !important;
    border-color: #667eea !important;
}

[data-theme="dark"] .ai-history-time,
body.dark-mode .ai-history-time {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-history-model,
body.dark-mode .ai-history-model {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-history-count,
body.dark-mode .ai-history-count {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .action-button,
body.dark-mode .action-button {
    background-color: #667eea !important;
    color: white !important;
}

[data-theme="dark"] .action-button:hover,
body.dark-mode .action-button:hover {
    background-color: #818cf8 !important;
    color: white !important;
}

[data-theme="dark"] .action-button.primary,
body.dark-mode .action-button.primary {
    background-color: #34d399 !important;
    color: white !important;
}

[data-theme="dark"] .action-button.primary:hover,
body.dark-mode .action-button.primary:hover {
    background-color: #10b981 !important;
    color: white !important;
}

[data-theme="dark"] .ai-history-restore,
body.dark-mode .ai-history-restore {
    background-color: #34d399 !important;
    color: white !important;
}

[data-theme="dark"] .ai-history-restore:hover,
body.dark-mode .ai-history-restore:hover {
    background-color: #10b981 !important;
    color: white !important;
}

[data-theme="dark"] .ai-disclaimer,
body.dark-mode .ai-disclaimer {
    background-color: rgba(251, 191, 36, 0.1) !important;
    border-color: rgba(251, 191, 36, 0.4) !important;
    color: #fbbf24 !important;
}

[data-theme="dark"] .ai-disclaimer strong,
body.dark-mode .ai-disclaimer strong {
    color: #fbbf24 !important;
}

[data-theme="dark"] #AIImageImport,
body.dark-mode #AIImageImport {
    background-color: transparent !important;
    color: #cbd5e1 !important;
}

[data-theme="dark"] #AIImageImport h3,
body.dark-mode #AIImageImport h3 {
    color: #f1f5f9 !important;
}

[data-theme="dark"] #AIImageImport p,
body.dark-mode #AIImageImport p {
    color: #cbd5e1 !important;
}

[data-theme="dark"] #AIImageImport h4,
body.dark-mode #AIImageImport h4 {
    color: #f1f5f9 !important;
}

[data-theme="dark"] .ai-description,
body.dark-mode .ai-description {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-history-empty,
body.dark-mode .ai-history-empty {
    color: #cbd5e1 !important;
}

[data-theme="dark"] .ai-preview-container,
body.dark-mode .ai-preview-container {
    background-color: transparent !important;
}

[data-theme="dark"] .ai-results-container,
body.dark-mode .ai-results-container {
    background-color: transparent !important;
}

[data-theme="dark"] .ai-history-section,
body.dark-mode .ai-history-section {
    background-color: transparent !important;
}

[data-theme="dark"] #AIImageImport .ai-upload-zone,
body.dark-mode #AIImageImport .ai-upload-zone {
    background-color: #1e293b !important;
    border-color: rgba(99, 102, 241, 0.3) !important;
    color: #cbd5e1 !important;
}

[data-theme="dark"] #AIImageImport .ai-history-list,
body.dark-mode #AIImageImport .ai-history-list {
    background-color: #0f172a !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

/* ==========================================================================
   Detection Results - Dark Mode & Font Improvements
   ========================================================================== */

/* Base styles for better readability */
#aiResultsSummary {
    font-size: 10.05px;
    font-family: var(--font-sans);
    line-height: 1.6;
    margin: 6.7px 0;
    padding: 8.04px 10.72px;
    background-color: #f0f4f8;
    border-left: 2.68px solid #667eea;
    border-radius: 4.02px;
}

.ai-results h4 {
    font-size: 12.06px;
    font-weight: 600;
    margin-bottom: 8.04px;
}

/* Dark mode */
[data-theme="dark"] #aiResultsSummary,
html body.dark-mode #aiResultsSummary,
body[data-theme="dark"] #aiResultsSummary,
body.dark-mode #aiResultsSummary {
    background-color: rgba(99, 102, 241, 0.15) !important;
    border-left-color: #818cf8 !important;
    color: #f1f5f9 !important;
    font-size: 10.05px !important;
    font-family: var(--font-sans) !important;
    line-height: 1.6 !important;
}

[data-theme="dark"] .ai-results h4,
html body.dark-mode .ai-results h4,
body[data-theme="dark"] .ai-results h4,
body.dark-mode .ai-results h4 {
    color: #f1f5f9 !important;
    font-weight: 600 !important;
    font-size: 12.06px !important;
}

/* ==========================================================================
   AI Results Table - Complete Dark Mode Fix
   ========================================================================== */

/* Light mode base styles */
.ai-results-table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

.ai-results-table th {
    padding: 8.04px;
    text-align: left;
    background-color: #f0f4f8;
    font-weight: 600;
    border-bottom: 1.34px solid #e2e8f0;
}

.ai-results-table td {
    padding: 6.7px 8.04px;
    border-bottom: 0.67px solid #e2e8f0;
    color: #4a5568;
}

.ai-results-table tr {
    background-color: white;
}

.ai-results-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

/* Dark mode - complete override */
[data-theme="dark"] .ai-results-table,
html body.dark-mode .ai-results-table,
body[data-theme="dark"] .ai-results-table,
body.dark-mode .ai-results-table {
    background-color: #0f172a !important;
    color: #e2e8f0 !important;
}

[data-theme="dark"] .ai-results-table tr,
html body.dark-mode .ai-results-table tr,
body[data-theme="dark"] .ai-results-table tr,
body.dark-mode .ai-results-table tr {
    background-color: #1e293b !important;
}

[data-theme="dark"] .ai-results-table tbody tr:nth-child(even),
html body.dark-mode .ai-results-table tbody tr:nth-child(even),
body[data-theme="dark"] .ai-results-table tbody tr:nth-child(even),
body.dark-mode .ai-results-table tbody tr:nth-child(even) {
    background-color: #0f172a !important;
}

[data-theme="dark"] .ai-results-table tbody tr:nth-child(odd),
html body.dark-mode .ai-results-table tbody tr:nth-child(odd),
body[data-theme="dark"] .ai-results-table tbody tr:nth-child(odd),
body.dark-mode .ai-results-table tbody tr:nth-child(odd) {
    background-color: #1e293b !important;
}

[data-theme="dark"] .ai-results-table th,
html body.dark-mode .ai-results-table th,
body[data-theme="dark"] .ai-results-table th,
body.dark-mode .ai-results-table th {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border-bottom-color: rgba(51, 65, 85, 0.5) !important;
    font-size: 9.38px !important;
    font-weight: 600 !important;
}

[data-theme="dark"] .ai-results-table td,
html body.dark-mode .ai-results-table td,
body[data-theme="dark"] .ai-results-table td,
body.dark-mode .ai-results-table td {
    border-bottom-color: rgba(51, 65, 85, 0.3) !important;
    color: #cbd5e1 !important;
    background-color: transparent !important;
    font-size: 9.38px !important;
}

[data-theme="dark"] .ai-results-table tr:hover,
html body.dark-mode .ai-results-table tr:hover,
body[data-theme="dark"] .ai-results-table tr:hover,
body.dark-mode .ai-results-table tr:hover {
    background-color: rgba(99, 102, 241, 0.1) !important;
}

/* Fix for the summary box */
[data-theme="dark"] #aiResultsSummary strong,
html body.dark-mode #aiResultsSummary strong,
body[data-theme="dark"] #aiResultsSummary strong,
body.dark-mode #aiResultsSummary strong {
    color: #f1f5f9 !important;
}

/* Make the "using Computer Vision" text more subtle */
#aiResultsSummary em,
#aiResultsSummary i {
    opacity: 0.8;
    font-size: 8.71px;
}
