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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* Header */
.header {
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header h1 i {
    margin-right: 0.5rem;
    color: #3498db;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-box {
    display: flex;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.search-box input {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: white;
    width: 300px;
}

.search-box input::placeholder {
    color: rgba(255,255,255,0.6);
}

.search-box button {
    padding: 0.5rem 1rem;
    border: none;
    background: #3498db;
    color: white;
    cursor: pointer;
}

.search-box button:hover {
    background: #2980b9;
}

.btn-icon {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.1);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.sync-status i {
    color: #2ecc71;
    font-size: 0.6rem;
    animation: pulse 2s infinite;
}

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

/* Container */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    min-height: calc(100vh - 120px);
}

/* Sidebar */
.sidebar {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: fit-content;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sidebar-header h3 {
    font-size: 1.2rem;
    color: #2c3e50;
}

.btn-small {
    padding: 0.4rem 0.8rem;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-small:hover {
    background: #2980b9;
}

.category-filter {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-btn {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.filter-btn:hover {
    background: #f5f7fa;
}

.filter-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* Tree */
.tree {
    font-size: 0.9rem;
}

.tree-item {
    padding: 0.5rem;
    margin: 0.25rem 0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.tree-item:hover {
    background: #f5f7fa;
}

.tree-item.active {
    background: #e3f2fd;
    color: #2196f3;
}

.tree-item i {
    margin-right: 0.5rem;
    width: 16px;
}

.tree-children {
    margin-left: 1.5rem;
}

/* Main Content */
.main-content {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.welcome {
    text-align: center;
    padding: 3rem 0;
}

.welcome i {
    font-size: 4rem;
    color: #3498db;
    margin-bottom: 1rem;
}

.welcome h2 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.welcome p {
    color: #7f8c8d;
    margin-bottom: 2rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.stat-card i {
    font-size: 2rem;
    color: #3498db;
}

.stat-card h4 {
    font-size: 2rem;
    color: #2c3e50;
}

.stat-card p {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Object View */
.object-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 1.5rem;
}

.object-header h2 {
    color: #2c3e50;
}

.object-header .badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge.active {
    background: #d4edda;
    color: #155724;
}

.badge.draft {
    background: #fff3cd;
    color: #856404;
}

.badge.archived {
    background: #f8d7da;
    color: #721c24;
}

.object-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.meta-item {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.meta-item strong {
    display: block;
    color: #7f8c8d;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.document-card {
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.document-card:hover {
    background: #e9ecef;
    border-color: #3498db;
}

.document-card h4 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.document-card .folder {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #3498db;
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
}

.document-card .meta {
    color: #7f8c8d;
    font-size: 0.85rem;
}

/* Search Results */
.search-results h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.search-result {
    padding: 1rem;
    margin-bottom: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 4px solid #3498db;
}

.search-result h4 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.search-result .path {
    color: #7f8c8d;
    font-size: 0.9rem;
}

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

.modal.show {
    display: block;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

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

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

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

.toast.success {
    border-left: 4px solid #2ecc71;
}

.toast.error {
    border-left: 4px solid #e74c3c;
}

.toast.info {
    border-left: 4px solid #3498db;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: #7f8c8d;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: none;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .search-box input {
        width: 200px;
    }
}

/* === TOOLS SIDEBAR === */

.tools-container {
    width: 250px;
    background: white;
    border-left: 1px solid #e0e0e0;
    padding: 20px;
    overflow-y: auto;
}

.tools-sidebar h3 {
    font-size: 18px;
    margin: 0 0 10px 0;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-project-name {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 20px;
    padding: 8px;
    background: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-category {
    margin-bottom: 20px;
}

.tool-category h4 {
    font-size: 14px;
    margin: 0 0 10px 0;
    color: #34495e;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #2c3e50;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
    transform: translateX(2px);
}

.tool-btn i {
    width: 20px;
    text-align: center;
}

.tools-sidebar .text-muted {
    font-size: 13px;
    color: #95a5a6;
    text-align: center;
    padding: 20px;
}

/* === CLAUDE AI MODAL === */

.claude-modal-content {
    display: flex;
    flex-direction: column;
    height: 600px;
    max-height: 80vh;
}

.claude-header {
    display: flex;
    justify-items: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.claude-header h3 {
    margin: 0;
    flex: 1;
    font-size: 18px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.claude-header .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #95a5a6;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.claude-header .close-btn:hover {
    background: #ecf0f1;
    color: #2c3e50;
}

.claude-chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.claude-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
}

.claude-welcome p {
    margin: 10px 0;
}

.claude-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s;
}

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

.claude-message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.claude-message.user .message-avatar {
    background: #3498db;
    color: white;
}

.claude-message.assistant .message-avatar {
    background: #9b59b6;
    color: white;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
}

.claude-message.user .message-content {
    background: #3498db;
    color: white;
    border-top-right-radius: 4px;
}

.claude-message.assistant .message-content {
    background: white;
    color: #2c3e50;
    border: 1px solid #e0e0e0;
    border-top-left-radius: 4px;
}

.claude-input-area {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: white;
    display: flex;
    gap: 10px;
}

.claude-input-area textarea {
    flex: 1;
    padding: 10px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
}

.claude-input-area textarea:focus {
    outline: none;
    border-color: #3498db;
}

.claude-input-area .send-btn {
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: background 0.2s;
}

.claude-input-area .send-btn:hover {
    background: #2980b9;
}

/* Update container layout to accommodate tools sidebar */
.container {
    display: grid;
    grid-template-columns: 250px 250px 1fr;
    height: calc(100vh - 60px);
    overflow: hidden;
}

.sidebar, .tools-container {
    overflow-y: auto;
}

.main-content {
    overflow-y: auto;
}

/* === SIDEBAR COLLAPSE/EXPAND === */

.sidebar-collapse-btn {
    position: absolute;
    top: 50%;
    right: -12px;
    transform: translateY(-50%);
    width: 24px;
    height: 60px;
    background: #3498db;
    border: none;
    border-radius: 0 8px 8px 0;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.sidebar-collapse-btn:hover {
    background: #2980b9;
    width: 28px;
}

.tools-container .sidebar-collapse-btn {
    left: -12px;
    right: auto;
    border-radius: 8px 0 0 8px;
}

/* Sidebar positioning */
.sidebar, .tools-container {
    position: relative;
    transition: all 0.3s ease;
}

/* Collapsed state for Categories sidebar */
.sidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    overflow: visible !important; /* Changed from hidden to visible */
    border: none;
}

.sidebar.collapsed .sidebar-collapse-btn {
    right: 0;
    border-radius: 8px;
    transform: translateY(-50%) translateX(100%);
}

.sidebar.collapsed .sidebar-collapse-btn i::before {
    content: "\f054"; /* fa-chevron-right */
}

/* Collapsed state for Tools sidebar */
.tools-container.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    overflow: visible !important; /* Changed from hidden to visible */
    border: none;
}

.tools-container.collapsed .sidebar-collapse-btn {
    left: 0;
    border-radius: 8px;
    transform: translateY(-50%) translateX(-100%);
}

.tools-container.collapsed .sidebar-collapse-btn i::before {
    content: "\f053"; /* fa-chevron-left */
}

/* Adjust container grid when sidebars are collapsed */
.container {
    transition: grid-template-columns 0.3s ease;
}

.container.categories-collapsed {
    grid-template-columns: 0 250px 1fr !important;
}

.container.tools-collapsed {
    grid-template-columns: 250px 0 1fr !important;
}

.container.both-collapsed {
    grid-template-columns: 0 0 1fr !important;
}
