/* Writer App Styles - Component-based version */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 1rem;
}

.writer-container {
    max-width: 1400px;
    margin: 20px auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Account for topbar (60px) + body padding (2rem) */
    height: calc(100vh - 60px - 2rem);
}

/* File Header */
.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

#doc-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.file-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #f0f0ff;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
    overflow-x: auto;
}

.tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    background: #f8f8f8;
}

.tab.active {
    background: white;
    border-bottom-color: white;
    font-weight: 600;
}

.tab.dirty .tab-title {
    font-style: italic;
    color: #e74c3c;
}

.tab-close {
    font-size: 1.2rem;
    color: #999;
    cursor: pointer;
    padding: 0 0.25rem;
}

.tab-close:hover {
    color: #e74c3c;
}

/* Editor Wrapper */
.editor-wrapper {
    flex: 1;
    overflow: hidden;
    background: white;
    position: relative;
}

.editor-instance {
    width: 100%;
    height: 100%;
    display: none;
}

.editor-instance[style*="display: flex"] {
    display: flex !important;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 600px;
    min-width: 400px;
    width: fit-content;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

/* File List in Modal */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
    max-height: 400px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.file-item:hover {
    background: #e8e9ea;
    border-color: #667eea;
}

.file-title {
    font-weight: 600;
    color: #333;
}

.file-date {
    font-size: 0.9rem;
    color: #666;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #333;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 10001;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-error {
    background: #e74c3c;
}

.toast.toast-success {
    background: #27ae60;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .writer-container {
        height: 100vh;
        border-radius: 0;
    }
    
    .file-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }
    
    #doc-title {
        font-size: 1.2rem;
    }
    
    .file-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .tabs {
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    .tab {
        padding: 0.4rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .modal-content {
        padding: 1.5rem;
        width: 100%;
        min-width: unset;
    }
    
    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

/* Input Modal */
.input-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.input-modal.active {
    display: flex;
}

.input-modal-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    min-width: 400px;
    max-width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.input-modal h2 {
    margin: 0 0 1.5rem 0;
    color: #333;
    font-size: 1.5rem;
}

.input-modal p {
    margin: 0 0 1.5rem 0;
    color: #555;
    font-size: 1rem;
    line-height: 1.5;
}

.input-modal input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-family: inherit;
}

.input-modal input:focus {
    outline: none;
    border-color: #667eea;
}

.input-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.input-modal .btn {
    padding: 0.75rem 1.5rem;
}
