/* ============================================
   Modbus RTU Master Emulator - Stylesheet
   ============================================ */

/* CSS Variables - Light Mode (Default) */
:root {
    --primary-color: #2196F3;
    --primary-hover: #1976D2;
    --success-color: #4CAF50;
    --success-hover: #388E3C;
    --warning-color: #FF9800;
    --warning-hover: #F57C00;
    --error-color: #F44336;
    --error-hover: #D32F2F;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-tertiary: #EEEEEE;
    --bg-sidebar: #263238;
    --bg-sidebar-hover: #37474F;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-light: #FFFFFF;
    --text-sidebar: #ECEFF1;
    --border-color: #E0E0E0;
    --border-focus: #2196F3;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.19);
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --border-radius: 4px;
    --sidebar-width: 280px;
    --toolbar-height: 56px;
    --statusbar-height: 28px;
    --value-editor-height: 200px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #1E1E1E;
    --bg-secondary: #252526;
    --bg-tertiary: #333333;
    --bg-sidebar: #1A1A1A;
    --bg-sidebar-hover: #2D2D2D;
    --text-primary: #E0E0E0;
    --text-secondary: #A0A0A0;
    --text-sidebar: #CCCCCC;
    --border-color: #404040;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
}

/* Browser Warning Banner */
.browser-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--warning-color);
    color: #000;
    font-weight: 500;
}

.browser-warning__close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.7;
}

.browser-warning__close:hover {
    opacity: 1;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 1024px;
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--toolbar-height);
    padding: 0 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.toolbar__left,
.toolbar__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar__divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 8px;
}

.toolbar__label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.toolbar__select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.toolbar__select:hover {
    border-color: var(--primary-color);
}

.toolbar__select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    font-weight: 500;
    font-size: 13px;
}

.connection-status__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.connection-status--disconnected {
    background: rgba(244, 67, 54, 0.15);
    color: var(--error-color);
    animation: attention-bg 1.5s ease-in-out infinite;
}

.connection-status--disconnected .connection-status__dot {
    background: var(--error-color);
    animation: blink 1s ease-in-out infinite;
}

.connection-status--connected {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.connection-status--connected .connection-status__dot {
    background: var(--success-color);
    animation: pulse 2s infinite;
}

/* Polling status indicator */
.polling-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--border-radius);
    font-size: 12px;
    font-weight: 500;
}

.polling-status--inactive {
    background: rgba(255, 152, 0, 0.15);
    color: var(--warning-color);
    animation: attention-bg-warning 1.5s ease-in-out infinite;
}

.polling-status--inactive .polling-status__dot {
    animation: blink 1s ease-in-out infinite;
}

.polling-status--active {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success-color);
}

.polling-status__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.polling-status--active .polling-status__dot {
    animation: pulse 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes attention-bg {
    0%, 100% { background: rgba(244, 67, 54, 0.1); }
    50% { background: rgba(244, 67, 54, 0.25); }
}

@keyframes attention-bg-warning {
    0%, 100% { background: rgba(255, 152, 0, 0.1); }
    50% { background: rgba(255, 152, 0, 0.25); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn__icon {
    font-size: 14px;
}

.btn--primary {
    background: var(--primary-color);
    color: var(--text-light);
}

.btn--primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn--secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn--secondary:hover:not(:disabled) {
    background: var(--border-color);
}

.btn--success {
    background: var(--success-color);
    color: var(--text-light);
}

.btn--success:hover:not(:disabled) {
    background: var(--success-hover);
}

.btn--danger {
    background: var(--error-color);
    color: var(--text-light);
}

.btn--danger:hover:not(:disabled) {
    background: var(--error-hover);
}

.btn--icon {
    padding: 8px;
    background: transparent;
}

.btn--icon:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.btn--small {
    padding: 4px 10px;
    font-size: 12px;
}

.btn--block {
    width: 100%;
    justify-content: center;
}

/* ============================================
   Main Content Layout
   ============================================ */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    position: relative;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    min-width: 200px;
    max-width: 500px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
}

.sidebar__header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar__title {
    font-size: 16px;
    font-weight: 600;
}

.sidebar__content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar__footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar__resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    cursor: ew-resize;
    transition: background var(--transition-fast);
}

.sidebar__resizer:hover,
.sidebar__resizer.active {
    background: var(--primary-color);
}

/* Device Tree */
.device-tree {
    font-size: 13px;
}

.device-tree__empty {
    padding: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
}

.device-tree__empty p {
    margin: 4px 0;
}

.tree-item {
    user-select: none;
}

.tree-item__header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.tree-item__header:hover {
    background: var(--bg-sidebar-hover);
}

.tree-item__header.selected {
    background: var(--primary-color);
}

.tree-item__toggle {
    width: 16px;
    font-size: 10px;
    text-align: center;
    transition: transform var(--transition-fast);
}

.tree-item__toggle.expanded {
    transform: rotate(90deg);
}

.tree-item__icon {
    font-size: 14px;
}

.tree-item__status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: auto;
}

.tree-item__status--connected {
    background: var(--success-color);
}

.tree-item__status--disconnected {
    background: var(--text-secondary);
}

.tree-item__status--polling {
    background: var(--primary-color);
    animation: pulse 1s infinite;
}

.tree-item__children {
    padding-left: 20px;
}

.tree-item__children.collapsed {
    display: none;
}

/* ============================================
   Main Panel
   ============================================ */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.action-bar__left,
.action-bar__right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Function Tabs */
.function-tabs {
    display: flex;
    gap: 4px;
}

.function-tab {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.function-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.function-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--text-light);
}

.function-tab--test {
    background: var(--success-color);
    border-color: var(--success-color);
    color: var(--text-light);
}

.function-tab--test:hover {
    background: var(--success-hover);
}

/* ============================================
   Register Table (Multi-Column Layout)
   ============================================ */
.register-table-container {
    flex: 1;
    overflow: auto;
    padding: 16px;
}

.register-table__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
}

.register-table__empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.register-table__empty h3 {
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Multi-column container */
.register-columns {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: flex-start;
}

/* Register Section (grouped by type) */
.register-section {
    width: 100%;
}

.register-section__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    font-size: 13px;
}

.register-section__type {
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Consolas', 'Monaco', monospace;
}

.register-section__name {
    color: var(--text-secondary);
}

.register-section__count {
    color: var(--text-tertiary);
    font-size: 12px;
}

.register-section__columns {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
}

.register-column {
    flex: 0 0 auto;
    min-width: 240px;
}

/* Hide comments by default */
.register-columns.hide-comments .register-table__cell--comment,
.register-columns.hide-comments .register-table__th--comment {
    display: none;
}

.register-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.register-table__th {
    padding: 8px 10px;
    text-align: left;
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.register-table__th--address { width: 55px; }
.register-table__th--alias { width: 70px; }
.register-table__th--value { width: 60px; }
.register-table__th--comment { min-width: 80px; }

.register-table__row {
    transition: background var(--transition-fast);
}

.register-table__row:hover {
    background: var(--bg-secondary);
}

.register-table__row.selected {
    background: rgba(33, 150, 243, 0.1);
}

.register-table__row--readonly {
    background: var(--bg-tertiary);
}

.register-table__row--modified {
    background: rgba(255, 152, 0, 0.15);
}

.register-table__row--success {
    animation: successFlash 1s ease;
}

.register-table__row--error {
    border: 2px solid var(--error-color);
}

@keyframes successFlash {
    0% { background: rgba(76, 175, 80, 0.3); }
    100% { background: transparent; }
}

.register-table__cell {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    white-space: nowrap;
}

.register-table__cell--type {
    font-weight: 500;
    color: var(--text-secondary);
}

.register-table__cell--address {
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--primary-color);
}

.register-table__cell--value {
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 500;
}

.register-table__cell--value.editable {
    cursor: pointer;
}

.register-table__cell--value.editable:hover {
    background: rgba(33, 150, 243, 0.1);
}

.register-table__cell--comment {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.register-table__input {
    width: 100%;
    padding: 4px 8px;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    outline: none;
}

/* ============================================
   Value Editor Panel
   ============================================ */
.value-editor {
    height: var(--value-editor-height);
    min-height: 40px;
    max-height: 60vh;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
}

.value-editor__resize {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    cursor: ns-resize;
    background: transparent;
    z-index: 10;
}

.value-editor__resize:hover {
    background: var(--primary-color);
    opacity: 0.5;
}

.value-editor.collapsed {
    height: 40px !important;
}

.value-editor.collapsed .value-editor__content {
    display: none;
}

.value-editor.collapsed .value-editor__resize {
    display: none;
}

.value-editor__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.value-editor__tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.value-editor__tab {
    padding: 6px 12px;
    border: none;
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.value-editor__tab:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.value-editor__tab--active {
    background: var(--primary-color);
    color: var(--text-light);
}

.value-editor__toggle {
    padding: 4px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: transform var(--transition-fast);
    color: var(--text-secondary);
}

.value-editor.collapsed .value-editor__toggle {
    transform: rotate(180deg);
}

.value-editor__content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.value-editor__panel {
    display: none;
}

.value-editor__panel--active {
    display: block;
}

.value-editor__info {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 13px;
}

.value-editor__values {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 8px;
}

.value-editor__card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 10px 14px;
    min-width: 180px;
}

.value-editor__card-header {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
}

.value-editor__card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 3px 0;
}

.value-editor__card-label {
    color: var(--text-secondary);
}

.value-editor__card-value {
    font-family: 'Consolas', 'Monaco', monospace;
    color: var(--text-primary);
    font-weight: 500;
}

.value-editor__string-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    margin-top: 8px;
}

.value-editor__string-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* ============================================
   Traffic Log Panel
   ============================================ */
.traffic-log {
    position: fixed;
    bottom: var(--statusbar-height);
    right: 20px;
    width: 600px;
    max-height: 400px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 200;
}

.traffic-log__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.traffic-log__tabs {
    display: flex;
    gap: 4px;
}

.traffic-log__tab {
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.traffic-log__tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.traffic-log__tab--active {
    background: var(--primary-color);
    color: white;
}

.traffic-log__tab--active:hover {
    background: var(--primary-color);
    color: white;
}

.traffic-log__badge {
    background: var(--error-color);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.traffic-log__tab--active .traffic-log__badge {
    background: white;
    color: var(--error-color);
}

.traffic-log__title {
    font-size: 14px;
    font-weight: 600;
}

.traffic-log__actions {
    display: flex;
    gap: 8px;
}

.traffic-log__content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    max-height: 300px;
    display: none;
}

.traffic-log__content--active {
    display: block;
}

.traffic-log__empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
}

.traffic-log__entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--bg-tertiary);
}

.traffic-log__entry--tx {
    color: var(--primary-color);
}

.traffic-log__entry--rx {
    color: var(--success-color);
}

.traffic-log__entry--error {
    color: var(--error-color);
}

/* ============================================
   Status Bar
   ============================================ */
.status-bar {
    display: flex;
    align-items: center;
    height: var(--statusbar-height);
    padding: 0 16px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    font-size: 12px;
}

.status-bar__item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-bar__divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 16px;
}

/* ============================================
   Modals
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal__content {
    position: relative;
    width: 400px;
    max-width: 90%;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 200ms ease;
}

.modal__content--wide {
    width: 500px;
}

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

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal__title {
    font-size: 18px;
    font-weight: 600;
}

.modal__close {
    padding: 4px 8px;
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.modal__close:hover {
    color: var(--text-primary);
}

.modal__body {
    padding: 20px;
}

.modal__info {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

/* ============================================
   Context Menu
   ============================================ */
.context-menu {
    position: fixed;
    min-width: 180px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    z-index: 500;
    padding: 4px 0;
}

.context-menu__item {
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.context-menu__item:hover {
    background: var(--bg-secondary);
}

.context-menu__item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.context-menu__divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-primary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    margin-top: 16px;
    color: var(--text-light);
    font-size: 14px;
}

/* ============================================
   Notifications
   ============================================ */
.notification-container {
    position: fixed;
    top: 70px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 3000;
}

.notification {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    min-width: 300px;
    max-width: 450px;
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    animation: notificationSlideIn 300ms ease;
}

@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification.hiding {
    animation: notificationSlideOut 300ms ease forwards;
}

@keyframes notificationSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.notification__icon {
    font-size: 20px;
}

.notification__message {
    flex: 1;
    font-size: 13px;
}

.notification__close {
    padding: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.notification__close:hover {
    opacity: 1;
}

.notification--success {
    border-left: 4px solid var(--success-color);
}

.notification--success .notification__icon {
    color: var(--success-color);
}

.notification--error {
    border-left: 4px solid var(--error-color);
}

.notification--error .notification__icon {
    color: var(--error-color);
}

.notification--warning {
    border-left: 4px solid var(--warning-color);
}

.notification--warning .notification__icon {
    color: var(--warning-color);
}

.notification--info {
    border-left: 4px solid var(--primary-color);
}

.notification--info .notification__icon {
    color: var(--primary-color);
}

/* ============================================
   Scrollbar Styling
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Dark mode scrollbar */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #555;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

.text-success { color: var(--success-color); }
.text-error { color: var(--error-color); }
.text-warning { color: var(--warning-color); }
.text-primary { color: var(--primary-color); }

/* Focus styles for accessibility */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

