/* Message Content Styles */
.message-content {
    word-wrap: break-word;
}

.message-content.markdown-content {
    white-space: normal;
}

/* Markdown Content Styles */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 0.5em 0 0.3em 0;
    font-weight: 600;
}

.markdown-content h1 { font-size: 1.5em; }
.markdown-content h2 { font-size: 1.3em; }
.markdown-content h3 { font-size: 1.1em; }

.markdown-content p {
    margin: 0.5em 0;
}

.markdown-content ul,
.markdown-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.markdown-content li {
    margin: 0.25em 0;
}

.markdown-content code {
    background-color: #f0f0f0;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.markdown-content pre {
    background-color: #f6f8fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1em;
    overflow-x: auto;
    margin: 0.5em 0;
}

.markdown-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

.markdown-content blockquote {
    border-left: 4px solid #ddd;
    margin: 0.5em 0;
    padding-left: 1em;
    color: #666;
}

.markdown-content table {
    border-collapse: collapse;
    margin: 0.5em 0;
}

.markdown-content table th,
.markdown-content table td {
    border: 1px solid #ddd;
    padding: 0.5em;
}

.markdown-content table th {
    background-color: #f6f8fa;
}

.markdown-content strong {
    font-weight: 600;
}

.markdown-content em {
    font-style: italic;
}

.markdown-content a {
    color: #0969da;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* Sidebar Styles */
#sidebar {
    width: 16rem; /* w-64 */
    transition: width 0.3s ease;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

#sidebar.collapsed {
    width: 0;
    transition: none; /* No animation when fully collapsed */
}

#collapseBtnIcon {
    transition: transform 0.3s ease;
}

#sidebar.collapsed #collapseBtnIcon {
    transform: rotate(180deg);
}

/* Ensure app container can position absolute handles */
#app { 
    position: relative; 
}

/* Resize handle */
.sidebar-resize-handle {
    position: absolute;
    right: -2px;
    top: 0;
    bottom: 0;
    width: 12px;
    background-color: rgba(59,130,246,0.06); /* subtle light-blue visible area */
    cursor: col-resize;
    z-index: 10;
    pointer-events: auto;
    user-select: none;
    touch-action: none;
}

.sidebar-resize-handle:hover {
    background-color: #c7d2fe;
}

.sidebar-resize-handle.dragging {
    background-color: #6366f1;
}

/* Visible handle shown when sidebar is collapsed so user can expand/drag */
.sidebar-toggle-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background-color: rgba(59,130,246,0.12); /* subtle light-blue hint */
    cursor: col-resize;
    z-index: 50;
    display: none; /* shown via JS when needed */
    touch-action: none;
    box-shadow: -1px 0 0 rgba(59,130,246,0.18) inset;
}

/* visible centered bar inside the handle for better affordance */
.sidebar-toggle-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 36px;
    background: rgba(59,130,246,0.92); /* prominent light-blue bar */
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
}

/* Authentication Modal */
.auth-message {
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 8px;
    font-size: 14px;
}

.auth-message.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.auth-message.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.auth-message.info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    gap: 1rem;
}

/* Spinner Components */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton Screens */
.skeleton-item {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
    height: 4rem;
    margin-bottom: 0.5rem;
}

.skeleton-stat {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.25rem;
    height: 1.5rem;
    width: 4rem;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading States */
.loading-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    color: #6b7280;
}

/* Upload Progress States */
.file-uploading {
    opacity: 0.75;
    background: linear-gradient(90deg, #dbeafe 25%, #93c5fd 50%, #dbeafe 75%);
    background-size: 200% 100%;
    animation: uploading-shimmer 2s ease-in-out infinite;
    border: 1px solid #3b82f6;
}

.file-deleting {
    opacity: 0.6;
    background: linear-gradient(90deg, #fee2e2 25%, #fecaca 50%, #fee2e2 75%);
    background-size: 200% 100%;
    animation: deleting-shimmer 1.5s ease-in-out infinite;
    border: 1px solid #ef4444;
    pointer-events: none;
}

.file-error {
    background: #fee2e2;
    border: 1px solid #ef4444;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-uploading {
    background: #dbeafe;
    color: #1e40af;
}

.status-deleting {
    background: #fee2e2;
    color: #991b1b;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

.status-paused {
    background: #f3f4f6;
    color: #6b7280;
}

@keyframes uploading-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes deleting-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    font-size: 0.875rem;
    animation: toast-slide-in 0.3s ease-out;
    min-width: 300px;
}

.toast.toast-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.toast.toast-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.toast.toast-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-weight: 500;
}

.toast-close {
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
    padding: 0.25rem;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.toast-hiding {
    animation: toast-slide-out 0.3s ease-in forwards;
}

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Cloud Storage Modal Styles */
.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 0.5rem;
    padding: 2rem;
    max-width: 28rem;
    width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #1f2937;
}

.modal-content p {
    margin: 0.5rem 0;
    color: #4b5563;
}

.modal-content ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
    color: #4b5563;
}

.modal-content li {
    margin: 0.25rem 0;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.btn-primary {
    flex: 1;
    padding: 0.5rem 1rem;
    background-color: #4f46e5;
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #4338ca;
}

.btn-secondary {
    flex: 1;
    padding: 0.5rem 1rem;
    background-color: #e5e7eb;
    color: #374151;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

/* Cloud Storage UI Styles */
.connection-card {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1rem;
    background: white;
}

.connection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.connection-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.connection-email {
    color: #6b7280;
    font-size: 0.875rem;
}

.connection-status {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.connection-status.active {
    background-color: #d1fae5;
    color: #065f46;
}

.connection-status.inactive {
    background-color: #fee2e2;
    color: #991b1b;
}

.connection-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-danger {
    padding: 0.5rem 1rem;
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.monitored-items {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.monitored-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.item-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.item-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}

.btn-icon:hover {
    opacity: 0.7;
}

.clickable {
    cursor: pointer;
    color: #4f46e5;
}

.clickable:hover {
    text-decoration: underline;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge.monitored {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Unified Panel Styles */
.unified-panel-section {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow flex items to shrink below content size */
}

.unified-panel-section h3 {
    flex-shrink: 0;
}

/* Drive sync panel states */
.drive-sync-connected {
    /* Connected state styling */
}

.drive-sync-disconnected {
    text-align: center;
    padding: 1rem;
}

.drive-sync-disconnected p {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Monitored item compact style for panel */
.monitored-item-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.monitored-item-compact .item-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.monitored-item-compact .item-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.monitored-item-compact .item-meta {
    font-size: 0.75rem;
    color: #6b7280;
}

.monitored-item-compact .item-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.monitored-item-compact .btn-icon-sm {
    padding: 0.125rem;
    font-size: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.7;
}

.monitored-item-compact .btn-icon-sm:hover {
    opacity: 1;
}

.monitored-item-compact .btn-icon-sm.btn-delete {
    color: #ef4444;
}

.monitored-item-compact .btn-icon-sm.btn-delete:hover {
    color: #dc2626;
}

/* Drive status indicator - inline header version */
.drive-header-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.drive-header-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    flex-shrink: 0;
}

.drive-header-status .status-email {
    color: #374151;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Drive header actions container */
.drive-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Upload button in header */
.btn-upload-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-upload-header:hover {
    background: #4f46e5;
}

.btn-upload-header svg {
    width: 14px;
    height: 14px;
}

/* Sync button in header */
.btn-sync-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-sync-header:hover {
    background: #4f46e5;
}

.btn-sync-header svg {
    width: 14px;
    height: 14px;
}

/* Drive status indicator - block version (for disconnected state) */
.drive-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f0fdf4;
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.drive-status.disconnected {
    background: #fef2f2;
}

.drive-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
}

.drive-status.disconnected .status-dot {
    background: #ef4444;
}

/* Panel footer actions */
.drive-panel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}

.drive-panel-footer .btn-sync {
    padding: 0.375rem 0.75rem;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.drive-panel-footer .btn-sync:hover {
    background: #4338ca;
}

.drive-panel-footer .btn-settings {
    padding: 0.375rem;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
}

.drive-panel-footer .btn-settings:hover {
    background: #f3f4f6;
    color: #374151;
}

/* ============================================
   Tag System Styles
   ============================================ */

/* Tags container within file items */
.file-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 0.5rem;
    align-items: center;
}

/* Individual tag badge */
.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.15s;
}

.tag-badge:hover {
    background: #c7d2fe;
}

.tag-badge .tag-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-badge .tag-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 0.125rem;
    background: none;
    border: none;
    color: #6366f1;
    cursor: pointer;
    border-radius: 50%;
    width: 14px;
    height: 14px;
    transition: all 0.15s;
}

.tag-badge .tag-remove:hover {
    background: #4338ca;
    color: white;
}

/* Add tag button */
.add-tag-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: transparent;
    color: #6b7280;
    border: 1px dashed #d1d5db;
    border-radius: 9999px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.add-tag-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #374151;
}

/* Tag selector dropdown */
.tag-selector-dropdown {
    position: fixed;
    z-index: 1000;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    min-width: 200px;
    max-width: 280px;
    overflow: hidden;
}

.tag-selector-header {
    padding: 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.tag-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

.tag-search-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.tag-selector-list {
    max-height: 200px;
    overflow-y: auto;
}

.tag-selector-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.tag-selector-item:hover {
    background: #f3f4f6;
}

.tag-selector-item .tag-name {
    font-size: 0.875rem;
    color: #374151;
}

.tag-selector-item .tag-count {
    font-size: 0.75rem;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
}

.tag-selector-empty {
    padding: 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.875rem;
}

.tag-selector-footer {
    padding: 0.5rem;
    border-top: 1px solid #f3f4f6;
    background: #fafafa;
}

.create-tag-btn {
    width: 100%;
    padding: 0.5rem;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s;
}

.create-tag-btn:hover {
    background: #4338ca;
}

/* Search hint for tag syntax */
.search-tag-hint {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
    padding-left: 0.25rem;
}

.search-tag-hint code {
    background: #f3f4f6;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: monospace;
    color: #6366f1;
}
