/* docresult.css - Complete document editor with formatresult style */

/* ===== Base Layout ===== */
.doc-main {
    padding: 0.5rem 0.5rem;
    background: var(--bg-page);
    min-height: 100vh;
}

.doc-container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    border: 1px solid var(--border-light);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ===== Document Header ===== */
.doc-header {
    background: linear-gradient(135deg, var(--accent-soft), transparent);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-light);
}

.doc-header-content h1 {
    margin: 0 0 1rem 0;
    font-size: 1.8rem;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--accent), var(--text-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.doc-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.metadata-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.metadata-item i {
    color: var(--accent);
    font-size: 0.9rem;
}

/* ===== Action Bar ===== */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    scrollbar-width: thin;
}

.action-bar::-webkit-scrollbar {
    height: 1px;
}

.action-bar::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 3px;
}

.action-bar::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.action-bar-wrapper {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
}

.action-bar-wrapper::-webkit-scrollbar {
    height: 4px;
}

.action-bar-wrapper::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 4px;
}

.action-bar-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

.action-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    align-items: center;
    flex-shrink: 0;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border-light);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    white-space: nowrap;
    flex-shrink: 0;
}

.action-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

.action-btn i {
    font-size: 0.9rem;
}

.action-btn#deleteBtn:hover {
    background: #fee2e2;
    border-color: #dc2626;
    color: #dc2626;
}


/* ===== Regenerate Inline Input ===== */
.regenerate-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.regenerate-input {
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--border-light);
    border-radius: 2rem;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 220px;
    transition: border-color 0.2s;
}

.regenerate-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.regenerate-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

/* ===== Formatting Toolbar ===== */
.formatting-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 10;
    align-items: center;
}

.format-group {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    flex-wrap: wrap;
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-light);
    margin: 0 0.5rem;
}

.format-btn {
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.format-btn:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.format-select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.format-select:hover {
    border-color: var(--accent);
}

/* ===== Editor Wrapper ===== */
.editor-wrapper {
    background: var(--surface);
    min-height: 60vh;
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem;
}

.editor-content {
    min-height: 500px;
    outline: none;
    font-family: inherit;
    line-height: 1.6;
    color: var(--text-primary);
    padding: 1rem;
    background: var(--surface);
    border-radius: 0.75rem;
    transition: all 0.2s;
}

.editor-content:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent-soft);
}

/* Editor Typography */
.editor-content h1 {
    font-size: 2rem;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
    margin: 1rem 0;
}
.editor-content h2 {
    font-size: 1.5rem;
    margin: 1rem 0;
}
.editor-content h3 {
    font-size: 1.25rem;
    margin: 0.75rem 0;
}
.editor-content h4 {
    font-size: 1.1rem;
    margin: 0.5rem 0;
    color: var(--accent);
}
.editor-content p {
    margin: 0.75rem 0;
}
.editor-content ul, .editor-content ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}
.editor-content li {
    margin: 0.25rem 0;
}
.editor-content blockquote {
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
    padding: 0.5rem 1rem;
    margin: 0.75rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
}
.editor-content a {
    color: var(--accent);
    text-decoration: underline;
}
.editor-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    overflow-x: auto;
    display: block;
}
.editor-content th, .editor-content td {
    border: 1px solid var(--border-light);
    padding: 0.5rem;
    text-align: left;
}
.editor-content th {
    background: var(--accent-soft);
}
.editor-content img {
    max-width: 100%;
    height: auto;
}
.editor-content pre {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
}
.editor-content code {
    font-family: monospace;
    background: var(--accent-soft);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
}

/* ===== Status Bar ===== */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border-light);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-left, .status-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.separator {
    color: var(--border-light);
}

#saveStatus {
    color: var(--accent);
}

#saveStatus.saving {
    color: #f59e0b;
}

#saveStatus.saved {
    color: var(--accent);
}

/* ===== Share Modal ===== */
.share-modal-content {
    max-width: 500px;
}

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

.modal-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.share-link-container {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.share-link-container input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.share-options {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.share-option {
    background: var(--surface);
    border: 1px solid var(--border-light);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.share-option:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* ===== Regenerate Modal ===== */
#regenerateModal .modal-content {
    max-width: 500px;
    padding: 1.5rem;
}

#regenerateModal textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--border-light);
    border-radius: 0.6rem;
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    font-size: 0.9rem;
}

#regenerateModal textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ===== Loading State ===== */
.loading-editor {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* ===== Toast ===== */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    background: var(--surface);
    border-left: 4px solid var(--accent);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    animation: slideUp 0.3s ease;
    color: var(--text-primary);
}

.toast.success { border-left-color: var(--accent); }
.toast.error { border-left-color: #dc2626; }
.toast.warning { border-left-color: #f59e0b; }
.toast.info { border-left-color: #3b82f6; }

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Public Toggle ===== */
.public-toggle {
    display: flex;
    align-items: center;
    margin-left: auto;
}
.switch-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 26px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--accent);
}
input:checked + .slider:before {
    transform: translateX(26px);
}
.slider.round {
    border-radius: 34px;
}
.slider.round:before {
    border-radius: 50%;
}

.editor-content[contenteditable="false"] {
    background: var(--surface);
    cursor: default;
    opacity: 0.9;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .action-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .action-bar-wrapper {
        width: 100%;
        overflow-x: auto;
        gap: 0.75rem;
    }
    
    .action-group {
        flex-shrink: 0;
    }
    
    .action-btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.8rem;
    }
    
    .doc-header {
        padding: 1rem;
    }
    
    .doc-header-content h1 {
        font-size: 1.4rem;
    }
    
    .formatting-toolbar {
        overflow-x: auto;
        flex-wrap: nowrap;
        white-space: nowrap;
    }
    
    .format-group {
        flex-shrink: 0;
    }
    
    .editor-wrapper {
        max-height: 50vh;
    }
    
    .status-bar {
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .doc-metadata {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-btn span:not(.icon-only) {
        display: none;
    }
    
    .action-btn i {
        margin-right: 0;
    }
    
    .action-btn {
        padding: 0.5rem 0.8rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    .navbar,
    .action-bar,
    .formatting-toolbar,
    .status-bar,
    .profile-dropdown,
    .theme-toggle,
    .home-icon,
    .icon-btn {
        display: none !important;
    }
    
    .doc-container {
        box-shadow: none;
        border: none;
        background: white;
    }
    
    .doc-header {
        background: none;
        border-bottom: 1px solid #ddd;
    }
    
    .editor-wrapper {
        overflow: visible;
        max-height: none;
    }
    
    .editor-content {
        padding: 0;
    }
}
