/**
 * Markdown Preview Editor Styles
 * Aethvion Labs - Text & Code Tools Section
 * Premium dark cybernetic look with full responsiveness and print layout rules.
 */

/* Main Wrapper Settings */
.md-tool {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 10px;
}

/* Control/Header Bar */
.workspace-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.1);
  padding: 10px 15px;
  border-radius: 8px;
}

.workspace-header-bar .control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace-header-bar label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.cyber-select {
  background: rgba(10, 15, 30, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.2);
  color: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  outline: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cyber-select:focus,
.cyber-select:hover {
  border-color: #00F0FF;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}

.layout-toggle-group {
  display: flex;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 6px;
  overflow: hidden;
}

.layout-toggle-group .cyber-btn {
  border: none;
  border-radius: 0;
  border-right: 1px solid rgba(0, 240, 255, 0.2);
}

.layout-toggle-group .cyber-btn:last-child {
  border-right: none;
}

.layout-toggle-group .cyber-btn.active {
  background: rgba(0, 240, 255, 0.2);
  color: #00F0FF;
  text-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
}

.metrics-indicator-panel {
  display: flex;
  gap: 15px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-item strong {
  color: #00F0FF;
  text-shadow: 0 0 5px rgba(0, 240, 255, 0.3);
}

/* Main Layout Grid */
.md-workspace-grid {
  display: grid;
  height: 600px;
  min-height: 400px;
  gap: 15px;
  transition: all 0.3s ease;
}

.md-workspace-grid.split-mode {
  grid-template-columns: 1fr 1fr;
}

.md-workspace-grid.editor-mode {
  grid-template-columns: 1fr;
}

.md-workspace-grid.editor-mode #panel-preview {
  display: none;
}

.md-workspace-grid.preview-mode {
  grid-template-columns: 1fr;
}

.md-workspace-grid.preview-mode #panel-editor {
  display: none;
}

/* Panels */
.workspace-panel {
  display: flex;
  flex-direction: column;
  background: rgba(11, 15, 25, 0.65);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: all 0.3s ease;
}

.workspace-panel:focus-within {
  border-color: rgba(0, 240, 255, 0.35);
  box-shadow: 0 4px 25px rgba(0, 240, 255, 0.08);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
}

.panel-title-tag {
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Toolbar Style */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.toolbar-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: all 0.2s ease;
  min-width: 26px;
  text-align: center;
}

.toolbar-btn:hover {
  background: rgba(0, 240, 255, 0.15);
  color: #00F0FF;
  text-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
}

.toolbar-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

/* Editor Workspace Textarea */
.editor-textarea-wrapper {
  flex: 1;
  position: relative;
}

#markdown-textarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  resize: none;
  outline: none;
  color: #e2e8f0;
  font-family: 'Consolas', 'Monaco', 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 15px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.2) rgba(0, 0, 0, 0.2);
}

#markdown-textarea::placeholder {
  color: rgba(255, 255, 255, 0.25);
  font-style: italic;
}

/* Preview Canvas Container */
.preview-canvas-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.preview-render-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.2) rgba(0, 0, 0, 0.2);
}

/* Outline Panel Styles */
.outline-sidebar-menu {
  width: 220px;
  background: rgba(7, 10, 18, 0.95);
  border-right: 1px solid rgba(0, 240, 255, 0.15);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  overflow-y: auto;
  scrollbar-width: none;
}

.outline-sidebar-menu.hidden {
  width: 0;
  border-right: none;
  overflow: hidden;
}

.outline-header {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: #00F0FF;
  padding: 12px 15px;
  border-bottom: 1px solid rgba(0, 240, 255, 0.1);
  text-transform: uppercase;
}

.outline-links-list {
  list-style: none;
  padding: 8px 0;
  margin: 0;
}

.outline-item {
  margin: 0;
}

.outline-link {
  display: block;
  padding: 6px 15px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.outline-link:hover {
  background: rgba(0, 240, 255, 0.05);
  color: #00F0FF;
  border-left-color: #00F0FF;
  padding-left: 18px;
}

.outline-depth-1 { padding-left: 15px; font-weight: bold; }
.outline-depth-2 { padding-left: 25px; }
.outline-depth-3 { padding-left: 35px; color: rgba(255, 255, 255, 0.5); }
.outline-depth-4 { padding-left: 45px; color: rgba(255, 255, 255, 0.4); }
.outline-depth-5 { padding-left: 55px; color: rgba(255, 255, 255, 0.3); }
.outline-depth-6 { padding-left: 65px; color: rgba(255, 255, 255, 0.3); }

.empty-outline-msg {
  padding: 15px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
}

/* CSS Scrollbar for all panels */
#markdown-textarea::-webkit-scrollbar,
.preview-render-area::-webkit-scrollbar,
.outline-sidebar-menu::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

#markdown-textarea::-webkit-scrollbar-track,
.preview-render-area::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

#markdown-textarea::-webkit-scrollbar-thumb,
.preview-render-area::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.2);
  border-radius: 3px;
}

#markdown-textarea::-webkit-scrollbar-thumb:hover,
.preview-render-area::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.4);
}

/* Markdown Rendering Styling */
.markdown-body {
  color: #cbd5e1;
  font-size: 0.95rem;
  line-height: 1.75;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.markdown-body > *:first-child {
  margin-top: 0 !important;
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4, 
.markdown-body h5, 
.markdown-body h6 {
  color: #fff;
  margin-top: 1.5em;
  margin-bottom: 0.6em;
  font-weight: 600;
  line-height: 1.35;
  scroll-margin-top: 20px;
}

.markdown-body h1 {
  font-size: 1.75rem;
  color: #00F0FF;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
  border-bottom: 1px solid rgba(0, 240, 255, 0.25);
  padding-bottom: 8px;
}

.markdown-body h2 {
  font-size: 1.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}

.markdown-body h3 { font-size: 1.15rem; }
.markdown-body h4 { font-size: 1rem; }

.markdown-body p {
  margin-top: 0;
  margin-bottom: 1.2em;
}

.markdown-body a {
  color: #00F0FF;
  text-decoration: none;
  border-bottom: 1px dashed rgba(0, 240, 255, 0.4);
  transition: all 0.2s ease;
}

.markdown-body a:hover {
  color: #fff;
  border-bottom-color: #00F0FF;
  text-shadow: 0 0 5px rgba(0, 240, 255, 0.3);
}

.markdown-body blockquote {
  margin: 1.5em 0;
  padding: 8px 16px;
  color: #94a3b8;
  background: rgba(138, 43, 226, 0.06);
  border-left: 4px solid #8A2BE2;
  border-radius: 0 6px 6px 0;
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body ul, 
.markdown-body ol {
  margin-top: 0;
  margin-bottom: 1.2em;
  padding-left: 24px;
}

.markdown-body li {
  margin-bottom: 0.4em;
}

.markdown-body code {
  font-family: 'Consolas', 'Monaco', 'Courier New', Courier, monospace;
  font-size: 0.85em;
  background: rgba(0, 240, 255, 0.08);
  color: #00F0FF;
  border: 1px solid rgba(0, 240, 255, 0.15);
  padding: 2px 5px;
  border-radius: 4px;
}

.markdown-body pre {
  margin: 1.5em 0;
  padding: 15px;
  background: rgba(7, 10, 18, 0.85);
  border: 1px solid rgba(138, 43, 226, 0.2);
  border-radius: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.markdown-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #e2e8f0;
  font-size: 0.85rem;
}

.markdown-body hr {
  height: 1px;
  border: none;
  background: rgba(0, 240, 255, 0.2);
  margin: 2em 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin: 1em 0;
}

/* Tables in markdown */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.9rem;
}

.markdown-body table th,
.markdown-body table td {
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.markdown-body table th {
  background: rgba(0, 240, 255, 0.08);
  color: #00F0FF;
  font-weight: 600;
  border-bottom: 2px solid rgba(0, 240, 255, 0.3);
}

.markdown-body table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.markdown-body table tr:hover {
  background: rgba(0, 240, 255, 0.03);
}

/* Footer Export Buttons Wrapper */
.export-actions-footer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  background: rgba(15, 23, 42, 0.3);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.export-actions-footer-bar .cyber-btn {
  min-width: 130px;
}

/* Syntax Info Grid */
.syntax-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin: 20px 0;
}

.syntax-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 12px;
}

.syntax-card h3 {
  margin-top: 0;
  font-size: 0.9rem;
  color: #00F0FF;
  margin-bottom: 8px;
}

.syntax-card pre {
  margin: 0;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px;
  border-radius: 4px;
}

.syntax-card code {
  color: #cbd5e1;
  font-size: 0.8rem;
}

/* Print Overrides (@media print) */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  
  header,
  .sidebar,
  footer,
  .hero,
  .workspace-header-bar,
  #panel-editor,
  .preview-actions,
  .outline-sidebar-menu,
  .export-actions-footer-bar,
  .info-section {
    display: none !important;
  }
  
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .content-wrapper {
    max-width: 100% !important;
    padding: 0 !important;
  }
  
  .tool-wrapper {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  
  .md-workspace-grid {
    display: block !important;
    height: auto !important;
  }
  
  #panel-preview {
    display: block !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #000 !important;
  }
  
  .preview-render-area {
    overflow: visible !important;
    padding: 0 !important;
  }
  
  .markdown-body {
    color: #000 !important;
    font-size: 11pt !important;
  }
  
  .markdown-body h1,
  .markdown-body h2,
  .markdown-body h3,
  .markdown-body h4 {
    color: #000 !important;
    text-shadow: none !important;
    page-break-after: avoid;
  }
  
  .markdown-body h1 {
    border-bottom: 2px solid #000 !important;
  }
  
  .markdown-body h2 {
    border-bottom: 1px solid #ddd !important;
  }
  
  .markdown-body a {
    color: #000 !important;
    text-decoration: underline !important;
  }
  
  .markdown-body pre {
    background: #f5f5f5 !important;
    border: 1px solid #ccc !important;
    color: #000 !important;
    page-break-inside: avoid;
  }
  
  .markdown-body code {
    background: #eee !important;
    border: 1px solid #ccc !important;
    color: #000 !important;
  }
  
  .markdown-body table th {
    background: #eaeaea !important;
    color: #000 !important;
    border-bottom: 2px solid #000 !important;
  }
  
  .markdown-body tr {
    page-break-inside: avoid;
  }
}

/* Responsiveness overrides */
@media (max-width: 900px) {
  .md-workspace-grid.split-mode {
    grid-template-columns: 1fr;
    height: 800px;
  }
}

@media (max-width: 600px) {
  .workspace-header-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .layout-toggle-group {
    justify-content: center;
  }
  
  .metrics-indicator-panel {
    justify-content: space-around;
  }
  
  .export-actions-footer-bar .cyber-btn {
    width: 100%;
  }
}
