/**
 * Right Toolbar Styles - TradingView Model
 * Watchlist + Buttons در یک container واحد در سمت راست صفحه
 * Chart عرضش تغییر می‌کند تا فضا را آزاد کند
 */

/* Container کلی - همیشه در سمت راست */
.right-toolbar-container {
    position: fixed;
    right: 0;
    top: 42px;
    height: calc(100vh - 42px);
    display: flex;
    z-index: 100;
    transition: width 0.15s ease;
}

/* Collapsed state - فقط دکمه‌ها */
.right-toolbar-container.collapsed {
    width: 45px;
}

/* Expanded state - واچ‌لیست + دکمه‌ها */
.right-toolbar-container.expanded {
    width: 460px; /* 415px watchlist + 45px buttons */
}

/* Watchlist Panel - سمت چپ container */
#right-toolbar-panel {
    width: 415px;
    height: 100%;
    background: #ffffff;
    border-left: 1px solid #e0e3eb;
    display: none; /* Hidden when collapsed */
    flex-direction: column;
    overflow: hidden;
}

/* Show watchlist when expanded */
.right-toolbar-container.expanded #right-toolbar-panel {
    display: flex;
}

/* Button bar - سمت راست container، همیشه visible */
.right-toolbar-buttons {
    width: 45px;
    height: 100%;
    background: #ffffff;
    border-left: 1px solid #e0e3eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0; /* Never shrink */
}

/* Dark mode support */
.right-toolbar-buttons.dark-mode,
#right-toolbar-panel.dark-mode {
    background: #1e222d;
    border-left-color: #2a2e39;
}

/* Scrollbar styling to match TradingView - for button bar */
.right-toolbar-buttons::-webkit-scrollbar {
    width: 6px;
}

.right-toolbar-buttons::-webkit-scrollbar-track {
    background: transparent;
}

.right-toolbar-buttons::-webkit-scrollbar-thumb {
    background: #b5b9c3;
    border-radius: 3px;
}

.right-toolbar-buttons::-webkit-scrollbar-thumb:hover {
    background: #898d9b;
}

.dark-mode .right-toolbar-buttons::-webkit-scrollbar-thumb {
    background: #434651;
}

.dark-mode .right-toolbar-buttons::-webkit-scrollbar-thumb:hover {
    background: #50535e;
}

/* Toolbar buttons content wrapper */
.right-toolbar-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    gap: 2px;
    width: 100%;
    min-height: 100%; /* Full height */
    background: #fcfeff; /* Very light blue-ish white like TradeCheck */
    border-left: 1px solid #e8eaed;
}

.dark-mode .right-toolbar-content {
    background: #1e222d;
    border-left-color: #2a2e39;
}

/* Group for bottom buttons (after separator) */
.right-toolbar-bottom-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto; /* Push to bottom */
}

/* Toolbar button base style (matching TradingView widgetbar) */
.right-toolbar-button {
    width: 36px;  /* Smaller to fit 45px toolbar */
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #131722;
    transition: all 0.15s ease;
    padding: 6px;
    margin: 0;
    position: relative;
    flex-shrink: 0;
}

.right-toolbar-button:hover {
    background: rgba(0, 0, 0, 0.06);
}

.right-toolbar-button:active {
    background: rgba(0, 0, 0, 0.1);
}

.right-toolbar-button.active {
    background: #2962ff;
    color: #ffffff;
}

.right-toolbar-button.active:hover {
    background: #1e53e5;
}

/* Dark mode button styles */
.dark-mode .right-toolbar-button {
    color: #d1d4dc;
}

.dark-mode .right-toolbar-button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.dark-mode .right-toolbar-button:active {
    background: rgba(255, 255, 255, 0.12);
}

/* Separator line (matching TradingView) */
.right-toolbar-separator {
    width: 32px;
    height: 1px;
    background: #e0e3eb;
    margin: 4px auto;
}

.dark-mode .right-toolbar-separator {
    background: #2a2e39;
}

/* Button icon styling */
.right-toolbar-button svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.2;  /* نازک‌تر برای ظریف‌تر شدن */
    pointer-events: none;
}

/* For filled icons */
.right-toolbar-button svg path[fill="currentColor"] {
    fill: currentColor;
    stroke: none;
}

/* Active button icons */
.right-toolbar-button.active svg {
    stroke: #ffffff;
    color: #ffffff;
}

.right-toolbar-button.active svg path[fill="currentColor"] {
    fill: #ffffff;
}

/* Tooltip on hover (optional) */
.right-toolbar-button[title]:hover::after {
    content: attr(title);
    position: absolute;
    right: 56px;
    top: 50%;
    transform: translateY(-50%);
    background: #131722;
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dark-mode .right-toolbar-button[title]:hover::after {
    background: #2a2e39;
    color: #d1d4dc;
}

/* Button group (for related buttons) */
.right-toolbar-button-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 4px 0;
}

/* Submenu indicator (small arrow) */
.right-toolbar-button.has-submenu::before {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid currentColor;
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
    opacity: 0.5;
}

/* Badge/counter (e.g., number of active items) */
.right-toolbar-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ff5252;
    color: #ffffff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 8px;
    line-height: 1;
    min-width: 16px;
    text-align: center;
}

/* Toggle state indicator (small dot) */
.right-toolbar-button.toggled::after {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #2962ff;
    border-radius: 50%;
}

.dark-mode .right-toolbar-button.toggled::after {
    background: #3b82f6;
}

/* Disabled state */
.right-toolbar-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Loading state (spinning animation) */
.right-toolbar-button.loading svg {
    animation: spin 1s linear infinite;
}

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

/* Hide toolbar on mobile devices */
@media (max-width: 768px) {
    #right-toolbar-container {
        display: none;
    }
}

/* Compact mode (optional - reduces width to 44px) */
#right-toolbar-container.compact {
    width: 44px;
}

#right-toolbar-container.compact .right-toolbar-button {
    width: 36px;
    height: 36px;
}

/* Expanded state (when submenu is open) */
#right-toolbar-container.expanded {
    width: auto;
    min-width: 52px;
}
