/* Import color palette first - @import must be before all other rules */
@import url('colors.css');

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

:root {
    --header-height: 56px;
    --sidebar-width: 250px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

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

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: var(--header-height);
    background: var(--gray-900);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.logo {
    font-size: 20px;
    font-weight: 700;
}

.logo-wordmark {
    height: 20px;
    width: auto;
    display: block;
}

.header .logo {
    height: 36px;
    width: auto;
    cursor: pointer;
    transition: opacity 0.2s;
}

.header .logo:hover {
    opacity: 0.8;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    margin-left: 10px;
    color: #aaa;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-info svg {
    width: 16px;
    height: 16px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn svg {
    width: 16px;
    height: 16px;
}

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

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

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

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

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

.btn-secondary {
    background: var(--gray-600);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-700);
}

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

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

.btn-link {
    background: none;
    color: var(--gray-400);
    text-decoration: none;
    padding: 8px 12px;
}

.btn-link:hover {
    color: white;
}

.btn-small {
    padding: 4px 8px;
    font-size: 16px;
    font-weight: bold;
    background: var(--primary);
    color: var(--text-on-primary);
}

.btn-small svg {
    width: 16px;
    height: 16px;
}

.btn-small:hover {
    background: var(--primary-dark);
}

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

.btn-sm svg {
    width: 14px;
    height: 14px;
}

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

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
}

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

.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.dropdown-menu button svg {
    width: 16px;
    height: 16px;
}

.dropdown-menu button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

/* Resize Handles */
.resize-handle {
    position: relative;
    z-index: 10;
}

.resize-handle-vertical {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.resize-handle-vertical:hover {
    background: var(--primary);
}

.resize-handle-vertical:active {
    background: var(--primary-dark);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sidebar Hint */
.sidebar-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-tertiary);
}

.sidebar-hint svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Sidebar Search */
.sidebar-search {
    padding: 10px 15px;
    border-bottom: 1px solid var(--border-light);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper > i {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    padding: 8px 32px 8px 36px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-page);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.search-input-wrapper input::placeholder {
    color: var(--text-tertiary);
}

.search-clear {
    position: absolute;
    right: 4px;
    padding: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.search-clear svg {
    width: 14px;
    height: 14px;
}

/* Tree View */
.tree-view {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    position: relative;
}

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

.tree-item-content {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 4px;
    gap: 6px;
    color: var(--text-primary);
    position: relative;
}

.tree-item-content:hover {
    background: var(--bg-hover);
}

.tree-item-content.selected {
    background: var(--bg-selected);
    color: var(--text-on-primary);
    font-weight: 500;
}

.tree-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    color: var(--gray-500);
    font-weight: bold;
    transition: transform 0.2s ease;
}

.tree-item-content.selected .tree-icon {
    color: var(--text-on-primary);
}

.tree-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.tree-children {
    margin-left: 16px;
    display: none;
    padding-left: 8px;
    border-left: 1px solid var(--border-light);
}

.tree-children.expanded {
    display: block;
}

/* Make directory items more obvious */
.tree-item[data-type="directory"] > .tree-item-content {
    font-weight: 500;
}

.tree-item[data-type="directory"] > .tree-item-content:hover {
    background: var(--bg-hover);
}

/* Search filtering */
.tree-item.hidden {
    display: none !important;
}

.tree-item.search-match .tree-name {
    background: var(--primary-light);
    border-radius: 3px;
    padding: 2px 4px;
    margin: -2px -4px;
}

/* Drag and drop */
.tree-item-content[draggable="true"] {
    cursor: grab;
}

.tree-item-content[draggable="true"]:active {
    cursor: grabbing;
}

.tree-item-content.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

/* Add subtle indicator that files are draggable */
.tree-item[data-type="file"] .tree-item-content:hover::after {
    content: '⋮⋮';
    position: absolute;
    right: 8px;
    color: var(--text-tertiary);
    font-size: 10px;
    letter-spacing: -2px;
}

.tree-item-content.drag-over {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
    padding-left: 5px;
}

.tree-view.drag-over-root {
    background: var(--primary-light);
    border: 2px dashed var(--primary);
    border-radius: 6px;
}

.tree-view.drag-over-root::before {
    content: 'Drop here to move to root';
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    padding: 12px 20px;
    border-radius: 6px;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Editor View Container */
.editor-view {
    display: flex;
    flex: 1;
    min-width: 0;
}

/* Dashboard View */
.dashboard-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-page);
    min-width: 0;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 0;
    flex-shrink: 0;
}

.dashboard-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.dashboard-usage {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-surface);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
}

.dashboard-usage.at-limit {
    color: var(--danger);
    border-color: var(--danger);
}

.dashboard-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 2px;
}

.dashboard-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.dashboard-view-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.dashboard-view-btn.active {
    background: var(--primary);
    color: var(--text-on-primary);
}

.dashboard-view-btn svg {
    width: 16px;
    height: 16px;
}

.dashboard-grid {
    padding: 20px 24px;
    flex: 1;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.diagram-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.diagram-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.diagram-thumbnail {
    height: 160px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-light);
    padding: 8px;
}

.diagram-thumbnail svg {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.thumbnail-placeholder {
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail-placeholder svg {
    width: 32px;
    height: 32px;
}

.thumbnail-error {
    color: var(--gray-400);
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumbnail-error svg {
    width: 24px;
    height: 24px;
}

.diagram-card-info {
    padding: 12px;
}

.diagram-card-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.diagram-card-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}


.diagram-card-clone {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all 0.2s;
}

.diagram-card-clone:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--primary);
}

.diagram-card-clone svg {
    width: 14px;
    height: 14px;
}

.diagram-card-path {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-folder-group {
    margin-bottom: 24px;
}

.dashboard-folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.dashboard-folder-header:hover {
    color: var(--primary);
}

.dashboard-folder-header svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.dashboard-folder-header:hover svg {
    color: var(--primary);
}

.dashboard-folder-count {
    font-size: 12px;
    font-weight: 400;
    color: var(--text-tertiary);
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 10px;
}

.dashboard-welcome {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--primary);
    border-radius: 6px;
}

.dashboard-welcome > i,
.dashboard-welcome > svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

.dashboard-welcome strong {
    display: block;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.dashboard-welcome p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.dashboard-folder-empty-message {
    font-size: 13px;
    font-style: italic;
    color: var(--text-tertiary);
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px dashed var(--border-light);
    border-radius: 6px;
}

.dashboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
    gap: 12px;
}

.dashboard-empty h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.dashboard-empty p {
    font-size: 14px;
    color: var(--text-secondary);
}

.dashboard-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 12px;
    color: var(--text-secondary);
}

/* Editor Panel */
.editor-panel {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-light);
    min-width: 300px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
}

.panel-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-icon {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-icon-small {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon-small:hover {
    background: var(--bg-hover);
}

.btn-icon-small svg {
    width: 16px;
    height: 16px;
}

/* Breadcrumb Navigation Bar */
.breadcrumb-bar {
    display: flex;
    align-items: center;
    height: 36px;
    padding: 0 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
    gap: 0;
    overflow-x: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

.breadcrumb-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.breadcrumb-home:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.breadcrumb-home svg {
    width: 16px;
    height: 16px;
}

.breadcrumb-separator {
    color: var(--gray-400);
    padding: 0 6px;
    font-size: 12px;
    flex-shrink: 0;
    user-select: none;
}

.breadcrumb-folder {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.breadcrumb-folder:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.breadcrumb-folder svg {
    width: 14px;
    height: 14px;
}

.breadcrumb-current {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 13px;
    flex-shrink: 0;
}

.breadcrumb-current svg {
    width: 14px;
    height: 14px;
}

.breadcrumb-delete-folder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    margin-left: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.breadcrumb-delete-folder:hover {
    background: rgba(248, 113, 113, 0.15);
    color: var(--danger);
}

.breadcrumb-delete-folder svg {
    width: 14px;
    height: 14px;
}

.status {
    font-size: 12px;
    color: var(--text-secondary);
}

.status.modified {
    color: var(--warning);
}

.status.saved {
    color: var(--success);
}

.status.saving {
    color: var(--accent);
}

.status.error {
    color: var(--danger);
}

#editor {
    flex: 1;
    padding: 15px;
    border: none;
    resize: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    background: #F9FAFB;
    color: #1F2937;
}

#editor:focus {
    outline: none;
}

#editor:disabled {
    background: #F3F4F6;
    color: #9CA3AF;
}

.validation-status.invalid {
    color: var(--danger);
}

.validation-errors {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
}

.validation-error {
    padding: 8px;
    margin-top: 6px;
    background: var(--danger-light);
    border-left: 3px solid var(--danger);
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    color: var(--danger);
}

/* Preview Panel */
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 300px;
    background: var(--bg-surface);
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 10px;
    border-right: 1px solid var(--border-light);
}

.theme-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-selector label {
    font-size: 12px;
    color: var(--text-secondary);
}

.theme-selector select {
    padding: 4px 8px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 12px;
    background: var(--bg-surface);
    color: var(--text-primary);
}

.preview-container {
    flex: 1;
    overflow: hidden;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: relative;
}

.preview-placeholder {
    color: var(--text-tertiary, var(--text-secondary));
    font-size: 13px;
    text-align: center;
    padding: 40px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.5;
    user-select: none;
}

.preview-placeholder-icon {
    width: 32px;
    height: 32px;
}

.empty-state {
    max-width: 400px;
    margin: 0 auto;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    color: var(--gray-400);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

.empty-state-tips {
    background: var(--gray-50);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
    text-align: left;
}

.empty-state-tips strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 13px;
}

.empty-state-tips ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.empty-state-tips li {
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.empty-state-tips kbd {
    display: inline-block;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 11px;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin-right: 8px;
    min-width: 60px;
    text-align: center;
}

.preview-error {
    color: var(--danger);
    font-size: 14px;
    padding: 20px;
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: 6px;
    white-space: pre-wrap;
    font-family: monospace;
}

/* Mermaid diagram container */
#preview .mermaid {
    max-width: 100%;
}

#preview svg {
    max-width: none;
    height: auto;
    transition: transform 0.1s ease-out;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-surface);
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 18px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 15px;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-surface);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group input.error {
    border-color: var(--danger);
}

.form-group input.error:focus {
    box-shadow: 0 0 0 3px var(--danger-light);
}

.form-error {
    display: block;
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Confirmation Modal */
.modal-confirm {
    text-align: center;
    max-width: 420px;
}

.confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: var(--danger-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-icon svg {
    width: 32px;
    height: 32px;
    color: var(--danger);
}

.modal-confirm h3 {
    font-size: 20px;
    margin-bottom: 12px;
}

.modal-confirm p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}

.modal-confirm .modal-actions {
    justify-content: center;
}

/* Upgrade Modal */
.modal-upgrade {
    max-width: 480px;
    text-align: center;
    position: relative;
}

.modal-upgrade h3 {
    font-size: 22px;
    margin-bottom: 4px;
}

.upgrade-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

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

.upgrade-subtitle {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.upgrade-plan-toggle {
    display: inline-flex;
    background: var(--bg-page);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 20px;
}

.upgrade-plan-toggle button {
    padding: 8px 20px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.upgrade-plan-toggle button.active {
    background: var(--primary);
    color: var(--text-on-primary);
}

.upgrade-price {
    margin-bottom: 24px;
}

.upgrade-price-amount {
    font-size: 40px;
    font-weight: 700;
    color: var(--text-primary);
}

.upgrade-price-period {
    font-size: 16px;
    color: var(--text-secondary);
}

.upgrade-save-badge {
    display: inline-block;
    background: var(--success);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: super;
}

.upgrade-features {
    text-align: left;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: hidden;
}

.upgrade-feature-row {
    display: grid;
    grid-template-columns: 1fr 80px 100px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    align-items: center;
}

.upgrade-feature-row:last-child {
    border-bottom: none;
}

.upgrade-free {
    text-align: center;
    color: var(--text-tertiary);
}

.upgrade-pro {
    text-align: center;
    color: var(--primary-light);
    font-weight: 600;
}

.upgrade-cta {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
}

/* Pro Badge */
.pro-badge {
    display: inline-block;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    margin-left: 4px;
    vertical-align: middle;
}

/* Context Menu */
.context-menu {
    position: fixed;
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 2500;
    overflow: hidden;
}

.context-menu.show {
    display: block;
}

.context-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background-color 0.2s;
}

.context-menu button svg {
    width: 16px;
    height: 16px;
}

.context-menu button:hover {
    background: var(--bg-hover);
}

.context-menu-danger {
    color: var(--danger) !important;
}

.context-menu-danger:hover {
    background: var(--danger-light) !important;
}

.context-menu-separator {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

.context-menu-item-file,
.context-menu-item-folder {
    display: flex;
}

.context-menu.show-file .context-menu-item-folder {
    display: none;
}

.context-menu.show-folder .context-menu-item-file {
    display: none;
}

.context-menu.protected-folder .context-menu-danger,
.context-menu.protected-folder .context-menu-separator,
.context-menu.protected-file .context-menu-danger,
.context-menu.protected-file .context-menu-item-file {
    display: none;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
}

.toast {
    padding: 12px 20px;
    border-radius: 6px;
    margin-top: 10px;
    color: white;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

.toast.info {
    background: var(--primary);
}

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

/* Loading Spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 900px) {
    .logo-wordmark {
        display: none;
    }

    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

    .editor-view {
        flex-direction: column;
    }

    .editor-panel,
    .preview-panel {
        min-width: auto;
    }

    .dashboard-cards {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Login Page Styles */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container .logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    gap: 0.75rem;
    color: var(--text-primary);
}

.login-container .logo img {
    width: 80px;
    height: 80px;
    margin-bottom: 0;
}

.login-container .logo .logo-wordmark {
    height: 26px;
}

.login-container .logo p {
    font-size: 1.2rem;
    font-weight: 600;
}

.login-container form {
    width: 100%;
    max-width: 360px;
    padding: 2rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.login-container form .form-group {
    margin-bottom: 1.5rem;
}

.login-container form label {
    font-weight: 600;
    color: var(--text-secondary);
}

.login-container form input {
    background: var(--bg-page);
}

.login-container form button[type="submit"] {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    background: var(--primary);
    color: var(--text-on-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.login-container form button[type="submit"]:hover {
    background: var(--primary-dark);
}

.auth-link {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Flash Messages */
.flash-messages {
    width: 100%;
    max-width: 360px;
    margin-bottom: 1rem;
}

.flash-message {
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
}

.flash-message.error {
    background: var(--danger-light);
    color: var(--danger-dark);
    border: 1px solid var(--danger);
}
