/* CSS variables for light and dark themes */
:root {
    --bg-body: #ffffff;
    --bg-card: #f5f5f5;
    --bg-nav: #ffffff;
    --text-main: #1e2329;
    --text-muted: #707a8a;
    --border-color: #eaecef;
    --theme-blue: #2962FF;
}

body.dark-mode {
    --bg-body: #0b0e14;
    --bg-card: #131924;
    --bg-nav: #0f141e;
    --text-main: #e0e4eb;
    --text-muted: #79859b;
    --border-color: #202838;
}

/* Base Styles */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow: hidden;
    overscroll-behavior-y: none;
    transition: background-color 0.3s, color 0.3s;
}

/* Floating controls on charts */
.floating-menu {
    position: absolute;
    left: 8px;
    top: 45px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    background-color: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    position: relative;
    cursor: pointer;
    transition: 0.2s ease-in-out;
    font-size: 13px;
}

.icon-btn:hover {
    color: var(--text-main);
    border-color: var(--theme-blue);
    transform: translateY(-1px);
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--theme-blue);
    color: #fff;
    font-size: 8px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 10px;
}

#chart-container a, .tv-lightweight-charts-watermark {
    display: none !important;
}

input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Modals styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10001;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    padding: 20px;
    border-radius: 20px;
    width: 92%;
    max-width: 420px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
}

#assetModal {
    display: none;
    position: fixed;
    z-index: 10005;
    inset: 0;
    background-color: var(--bg-body);
    flex-direction: column;
}

#assetModal.active {
    display: flex;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Timer Popup */
#timer-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99998;
    backdrop-filter: blur(2px);
    transition: 0.3s;
}

#timerPopup {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 320px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    z-index: 99999;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

@media (min-width: 768px) { 
    #timerPopup {
        position: absolute;
        left: auto;
        right: 0;
        bottom: 60px;
        transform: none;
        width: 260px;
        z-index: 50;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    } 
    #timer-popup-overlay {
        display: none !important;
    }
}

.timer-btn {
    background-color: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 0;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.timer-btn:hover {
    border-color: var(--theme-blue);
}

.timer-btn.active {
    background: var(--theme-blue);
    color: #fff;
    border-color: var(--theme-blue);
    box-shadow: 0 4px 10px rgba(41, 98, 255, 0.2);
}

/* Active Trades Panel Mobile Drawer */
#tradesPanel {
    display: none;
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    z-index: 45;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
    max-height: 60vh;
    flex-direction: column;
}

#tradesPanel.active {
    display: flex;
}

.trade-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 44;
}

.trade-panel-overlay.active {
    display: block;
}

.sentiment-bar-container {
    width: 100%;
    padding: 0 5px;
    margin-top: 8px;
    margin-bottom: -5px;
}

/* Background image overlay for charts */
#chart-bg-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}

#chart-bg-layer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(11, 14, 20, 0.85); /* fallback dark overlay */
}

body:not(.dark-mode) #chart-bg-layer::after {
    background: rgba(255, 255, 255, 0.85); /* fallback light overlay */
}

#chart {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
}

/* Clock / Timezone styles */
#scale-timer { 
    position: absolute;
    display: none;
    align-items: center;
    justify-content: center; 
    height: 18px;
    padding: 0 7px;
    color: #eaecef;
    font-size: 9.5px;
    font-weight: 700; 
    z-index: 100;
    border-radius: 10px;
    pointer-events: none;
    background-color: #2b3139;
    border: 1px solid #4a505e;
    letter-spacing: 0.5px;
}

/* Toast Messages */
#toast-container {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.qx-toast {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
    min-width: 240px;
    max-width: 300px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.qx-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.qx-toast-success {
    background-color: #0ecb81;
}

.qx-toast-error {
    background-color: #f6465d;
}

.qx-toast-info {
    background-color: var(--theme-blue);
}

.qx-toast-icon {
    margin-right: 10px;
    font-size: 16px;
}

.qx-toast-content {
    display: flex;
    flex-direction: column;
}

.qx-toast-title {
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 2px;
}

.qx-toast-msg {
    font-size: 10px;
    opacity: 0.9;
    font-weight: 500;
}

/* Footer & Tabs */
.footer___pP3SZ {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-nav);
    border-top: 1px solid var(--border-color);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.adm-tab-bar-wrap {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
}

.adm-tab-bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.3s;
}

.adm-tab-bar-item:hover {
    color: var(--theme-blue);
}

.adm-tab-bar-item-active {
    color: var(--theme-blue);
}

.adm-tab-bar-item-icon svg {
    fill: currentColor;
    transition: fill 0.3s;
}

.adm-tab-bar-item-title {
    font-size: 10px;
    font-weight: 700;
    margin-top: 4px;
}

/* Trading View result popup animation */
@keyframes qxPopup {
    0% { transform: scale(0.6) translateY(20px); opacity: 0; }
    10% { transform: scale(1) translateY(0); opacity: 1; }
    90% { transform: scale(1) translateY(0); opacity: 1; }
    100% { transform: scale(0.6) translateY(-20px); opacity: 0; }
}

.animate-qx-popup {
    animation: qxPopup 4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Interactive indicators overlay */
.indicator-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: bold;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    margin-right: 4px;
}

/* Desktop tab styles */
.desktop-tab {
    position: relative;
    border-top-width: 3px;
    transition: all 0.2s ease;
}

.desktop-tab.active {
    border-top-color: var(--theme-blue);
    background-color: var(--bg-body);
}

/* Vertical Sentiment Bar */
#sentiment-green-vert, #sentiment-red-vert {
    transition: height 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Tabs */
.sidebar-tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
}
.sidebar-tab-btn:hover {
    color: #fff;
    background-color: var(--border-color);
}
.sidebar-tab-btn.active {
    color: var(--theme-blue);
    border-color: var(--theme-blue);
    background-color: rgba(27, 93, 252, 0.1);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}
.animate-fade-in {
    animation: fadeIn 0.2s ease-out forwards;
}

/* Scrollbar Thin styling */
.scrollbar-thin::-webkit-scrollbar {
    width: 4px;
}
.scrollbar-thin::-webkit-scrollbar-track {
    background: transparent;
}
.scrollbar-thin::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Settings, inputs and labels custom Quotex styles */
.sidebar-input {
    width: 100%;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}
.sidebar-input:focus {
    border-color: var(--theme-blue);
}

/* ─── SHAPES ENGINE CSS ─────────────────────────────────────── */

/* Pencil Hub flyout menu */
.pencil-hub-menu {
    display: none;
    position: fixed;
    flex-direction: column;
    gap: 2px;
    background-color: rgba(21, 26, 38, 0.95) !important;
    backdrop-filter: blur(12px);
    border: 1px solid #263147 !important;
    border-radius: 10px;
    padding: 8px;
    min-width: 190px;
    z-index: 99999 !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
    font-size: 11px;
}
.pencil-hub-title {
    color: #6e7991;
    font-weight: 700;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 6px 2px;
}
.pencil-hub-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    border-radius: 7px;
    cursor: pointer;
    color: #c5cbdb;
    font-weight: 600;
    transition: background 0.15s;
}
.pencil-hub-item:hover {
    background: #1e2638;
    color: #ffffff;
}
.pencil-hub-item span {
    color: #6e7991;
    font-size: 13px;
}

/* Pencil Hub status badge */
.pencil-status-badge {
    font-size: 9px;
    font-weight: 700;
    color: #6e7991;
    background: #1e2638;
    border-radius: 4px;
    padding: 1px 5px;
    min-width: 24px;
    text-align: center;
}
.pencil-status-badge.badge-on {
    color: #0ecb81;
    background: rgba(14, 203, 129, 0.12);
}

/* RSI Split Panel */
.split-rsi-panel {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100px;
    border-top: 1px solid #263147;
    background: #0d1117;
    z-index: 16;
    pointer-events: none;
}

/* Floating Context Bar (selected shape editor) */
.floating-context-bar {
    display: none;
    position: fixed;
    align-items: center;
    gap: 8px;
    background-color: rgba(21, 26, 38, 0.95) !important;
    backdrop-filter: blur(12px);
    border: 1px solid #263147 !important;
    border-radius: 8px;
    padding: 6px 12px;
    z-index: 99998 !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
    font-size: 11px;
}
.floating-context-bar input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
    padding: 0;
}
.floating-context-bar input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.floating-context-bar input[type="color"]::-webkit-color-swatch {
    border: 1px solid #263147;
    border-radius: 50%;
}

.floating-context-bar select,
#shapesContextBar select {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-color: #1e2638 !important;
    background: #1e2638 !important;
    color: #c5cbdb !important;
    border: 1px solid #263147 !important;
    border-radius: 6px !important;
    padding: 4px 20px 4px 8px !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    outline: none !important;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%23c5cbdb' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 8px !important;
}

.floating-context-bar button {
    background: #1e2638 !important;
    border: 1px solid #263147 !important;
    border-radius: 6px;
    color: #c5cbdb !important;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px !important;
    cursor: pointer;
    outline: none;
    transition: all 0.15s ease;
}
.floating-context-bar button:hover {
    background: #263147 !important;
    color: #fff !important;
}

#shape-ctx-delete {
    background: rgba(246, 70, 93, 0.1) !important;
    border: 1px solid rgba(246, 70, 93, 0.2) !important;
    color: #f6465d !important;
}
#shape-ctx-delete:hover {
    background: rgba(246, 70, 93, 0.2) !important;
    color: #ff6074 !important;
}

/* Mobile Overrides for Floating Context Bar positioning */
@media (max-width: 767px) {
    .floating-context-bar,
    #shapesContextBar {
        position: fixed !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        top: auto !important;
        bottom: 80px !important;
        z-index: 999999 !important;
    }
}
