/**
 * META-AIML Lite Admin Styles - Optimized
 * Clean UI for simplified plugin version
 */

/* CSS Variables */
:root {
    /* Colors */
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-success: #4cad80;
    --color-warning: #f59e0b;
    --color-error: #ef4444;

    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-hover: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
}

/* Reset WordPress Admin Styles */
.meta-aiml-admin-wrapper {
    margin-left: 0;
    margin-right: 0;
    margin-top: -10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    min-height: calc(100vh - 32px);
    max-width: 100%;
    overflow-x: hidden;
}

.meta-aiml-admin-wrapper * {
    box-sizing: border-box;
}

/* Top Bar */
.meta-aiml-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-xl);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.plugin-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.plugin-logo h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Main Content Area */
.meta-aiml-main-content {
    display: flex;
    height: calc(100vh - 65px);
    max-width: 100%;
    overflow-x: hidden;
}

/* Sidebar */
.meta-aiml-sidebar {
    width: 260px;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    width: 100%;
    text-decoration: none !important;
}

.nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--color-primary);
    color: white;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item span {
    text-decoration: none !important;
}

/* Sidebar Actions */
.sidebar-actions {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

.sidebar-actions h3 {
    margin: 0 0 var(--spacing-md) 0;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    letter-spacing: 0.05em;
}

.action-button {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-xs);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none !important;
}

.action-button:hover {
    background-color: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-button.primary {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.action-button.primary:hover {
    background-color: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
    text-decoration: none !important;
}

.action-button.inline {
    width: auto;
    display: inline-flex;
}

/* Content Area */
.meta-aiml-content {
    flex: 1;
    overflow: hidden;
    background-color: var(--bg-secondary);
    max-width: calc(100% - 260px);
}

.tab-content {
    display: none;
    height: 100%;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Editor Tab */
.editor-header,
.docs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.editor-header h2,
.docs-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.editor-controls {
    display: flex;
    gap: var(--spacing-sm);
}

.control-button {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-button:hover {
    background-color: var(--bg-hover);
}

/* Editor Container */
#monaco-editor-container {
    flex: 1;
    min-height: calc(100vh - 200px);
    height: calc(100vh - 200px);
}

#meta-aiml-editor {
    width: 100% !important;
    height: 400px !important;
    border: 1px solid #ddd !important;
    font-family: 'SFMono-Regular', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', 'Courier New', monospace !important;
    font-size: 13px !important;
    padding: 10px !important;
    resize: vertical !important;
    box-sizing: border-box !important;
}

#monaco-editor-container textarea {
    height: 100% !important;
}

/* CodeMirror Editor Styles */
.CodeMirror {
  background-color: #ffffff !important; /* Editor background */
  color: #1f2937 !important; /* Default text color */
  border: 1px solid #d1d5db !important; /* Border around editor */
  font-family: 'SFMono-Regular', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace !important;
  font-size: 14px !important;
  line-height: 1.5 !important;
  height: calc(100vh - 200px) !important;
  min-height: calc(100vh - 200px) !important;
  max-height: none !important;
}

.CodeMirror-focused {
  border-color: #d1d5db !important; /* Brand color when focused */
}

.CodeMirror-gutters {
  background-color: #ffffff !important; /* Gutter background */
  border-right: 1px solid #e5e7eb !important; /* Gutter separator */
}

.CodeMirror-linenumber {
  color: #9ca3af !important; /* Line numbers color */
  padding: 0 8px !important;
}

.CodeMirror-activeline-background {
  background-color: #f3f4f6 !important; /* Active line background */
}

.CodeMirror-scroll {
  height: 100% !important;
  overflow-y: auto !important;
  overflow-x: auto !important;
}

/* Syntax Highlighting */
.cm-string {
  color: #b45309 !important; /* Strings: warm brown */
}

.cm-property {
  color: #4f46e5 !important; /* Properties: brand color */
}

.cm-number,
.cm-atom {
  color: #059669 !important; /* Numbers/atoms: green */
}

.cm-punctuation,
.cm-bracket {
  color: #9ca3af !important; /* Punctuation/brackets: light gray */
}

.cm-keyword {
  color: #4f46e5 !important; /* Keywords: brand color */
  font-weight: bold !important;
}

.cm-variable {
  color: #1f2937 !important; /* Variables: normal text color */
}

.cm-comment {
  color: #6b7280 !important; /* Comments: gray */
  font-style: italic !important;
}

.cm-error {
  color: #dc2626 !important; /* Error text: red */
  background-color: #fee2e2 !important; /* Error background */
}

/* Selection and cursor */
.CodeMirror-selected {
  background-color: #c7d2fe !important; /* Selected text: light violet */
  color: #1f2937 !important;
}

.CodeMirror-cursor {
  border-left: 2px solid #4f46e5 !important; /* Cursor color: brand */
}

/* Matching bracket highlight */
.CodeMirror-matchingbracket {
  color: #1f2937 !important; /* Matching bracket text color */
  background-color: #e0e7ff !important; /* Soft blue-violet background */
  font-weight: bold !important;
}


/* Editor Footer */
.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.editor-stats {
    display: flex;
    gap: var(--spacing-lg);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Documentation Tab */
.docs-content {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.docs-meta-intro {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid #4f46e5;
}

.docs-meta-intro h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
}

.docs-meta-intro p {
    margin: 0;
    color: #666;
    line-height: 1.6;
}

.docs-section-title {
    margin: 30px 0 20px 0;
    color: #333;
}

.docs-section-title:first-child {
    margin-top: 0;
}

.docs-references-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.docs-ref-item {
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
    border-left: 4px solid #4f46e5;
}

.docs-ref-item h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

.docs-ref-item a {
    display: block;
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.4;
    color: #4f46e5;
    text-decoration: none;
}

.docs-ref-item a:hover {
    text-decoration: underline;
}

.docs-ref-item p {
    margin: 8px 0 0 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* Full Version Tab */
.full-version-info {
    font-size: 0.875rem;
}

.download-section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #4f46e5;
    margin: 20px 0;
}

.download-section h4 {
    margin: 0 0 15px 0;
    color: #333;
}

.download-section a {
    color: #4cad80;
    text-decoration: none;
    font-size: 16px;
}

.download-section a:hover {
    text-decoration: underline;
}

/* Status Messages */
.status-message {
    position: fixed;
    top: 32px;
    right: 20px;
    z-index: 100000;
    background: white;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #4f46e5;
    min-width: 100px;
    display: none;
}

.status-content {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-message.error {
    border-left-color: #d63638;
}

.status-message.warning {
    border-left-color: #dba617;
}

.status-message.success {
    border-left-color: #4cad80;
}

.status-text {
    color: var(--text-primary) !important;
}

.status-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 16px !important;
    height: 16px !important;
}

/* Fullscreen Editor Styles */
body.meta-aiml-fullscreen {
    overflow: hidden;
}

#monaco-editor-container.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
    background: white !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Fullscreen exit button */
#monaco-editor-container.fullscreen::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(79, 70, 229, 0.9);
    border-radius: 4px;
    z-index: 1000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#monaco-editor-container.fullscreen::after {
    content: '✕';
    position: absolute;
    top: 10px;
    right: 20px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    font-weight: bold;
    z-index: 1000001;
    cursor: pointer;
    pointer-events: none;
}

#monaco-editor-container.fullscreen .CodeMirror {
    height: 100vh !important;
    min-height: 100vh !important;
    border: none !important;
}

#monaco-editor-container.fullscreen textarea {
    height: 100vh !important;
    border: none !important;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: var(--radius-full);
}

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