/* Cyberpad.site - Modern Cyberpunk Theme */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    --bg-primary: #050508;
    --bg-secondary: #0a0a0f;
    --bg-tertiary: #1a1a24;
    --bg-card: rgba(26, 26, 36, 0.8);
    
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #8b9bb4;
    
    --accent-cyan: #00f5ff;
    --accent-magenta: #ff00ff;
    --accent-purple: #9945ff;
    --accent-green: #00ff88;
    --accent-red: #ff4466;
    
    --border-color: rgba(0, 245, 255, 0.2);
    --border-hover: rgba(0, 245, 255, 0.4);
    
    --shadow-glow: 0 0 20px rgba(0, 245, 255, 0.3);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);
    
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;
    
    --transition: all 0.15s ease;
}

/* ========================================
   Base Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

/* ========================================
   Gradient Text
   ======================================== */
.gradient-text {
    background: linear-gradient(90deg, #00f5ff, #ff00ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========================================
   Glow Border
   ======================================== */
.glow-border {
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.1), inset 0 0 20px rgba(0, 245, 255, 0.02);
}

.glow-border:hover {
    box-shadow: 0 0 30px rgba(0, 245, 255, 0.15), inset 0 0 20px rgba(0, 245, 255, 0.03);
}

/* ========================================
   Editor Textarea
   ======================================== */
.editor-textarea {
    font-family: 'JetBrains Mono', monospace;
    background: transparent;
    resize: none;
}

.editor-textarea:focus {
    outline: none;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 4px;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
}

.btn-primary {
    background: linear-gradient(135deg, #00f5ff 0%, #9945ff 100%);
    color: #000;
    border: none;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.4);
}

.btn-success {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.btn-success:hover:not(:disabled) {
    background: rgba(0, 255, 136, 0.25);
    border-color: rgba(0, 255, 136, 0.5);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 245, 255, 0.3);
    color: #fff;
}

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

.btn-ghost {
    background: transparent;
    color: #8b9bb4;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #00f5ff;
    border-color: rgba(0, 245, 255, 0.3);
}

.btn-enhance {
    background: rgba(153, 69, 255, 0.15);
    color: #9945ff;
    border: 1px solid rgba(153, 69, 255, 0.3);
}

.btn-enhance:hover:not(:disabled) {
    background: rgba(153, 69, 255, 0.25);
    border-color: rgba(153, 69, 255, 0.5);
}

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

.btn-icon {
    padding: 6px;
    background: transparent;
    color: #8b9bb4;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.btn-icon:hover {
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    border-color: rgba(0, 255, 136, 0.3);
}

.btn-icon-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-sm:hover {
    background: rgba(255, 68, 102, 0.15);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

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

/* ========================================
   Badge
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-success {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
}

.badge-info {
    background: rgba(0, 245, 255, 0.15);
    color: var(--accent-cyan);
}

.badge-live {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    font-size: 9px;
    padding: 1px 5px;
    margin-left: 6px;
}

/* ========================================
   Dropdown
   ======================================== */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: fixed;
    min-width: 180px;
    background: rgba(20, 20, 28, 0.98);
    border: 1px solid rgba(0, 245, 255, 0.2);
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
}

.dropdown.open .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 13px;
    color: #e0e0e0;
    cursor: pointer;
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: rgba(0, 245, 255, 0.1);
}

.dropdown-item.active {
    color: #00f5ff;
}

.dropdown-item.delete-item:hover {
    background: rgba(255, 68, 102, 0.15);
    color: var(--accent-red);
}

.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 4px 0;
}

.dropdown-label {
    padding: 8px 12px 4px;
    font-size: 10px;
    font-weight: 600;
    color: #8b9bb4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========================================
   Inputs
   ======================================== */
.input,
.select {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    background: #0a0a0f;
    border: 1px solid rgba(0, 245, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    transition: border-color 0.15s;
}

.input:focus,
.select:focus {
    outline: none;
    border-color: rgba(0, 245, 255, 0.5);
}

.input::placeholder {
    color: #6b7280;
}

.select {
    appearance: none;
    cursor: pointer;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b9bb4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* ========================================
   Model Chip
   ======================================== */
.model-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(0, 245, 255, 0.1);
    border: 1px solid rgba(0, 245, 255, 0.2);
    border-radius: 4px;
    color: #00f5ff;
    cursor: pointer;
    transition: var(--transition);
}

.model-chip:hover {
    background: rgba(0, 245, 255, 0.15);
    border-color: rgba(0, 245, 255, 0.4);
}

.model-chip.image {
    background: rgba(153, 69, 255, 0.1);
    border-color: rgba(153, 69, 255, 0.2);
    color: #9945ff;
}

.model-chip.image:hover {
    background: rgba(153, 69, 255, 0.15);
    border-color: rgba(153, 69, 255, 0.4);
}

/* ========================================
   Model Dropdown List
   ======================================== */
.model-option {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-option:hover,
.model-option.highlighted {
    background: rgba(0, 245, 255, 0.1);
}

.model-option.selected {
    background: rgba(0, 245, 255, 0.15);
    border-left: 2px solid var(--accent-cyan);
}

.model-option-name {
    font-size: 12px;
    color: var(--text-primary);
}

.model-option-id {
    font-size: 10px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.model-option-price {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
}

.no-models-found {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

.model-group-header {
    padding: 6px 12px;
    font-size: 10px;
    font-weight: 600;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
}

/* Recommended tooltip styling */
.recommended-tooltip {
    color: var(--accent-purple);
    font-weight: bold;
    cursor: help;
    margin-left: 4px;
}

.model-group-header .recommended-tooltip {
    font-size: 12px;
}

.model-group-header:has(.recommended-tooltip) {
    color: var(--accent-purple);
}

/* ========================================
   Tab Buttons
   ======================================== */
.tab-btn {
    background: transparent;
    border: none;
    color: #8b9bb4;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    background: rgba(0, 245, 255, 0.2);
    color: #00f5ff;
}

/* ========================================
   Tab Content
   ======================================== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ========================================
   Markdown Preview
   ======================================== */
.markdown-preview {
    background: var(--bg-primary);
    font-size: 0.85rem;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.markdown-preview h1 { font-size: 1.3rem; }
.markdown-preview h2 { font-size: 1.1rem; }
.markdown-preview h3 { font-size: 1.1rem; }

.markdown-preview p {
    margin-bottom: 0.75rem;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.markdown-preview ul {
    list-style-type: disc;
}

.markdown-preview ol {
    list-style-type: decimal;
}

.markdown-preview code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
}

.markdown-preview pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

/* ========================================
   Output Section
   ======================================== */
.output-container {
    position: relative;
    min-height: 400px;
    overflow: hidden;
    border-radius: 0 0 6px 6px;
}

.output-top-spacer {
    height: 12px;
    background: #fff;
    display: none;
}

.output-frame {
    width: 100%;
    min-height: 600px;
    height: auto;
    border: none;
    display: block;
    background: white;
}

.output-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.output-loading {
    display: flex;
    scroll-margin-top: 96px;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(0, 245, 255, 0.1), rgba(139, 92, 246, 0.1));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 0.5rem;
    color: var(--accent-cyan);
    font-weight: 500;
}

.loading-spinner-small {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

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

.toast.success {
    border-left: 3px solid var(--accent-green);
}

.toast.error {
    border-left: 3px solid var(--accent-red);
}

.toast.info {
    border-left: 3px solid var(--accent-cyan);
}

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 39, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 2rem;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-width: 900px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
}

dialog.modal-content {
    padding: 0;
    border: none;
}

dialog.modal-content[open] {
    display: flex;
}

dialog.modal-content:not([open]) {
    display: none;
}

dialog::backdrop {
    background: rgba(10, 14, 39, 0.95);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(0, 245, 255, 0.05);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: #e5e7eb;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* ========================================
   Directory Cards
   ======================================== */
/* Directory card styles moved to directory-cards.css */

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

::-webkit-scrollbar-track {
    background: #0a0a0f;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 245, 255, 0.3);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 245, 255, 0.5);
}

/* ========================================
   Recording Animation
   ======================================== */
.recording {
    color: var(--accent-red) !important;
    animation: pulse 1.5s infinite;
}

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

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .model-chip span:not(:first-child):not(:last-child) {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .dropdown-menu {
        min-width: 160px;
    }
}

@media (max-width: 640px) {
    /* Header mobile fixes */
    header .max-w-7xl {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    header .gap-4 {
        gap: 0.5rem;
    }
    
    /* Editor header - stack on mobile */
    .editor-header-mobile {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Ensure inner groups can wrap instead of overflowing */
    .editor-header-mobile > div:first-child {
        flex-wrap: wrap;
    }

    /* Truncate long page names on mobile */
    #currentPageName {
        max-width: 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: inline-block;
        vertical-align: bottom;
    }
    
    /* Model chips - truncate text */
    .model-chip {
        max-width: 120px;
    }
    
    .model-chip span:nth-child(2) {
        max-width: 70px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Action bar - stack buttons */
    .action-bar-mobile {
        flex-direction: column;
        gap: 0.75rem;
    }

    
    .action-bar-mobile > div {
        width: 100%;
        justify-content: space-between;
    }

    /* Allow the left control cluster (model chips etc.) to wrap on small screens */
    .action-bar-mobile > div:first-child {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    /* Buttons full width on mobile */
    .btn-mobile-full {
        flex: 1;
        justify-content: center;
    }
    
    /* Enhance bar stack */
    .enhance-bar-mobile {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .enhance-bar-mobile .input {
        min-width: 100% !important;
    }
    
    /* Output section header */
    .output-header-mobile {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .output-header-mobile > div {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* ========================================
   Directory Section Visibility
   ======================================== */
.directory-section {
    display: none;
}

.directory-section[style*="display: block"] ~ #editorSection {
    display: none !important;
}

#editorSection[style*="display: none"] {
    display: none !important;
}
