/* IntelliDungeon - Enhanced UI
   Modern dark theme with cyberpunk accents */

   :root {
    --primary: #00c3ff;
    --primary-hover: #33cfff;
    --primary-active: #0099cc;
    --secondary: #ff7b00;
    --bg-dark: #121212;
    --bg-medium: #1e1e1e;
    --bg-light: #2d2d2d;
    --bg-input: #3d3d3d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #999999;
    --border-color: #464646;
    --success: #00cc66;
    --danger: #ff3b5c;
    --warning: #ffcc00;
    --transition-speed: 0.2s;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    --radius: 6px;
  }
  
  /* Base styles */
  body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
  }
  
  /* Typography refinements */
  h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-top: 0;
    color: var(--text-primary);
  }
  
  /* Split-pane layout */
  .app-container {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
  }
  
  /* Toolbar Styling */
  .toolbar {
    grid-column: 1 / -1;
    grid-row: 1;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 100;
    box-shadow: var(--shadow);
  }
  
  .toolbar-group {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-right: 16px;
    margin-right: 16px;
    border-right: 1px solid var(--border-color);
  }
  
  .toolbar-title {
    font-weight: 600;
    font-size: 18px;
    color: var(--primary);
    margin-right: 16px;
    white-space: nowrap;
  }
  
  .file-info-display {
    margin-left: auto;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
  }
  
  #current-file-display {
    font-size: 18px;
    white-space: nowrap;
  }
  
  .toolbar button {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 38px;
  }
  
  .toolbar button:hover {
    background-color: var(--border-color);
  }
  
  .toolbar button:active {
    transform: translateY(1px);
  }
  
  .toolbar button.primary {
    background-color: var(--primary);
    color: #000;
    border-color: var(--primary);
  }
  
  .toolbar button.primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
  }
  
  .toolbar button.primary:active {
    background-color: var(--primary-active);
  }
  
  .toolbar button.danger {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
  }
  
  .toolbar select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    height: 38px;
  }
  
  .toolbar select:focus {
    outline: none;
    border-color: var(--primary);
  }
  
  /* Cytoscape Graph Container */
  #cy {
    grid-column: 1;
    grid-row: 2;
    background: var(--bg-dark);
    background-image: 
      radial-gradient(rgba(70, 70, 70, 0.3) 1px, transparent 0),
      radial-gradient(rgba(70, 70, 70, 0.3) 1px, transparent 0);
    background-size: 30px 30px;
    background-position: 0 0, 15px 15px;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
  }
  
  /* Grid overlay */
  .grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
  }
  
  /* Zoom controls */
  .zoom-controls {
    position: absolute;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
  }
  
  .zoom-controls button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    box-shadow: var(--shadow);
    transition: all var(--transition-speed) ease;
  }
  
  .zoom-controls button:hover {
    background: var(--bg-input);
  }
  
  /* Node Styles (Applied through Cytoscape) */
  .node {
    background-color: var(--bg-light) !important;
    border-color: var(--border-color) !important;
  }
  
  .node.selected {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7), 0 0 0 8px rgba(0, 195, 255, 0.7) !important;
    border: 2px solid #00c3ff !important;
    animation: pulse-highlight 1.5s infinite alternate !important;
    z-index: 100 !important; /* Ensure selected node is on top */
  }
  
  .node.editing {
    box-shadow: 0 0 20px var(--primary), 0 0 40px var(--primary);
    border-color: white !important;
    border-width: 3px !important;
    animation: pulse 2s infinite;
  }
  
  @keyframes pulse {
    0% { box-shadow: 0 0 15px rgba(0, 195, 255, 0.5); }
    50% { box-shadow: 0 0 25px rgba(0, 195, 255, 0.8); }
    100% { box-shadow: 0 0 15px rgba(0, 195, 255, 0.5); }
  }
  
  /* Animation for selected node highlight */
  @keyframes pulse-highlight {
    0% {
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.5), 0 0 0 8px rgba(0, 195, 255, 0.5);
    }
    100% {
        box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.8), 0 0 0 12px rgba(0, 195, 255, 0.8);
    }
  }
  
  /* Sidebar Styling */
  #sidebar {
    grid-column: 2;
    grid-row: 1 / 3;
    background: var(--bg-light);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 0;
    box-shadow: -2px 0 10px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 320px;
    z-index: 50;
    position: fixed;
    top: 0;
    right: 0;
    transform: translateX(100%);
    transition: transform var(--transition-speed) ease-in-out;
    padding-top: 48px;
  }
  
  #sidebar.open {
    transform: translateX(0);
  }
  
  .sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg-light);
    z-index: 10;
  }
  
  .sidebar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
  }
  
  .sidebar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .sidebar-close:hover {
    color: var(--text-primary);
  }
  
  .sidebar-content {
    overflow-y: auto !important;
    padding: 15px !important;
    padding-bottom: 70px !important; /* Extra padding at bottom to prevent buttons from running off */
  }
  
  .form-group {
    position: relative !important;
    margin-bottom: 1rem !important;
    z-index: 1;
  }
  
  .form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
  }
  
  .form-input {
    width: 100%;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color var(--transition-speed) ease;
  }
  
  .form-input:focus {
    outline: none;
    border-color: var(--primary);
  }
  
  .form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
  }
  
  .form-actions {
    display: flex !important;
    gap: 10px !important;
    margin-top: 15px !important;
    margin-bottom: 15px !important;
    position: relative !important;
    width: 100% !important;
  }
  
  .form-collapsible {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
  }
  
  .form-collapsible-header {
    padding: 12px 16px;
    background: var(--bg-input);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
  }
  
  .form-collapsible-header:hover {
    background: rgba(61, 61, 61, 0.8);
  }
  
  .form-collapsible-content {
    padding: 16px;
    border-top: 1px solid var(--border-color);
  }
  
  .form-collapsible-content.collapsed {
    display: none;
  }
  
  .form-divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0;
  }
  
  /* Button variations */
  .btn {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 14px;
    font-weight: 500;
  }
  
  .btn:hover {
    background-color: var(--border-color);
  }
  
  .btn-primary {
    background-color: var(--primary);
    color: #000;
    border-color: var(--primary);
  }
  
  .btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
  }
  
  .btn-secondary {
    background-color: var(--secondary);
    color: #000;
    border-color: var(--secondary);
  }
  
  .btn-block {
    display: block;
    width: 100%;
  }
  
  /* Context Menu Styles */
  #context-menu {
    position: absolute;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 150px;
    display: none;
  }
  
  #context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  #context-menu li {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
  }
  
  #context-menu li:hover {
    background-color: var(--bg-light);
  }
  
  #context-menu li i {
    margin-right: 8px;
    color: var(--primary);
    width: 18px;
    text-align: center;
  }
  
  /* Tooltip Styles */
  .tooltip {
    position: absolute;
    background: var(--bg-dark);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius);
    font-size: 12px;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-speed);
    pointer-events: none;
    box-shadow: var(--shadow);
    white-space: nowrap;
    border: 1px solid var(--border-color);
  }
  
  .tooltip.visible {
    opacity: 1;
  }
  
  /* Keyboard shortcut display */
  .key {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-input);
    font-size: 11px;
    line-height: 1;
    vertical-align: middle;
    margin-left: 4px;
  }
  
  /* Status bar */
  .status-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 16px;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
  }
  
  /* Mini map */
  .mini-map {
    position: absolute;
    left: 16px;
    bottom: 16px;
    width: 180px;
    height: 120px;
    background: rgba(18, 18, 18, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    z-index: 10;
    backdrop-filter: blur(4px);
  }
  
  /* Loading indicator */
  .loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 18, 18, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
  }
  
  .loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  /* Node & connection type themes */
  .node-type-entrance {
    border-color: var(--primary) !important;
  }
  
  .node-type-boss {
    border-color: var(--danger) !important;
  }
  
  .node-type-treasure {
    border-color: var(--warning) !important;
  }
  
  .node-type-puzzle {
    border-color: var(--secondary) !important;
  }
  
  .edge-type-locked {
    stroke-dasharray: 5 !important;
  }
  
  .edge-type-secret {
    opacity: 0.5 !important;
  }
  
  /* Coordinate system additions */
  .coordinate-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
  }
  
  .coordinate-input-group {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  
  .coordinate-input {
    width: 60px;
    text-align: center;
  }
  
  .coord-label {
    font-weight: 600;
    color: var(--primary);
  }
  
  /* Direction selector */
  .connection-direction-selector {
    margin-top: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
  }
  
  .connection-direction-title {
    font-weight: 500;
    margin-bottom: 10px;
  }
  
  .direction-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }
  
  .direction-btn {
    padding: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .direction-btn.selected {
    background: var(--primary);
    color: black;
  }
  
  /* Connection type editor */
  .edge-editor-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-light);
    padding: 20px;
    border-radius: var(--radius);
    z-index: 2000;
    width: 400px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  }
  
  .edge-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
  }
  
  .edge-editor-title {
    font-size: 18px;
    font-weight: 600;
  }
  
  .edge-editor-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
  }
  
  .edge-direction-display {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px 0;
    font-size: 18px;
    padding: 10px;
    background: var(--bg-medium);
    border-radius: var(--radius);
  }
  
  .edge-direction-display i {
    margin: 0 10px;
    color: var(--primary);
  }
  
  .edge-type-options {
    display: flex;
    gap: 10px;
    margin: 15px 0;
  }
  
  .edge-type-option {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
  }
  
  .edge-type-option.selected {
    background: var(--primary);
    color: black;
    border-color: var(--primary);
  }
  
  /* Map controls */
  .map-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
  }
  
  .map-control-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 8px 12px;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
  }
  
  .map-control-btn:hover {
    background: var(--border-color);
  }
  
  .map-control-btn.active {
    background: var(--primary);
    color: black;
  }
  
  /* Coordinate label */
  .coord-label {
    position: absolute;
    background: rgba(45, 45, 45, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.3s, transform 0.3s;
  }
  
  /* Compass rose */
  .compass-rose {
    position: absolute;
    left: 20px;
    top: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(45, 45, 45, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
  }
  
  .compass-north, .compass-east, .compass-south, .compass-west {
    position: absolute;
  }
  
  .compass-north {
    top: 4px;
    color: var(--primary);
  }
  
  .compass-east {
    right: 4px;
  }
  
  .compass-south {
    bottom: 4px;
  }
  
  .compass-west {
    left: 4px;
  }
  
  .compass-center {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
  }
  
  /* Direction indicator */
  .direction-indicator {
    position: absolute;
    background: rgba(0, 195, 255, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    pointer-events: none;
    z-index: 5;
    transform: translate(-50%, -50%);
  }
  
  /* Shape selector */
  .shape-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
  }
  
  .shape-button {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: var(--bg-button);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0 4px;
    position: relative;
    overflow: visible;
  }
  
  .shape-button:hover {
    background: var(--bg-button-hover);
  }
  
  .shape-button.selected {
    border: 2px solid var(--accent-color);
    background: var(--bg-button-hover);
    box-shadow: 0 0 0 2px var(--accent-color);
  }
  
  .shape-button i, 
  .shape-button svg {
    font-size: 20px;
    fill: currentColor !important;
    stroke: currentColor;
    stroke-width: 1;
  }
  
  /* Fix for shape buttons - ensure they all have proper fill and shape */
  .shape-button[data-shape="hexagon"] {
    background-color: #2d2d2d;
  }
  
  .shape-button[data-shape="octagon"] {
    background-color: #2d2d2d;
    /* Use clip-path to create an octagon shape */
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  }
  
  .shape-button[data-shape="hexagon"] i,
  .shape-button[data-shape="octagon"] i {
    font-size: 20px;
    fill: currentColor !important;
    stroke: currentColor;
    stroke-width: 1;
  }
  
  /* Image upload placeholder */
  .image-upload-placeholder {
    width: 100%;
    height: 120px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-bottom: 16px;
    transition: all var(--transition-speed) ease;
  }
  
  .image-upload-placeholder:hover {
    border-color: var(--primary);
    background: rgba(0, 195, 255, 0.05);
  }
  
  .image-upload-placeholder svg {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    margin-bottom: 8px;
  }
  
  .image-upload-placeholder-text {
    font-size: 14px;
    color: var(--text-muted);
  }
  
  /* Tag input for features, items, etc. */
  .tag-input-container {
    border: 2px solid var(--border-color) !important;
    background-color: var(--bg-card) !important;
    padding: 10px !important;
    border-radius: var(--radius) !important;
    min-height: 48px !important;
    margin-bottom: 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
    gap: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 10 !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1) !important;
  }
  
  /* Basic tag style - used throughout the application */
  .tag, 
  #features-container .tag,
  #detailed-look-content .tag {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    background-color: var(--primary-light) !important;
    color: var(--text-color) !important;
    border-radius: 16px !important;
    padding: 4px 26px 4px 8px !important;
    margin: 4px !important;
    font-size: 14px !important;
    max-width: calc(100% - 8px) !important;
    word-break: break-word !important; 
    white-space: normal !important;
    height: auto !important;
    min-height: 24px !important;
    overflow-wrap: break-word !important;
    text-overflow: clip !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    border: 1px solid var(--border-color) !important;
    transition: all 0.2s ease !important;
  }
  
  /* Single unified hover style for ALL tags */
  .tag:hover {
    background-color: rgba(180, 180, 180, 0.2) !important; /* Subtle gray */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) !important;
    transform: translateY(-1px) !important;
  }
  
  /* Explicitly reset any other hover styles that might be defined elsewhere */
  #features-container .tag:hover,
  #detailed-look-content .tag:hover,
  #time-of-day-content .tag:hover,
  #weather-effects-content .tag:hover,
  #ambience-content .tag:hover,
  #room-context-content .tag:hover,
  #knowledge-content .tag:hover,
  #content-items .tag:hover,
  #knowledge-local-container .tag:hover,
  #knowledge-distant-container .tag:hover,
  #knowledge-forbidden-container .tag:hover {
    background-color: rgba(180, 180, 180, 0.2) !important; /* Same subtle gray */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) !important;
    transform: translateY(-1px) !important;
  }
  
  /* Form input hover effect */
  .form-input:not(.tag-input):hover, 
  .form-textarea:hover {
    background-color: var(--bg-input) !important;
    box-shadow: 0 0 0 2px rgba(0, 195, 255, 0.2) !important;
    cursor: pointer !important;
  }
  
  /* Fix tag remove button positioning */
  .tag-remove {
    position: absolute !important;
    right: 4px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    font-size: 14px !important;
    line-height: 1 !important;
    padding: 2px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 10 !important; /* Make sure this is higher than other elements */
    width: 18px !important;
    height: 18px !important;
  }
  
  /* Fix enhance button positioning and ensure it doesn't overlap */
  .tag-enhance {
    position: absolute !important;
    right: 22px !important; /* Position it to the left of the X button */
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 18px !important;
    height: 18px !important;
    background-color: #00c3ff !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    opacity: 0 !important;
    transition: opacity 0.2s ease !important;
    z-index: 5 !important;
  }
  
  /* Tag input styling */
  .tag-input {
    flex: 1 !important;
    min-width: 100px !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-primary) !important;
    padding: 4px !important;
    font-size: 14px !important;
  }
  
  .tag-input:focus {
    outline: none !important;
  }
  
  /* Magic wand buttons should always be visible */
  .tag-magic-wand {
    visibility: visible !important;
    opacity: 1 !important;
    display: block !important;
  }
  
  /* Ensure all tag containers have the same styling */
  #features-container,
  #sounds-container,
  #scents-container,
  #knowledge-local-container,
  #knowledge-distant-container,
  #knowledge-forbidden-container,
  #entry-prompts-container,
  #items-container,
  #characters-container {
    border: 2px solid var(--border-color) !important;
    background-color: var(--bg-card) !important;
    padding: 10px !important;
    border-radius: var(--radius) !important;
    min-height: 48px !important;
    margin-bottom: 10px !important;
  }
  
  /* Override any specific tag styles to ensure consistency */
  #time-of-day-content .tag,
  #weather-effects-content .tag,
  #ambience-content .tag,
  #room-context-content .tag,
  #knowledge-content .tag,
  #content-items .tag {
    background-color: var(--primary-light) !important;
    color: var(--text-color) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
    border: 1px solid var(--border-color) !important;
    transition: all 0.2s ease !important;
  }
  
  /* Override any specific tag hover styles to ensure consistency */
  #time-of-day-content .tag:hover,
  #weather-effects-content .tag:hover,
  #ambience-content .tag:hover,
  #room-context-content .tag:hover,
  #knowledge-content .tag:hover,
  #content-items .tag:hover {
    background-color: var(--bg-medium) !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) !important;
    transform: translateY(-1px) !important;
  }
  
  /* Remove tag magic wand styles */
  .tag-magic-wand, 
  .tag-magic-wand i,
  .magic-wand-button,
  .magic-wand-button i {
    display: none !important;
  }
  
  /* Remove selector for preventing right-side wand buttons */
  .tag button[style*="right"],
  .tag button[class*="wand"]:not(.tag-magic-wand),
  .tag button[class*="magic"]:not(.tag-magic-wand),
  .tag > *:not(.tag-remove)[style*="right"],
  .tag > *:not(.tag-remove)[class*="wand"]:not(.tag-magic-wand),
  .tag > *:not(.tag-remove)[class*="magic"]:not(.tag-magic-wand),
  .tag-magic-wand:not([style*="left: 6px"]) {
    display: none !important;
  }
  
  /* Fix close buttons to ensure they work */
  .sidebar-close,
  .modal-close,
  .btn-close-modal,
  .close-button {
    cursor: pointer !important;
    z-index: 1000 !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    position: absolute !important;
    right: 10px !important;
    top: 10px !important;
    background: none !important;
    border: none !important;
    color: var(--text-muted) !important;
    font-size: 20px !important;
    padding: 5px !important;
  }
  
  .sidebar-close:hover,
  .modal-close:hover,
  .btn-close-modal:hover,
  .close-button:hover {
    color: var(--text-primary) !important;
  }
  
  /* Notification container */
  #notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
  }
  
  .notification {
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
    min-width: 250px;
    max-width: 400px;
    display: flex;
    align-items: center;
    color: white;
    background-color: var(--bg-light);
    border-left: 4px solid;
    pointer-events: auto;
    margin-bottom: 10px;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  
  .notification.info {
    background-color: #3498db;
    border-left-color: #2980b9;
  }
  
  .notification.success {
    background-color: #2ecc71;
    border-left-color: #27ae60;
  }
  
  .notification.warning {
    background-color: #f39c12;
    border-left-color: #e67e22;
  }
  
  .notification.error {
    background-color: #e74c3c;
    border-left-color: #c0392b;
  }
  
  .notification i {
    margin-right: 10px;
    font-size: 1.2em;
  }
  
  .notification span {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
  }
  
  /* File Explorer Dialog Styles */
  .modal-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .modal-content {
    background: var(--bg-light);
    border-radius: var(--radius);
    width: 600px;
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  }
  
  .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
  }
  
  .modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--primary);
  }
  
  .modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
  }
  
  .modal-body {
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    background-color: var(--bg-card) !important;
    padding: 15px !important;
    overflow: auto !important;
    min-height: 200px !important;
  }
  
  .modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }
  
  .file-explorer-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
  }
  
  .file-explorer-path {
    background: var(--bg-medium);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-family: monospace;
    color: var(--text-secondary);
  }
  
  .file-explorer-actions {
    display: flex;
    gap: 10px;
  }
  
  .file-action-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-primary);
  }
  
  .file-action-btn:hover {
    background: var(--border-color);
  }
  
  .file-explorer-view {
    flex: 1;
    background: var(--bg-medium);
    border-radius: var(--radius);
    padding: 10px;
    margin-bottom: 15px;
    overflow-y: auto;
    min-height: 200px;
  }
  
  .file-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  
  .file-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
  }
  
  .file-item:hover {
    background: var(--bg-input);
  }
  
  .file-item.selected {
    background: rgba(0, 195, 255, 0.2);
  }
  
  .file-icon {
    margin-right: 10px;
    color: var(--text-muted);
  }
  
  .file-icon.file-json {
    color: var(--primary);
  }
  
  .file-icon.file-md {
    color: var(--secondary);
  }
  
  .file-icon.file-html {
    color: var(--warning);
  }
  
  .file-name {
    flex: 1;
  }
  
  .file-date {
    font-size: 12px;
    color: var(--text-muted);
  }
  
  .file-explorer-input {
    display: flex;
    gap: 10px;
  }
  
  .filename-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  
  .filename-input-group label {
    font-size: 14px;
    color: var(--text-secondary);
  }
  
  .file-type-dropdown {
    width: 160px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }
  
  /* Responsive adjustments */
  @media (max-width: 768px) {
    .app-container {
      grid-template-columns: 1fr;
    }
    
    #sidebar {
      position: fixed;
      right: 0;
      top: 0;
      bottom: 0;
      width: 300px;
      transform: translateX(100%);
      transition: transform var(--transition-speed) ease;
      z-index: 1000;
    }
    
    #sidebar.open {
      transform: translateX(0);
    }
    
    .toolbar-title {
      display: none;
    }
  }
  
  /* Animation for transitions */
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  .fade-in {
    animation: fadeIn var(--transition-speed) ease;
  }
  
  /* Active state for toggle buttons */
  .toolbar button.active {
    background-color: var(--accent-color) !important;
    color: white;
  }
  
  /* Active state for realign button when clicked */
  .toolbar button#realign-coords:active {
    background-color: var(--accent-color-dark);
    color: white;
  }
  
  /* Coordinate label for nodes */
  .coordinate-label {
    position: absolute;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
  }
  
  /* Splash Screen */
  .splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-dark);
    z-index: 1000;
    transition: opacity 0.8s ease-in-out, visibility 0.8s ease-in-out;
  }
  
  .splash-screen img {
    max-width: 80%;
    max-height: 80%;
  }
  
  .splash-title {
    font-size: 3rem;
    font-weight: bold;
    color: var(--primary);
    margin-top: 1rem;
    text-shadow: 0 0 10px rgba(0, 195, 255, 0.4);
  }
  
  .splash-subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
  }
  
  .splash-progress {
    width: 300px;
    height: 6px;
    background-color: var(--bg-light);
    border-radius: 3px;
    margin-top: 2rem;
    overflow: hidden;
  }
  
  .splash-progress-bar {
    height: 100%;
    background-color: var(--primary);
    width: 0;
    transition: width 1s ease-out;
  }
  
  .splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
  }
  
  /* Magic Wand Button */
  .magic-wand-button {
    position: absolute !important;
    top: calc(50% - 12px) !important;
    right: 8px !important;
    background-color: #00c3ff !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 50 !important;
  }
  
  .magic-wand-button i {
    font-size: 12px !important;
  }
  
  /* AI Enhance Modal */
  .enhance-editor-container {
    position: relative;
    width: 100%;
    flex-grow: 1;
    min-height: 150px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-card);
  }
  
  .enhance-editor {
    width: 100%;
    height: 100%;
    min-height: 150px;
    padding: 12px;
    font-size: 15px;
    line-height: 1.5;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-input);
    color: var(--text-color);
    resize: vertical;
    flex-grow: 1;
  }
  
  .enhance-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
  }
  
  .enhance-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 195, 255, 0.3);
    border-top: 4px solid #00c3ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  
  .enhance-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
  }
  
  .enhance-btn {
    flex: 1;
    padding: 15px 10px !important;
    border: none;
    border-radius: 4px;
    background-color: var(--bg-card) !important;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom-width: 3px !important;
    border-bottom-style: solid !important;
  }
  
  .enhance-btn i {
    font-size: 18px !important;
    margin-bottom: 5px !important;
    display: inline-block !important;
  }
  
  .enhance-btn:hover {
    background-color: var(--bg-hover);
  }
  
  #enhance-basic {
    border-bottom-color: #4caf50 !important;
  }
  
  #enhance-descriptive {
    border-bottom-color: #2196f3 !important;
  }
  
  #enhance-wordy {
    border-bottom-color: #9c27b0 !important;
  }
  
  .resize-handle {
    position: absolute !important;
    bottom: 0 !important;
    right: 0 !important;
    width: 20px !important;
    height: 20px !important;
    cursor: nwse-resize !important;
    background: linear-gradient(135deg, transparent 60%, var(--primary) 60%) !important;
    border-radius: 0 0 4px 0 !important;
    z-index: 20 !important;
  }

#ai-enhance-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: none;
    z-index: 9999 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
}

#ai-enhance-modal .modal-content {
    background-color: var(--bg-dark) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    width: 600px !important;
    max-width: 90% !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

.modal-header {
    background-color: var(--bg-darker);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    cursor: move;
}

.close-button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
}

.close-button:hover {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.1);
}

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

/* Add resize functionality to the enhance modal */
.enhance-modal-content {
    resize: both !important;
    overflow: hidden !important; /* Changed from auto to hidden */
    min-width: 400px !important;
    min-height: 400px !important;
    max-width: 95vw !important;
    max-height: 95vh !important;
}

/* More comprehensive fix for hover highlights - keep borders visible */
.form-input:hover, 
.form-textarea:hover,
textarea:hover,
input[type="text"]:hover,
.tag:hover,
#points-of-interest:hover,
#detailed-look-general:hover,
#room-description:hover,
textarea.form-input:hover,
.form-input.form-textarea:hover,
[class*="content"] .form-input:hover,
[id*="effects"] .form-input:hover,
[id*="-of-"] .form-input:hover {
    background-color: var(--bg-input) !important;
    box-shadow: none !important;
    border-color: var(--border-color) !important;
}

/* Make sure tag input containers keep their border */
.tag-input-container,
.tag-input-container:hover {
    border: 1px solid var(--border-color) !important;
    background-color: var(--bg-input) !important;
}

/* Fix potential z-index issues with tag input container */
.form-group {
    position: relative !important;
    margin-bottom: 1rem !important;
    z-index: 1;
}

/* Override any conflicting hover styles */
.form-group:hover .form-input,
.form-group:hover .form-textarea,
.form-group:hover textarea {
    background-color: var(--bg-input) !important;
}

/* Add back the highlight for the enhance buttons only */
.form-group:hover .enhance-trigger,
.tag-input-container:hover .enhance-trigger,
.tag:hover .tag-enhance {
    opacity: 1 !important;
}

/* Icon styles for enhance buttons */
#enhance-basic i {
    color: #4caf50 !important; /* Green */
    display: block !important;
    font-size: 24px !important;
    margin-bottom: 8px !important;
}

#enhance-descriptive i {
    color: #2196f3 !important; /* Blue */
    display: block !important;
    font-size: 24px !important;
    margin-bottom: 8px !important;
}

#enhance-wordy i {
    color: #9c27b0 !important; /* Purple */
    text-shadow: 0 0 5px rgba(156, 39, 176, 0.5) !important;
}

/* Ensure icons display properly */
.enhance-btn i {
    font-size: 18px !important;
    margin-bottom: 5px !important;
    display: inline-block !important;
}

/* Fix tag container frames - make them more visible and ensure they display */
.tag-input-container {
    border: 2px solid var(--border-color) !important;
    background-color: var(--bg-card) !important;
    padding: 10px !important;
    border-radius: var(--radius) !important;
    min-height: 48px !important;
    margin-bottom: 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-start !important;
    gap: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    position: relative !important;
    z-index: 10 !important;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

/* Make sure all tag containers have visible frames */
#features-container,
#sounds-container,
#scents-container,
#knowledge-local-container,
#knowledge-distant-container,
#knowledge-forbidden-container,
#entry-prompts-container,
#items-container,
#characters-container,
[id$="-container"] {
    border: 2px solid var(--border-color) !important;
    background-color: var(--bg-card) !important;
    min-height: 48px !important;
    padding: 10px !important;
    border-radius: var(--radius) !important;
}

/* Hide textareas that are used for tag lists */
.form-group textarea[id="detailed-look-features"],
.form-group textarea[id="ambient-sounds"],
.form-group textarea[id="scents"],
.form-group textarea[id="knowledge-local"],
.form-group textarea[id="knowledge-distant"],
.form-group textarea[id="knowledge-forbidden"],
.form-group textarea[id="entry-prompts"],
.form-group textarea[id="items"],
.form-group textarea[id="characters"] {
    display: none !important;
}

/* Hide the bottom wands completely since they're not needed when the tags have their own wands */
.tag-input-container + .magic-wand-button,
#features-container ~ .magic-wand-button,
#sounds-container ~ .magic-wand-button,
#scents-container ~ .magic-wand-button,
#knowledge-local-container ~ .magic-wand-button,
#knowledge-distant-container ~ .magic-wand-button,
#knowledge-forbidden-container ~ .magic-wand-button,
#entry-prompts-container ~ .magic-wand-button,
#items-container ~ .magic-wand-button,
#characters-container ~ .magic-wand-button,
.tag-input-container + button.edit-btn,
div[id$="-container"] + .magic-wand-button,  /* General selector for any container */
.tag-input-container + button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    pointer-events: none !important;
}

/* Fix text wrapping in special input fields */
#atmosphere,
textarea[name="atmosphere"],
#atmosphere-textarea,
#time-of-day-content input,
#weather-effects-content input,
#room-context-content input,
input[data-type="morning"],
input[data-type="afternoon"],
input[data-type="evening"],
input[data-type="night"],
input[data-type="clear"],
input[data-type="rain"],
input[data-type="fog"],
input[data-type="lighting"],
input[data-type="temperature"],
input[data-type="ground"],
.subsection-container input,
.environmental-effects-container input {
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding-right: 15px !important;
    height: auto !important;
    min-height: 34px !important;
    line-height: 1.4 !important;
}

/* Make sure subsection containers have proper styling */
#time-of-day-content .subsection-container,
#weather-effects-content .subsection-container,
#room-context-content .subsection-container,
.environmental-effects-container,
.subsection-container {
    border: 1px solid var(--border-color) !important;
    background-color: var(--bg-card) !important;
    padding: 10px !important;
    border-radius: var(--radius) !important;
    margin-bottom: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* Hide unnecessary Save and Delete buttons since changes are saved automatically */
#save-room, #delete-room {
    display: none !important;
}

/* Fix atmosphere input field */
#room-atmosphere {
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding-right: 15px !important;
    height: auto !important;
    min-height: 54px !important; /* Taller for atmosphere */
    line-height: 1.4 !important;
    max-width: 100% !important; /* Enforce max width */
    margin-bottom: 10px !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
}