/* Drive Document Ingestion UI */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f5f5;
  color: #111827;
  line-height: 1.5;
}

/* Unified Header */
.unified-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
}

.unified-header .header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.unified-header .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #ffffff;
}

.unified-header .logo-text {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.unified-header .header-nav {
  display: flex;
  gap: 8px;
}

.unified-header .nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all 0.15s;
}

.unified-header .nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.unified-header .nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

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

.unified-header .user-email {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.unified-header .logout-btn {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.15s;
}

.unified-header .logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

/* Main App Layout */
.drive-app {
  display: flex;
  padding-top: 48px;
  height: 100vh;
}

/* Sidebar */
.drive-sidebar {
  width: 280px;
  background: #ffffff;
  border-right: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #e5e5e5;
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.sort-select {
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #ffffff;
  color: #374151;
  cursor: pointer;
}

.sort-select:focus {
  outline: none;
  border-color: #2563eb;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: #2563eb;
}

.company-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.company-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
}

.company-item:hover {
  background: #f3f4f6;
}

.company-item.active {
  background: #eff6ff;
  color: #1d4ed8;
}

.company-item .folder-icon {
  width: 16px;
  height: 16px;
  color: #9ca3af;
  flex-shrink: 0;
}

.company-item.active .folder-icon {
  color: #2563eb;
}

.company-item .company-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-item .company-date {
  font-size: 10px;
  color: #9ca3af;
  flex-shrink: 0;
  margin-left: 8px;
}

.company-item.active .company-date {
  color: #60a5fa;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid #e5e5e5;
}

.btn-all-docs {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  background: transparent;
  color: #6b7280;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-all-docs:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #374151;
}

.btn-all-docs.active {
  background: #eff6ff;
  border-color: #2563eb;
  border-style: solid;
  color: #1d4ed8;
}

/* Main Content */
.drive-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
}

.header-info h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 2px;
}

.file-count {
  font-size: 13px;
  color: #6b7280;
}

/* Date Filters */
.date-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 12px;
  color: #374151;
}

.date-filters.hidden {
  display: none;
}

.date-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-input {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
}

.btn-small {
  padding: 4px 10px !important;
  font-size: 11px !important;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-primary,
.btn-secondary {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-primary:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.btn-secondary {
  background: #ffffff;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
  background: #f9fafb;
}

.btn-secondary:disabled {
  color: #9ca3af;
  cursor: not-allowed;
}

.btn-icon {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #6b7280;
  border-radius: 4px;
}

.btn-icon:hover {
  background: #f3f4f6;
  color: #374151;
}

/* Files Container */
.files-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #9ca3af;
}

.empty-state svg {
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 14px;
}

.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #6b7280;
  font-size: 14px;
}

/* File Tree */
.file-tree {
  font-size: 13px;
}

.tree-item {
  display: flex;
  align-items: flex-start;
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 2px;
}

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

.tree-item.folder {
  font-weight: 500;
  color: #374151;
}

.tree-item.file {
  color: #4b5563;
}

.tree-item.not-extractable {
  color: #9ca3af;
}

.tree-checkbox {
  margin-right: 8px;
  margin-top: 2px;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.tree-checkbox:disabled {
  cursor: not-allowed;
}

.tree-icon {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  flex-shrink: 0;
}

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

.tree-link {
  color: inherit;
  text-decoration: none;
}

.tree-link:hover {
  color: #2563eb;
  text-decoration: underline;
}

.tree-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 8px;
  font-size: 12px;
  color: #9ca3af;
  flex-shrink: 0;
}

.file-type-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  background: #f3f4f6;
  color: #6b7280;
}

.file-type-badge.extractable {
  background: #dcfce7;
  color: #166534;
}

/* Uploaded indicator */
.uploaded-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: #dbeafe;
  color: #1e40af;
}

.uploaded-badge svg {
  width: 12px;
  height: 12px;
}

/* Company badge in all docs view */
.company-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: #f3e8ff;
  color: #7c3aed;
  white-space: nowrap;
}

.indent-1 { padding-left: 24px; }
.indent-2 { padding-left: 48px; }
.indent-3 { padding-left: 72px; }
.indent-4 { padding-left: 96px; }
.indent-5 { padding-left: 120px; }

/* Status Panel */
.drive-status {
  width: 300px;
  background: #ffffff;
  border-left: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e5e5;
}

.status-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.status-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.no-jobs {
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  padding: 40px 20px;
}

.job-card {
  background: #f9fafb;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.job-company {
  font-weight: 500;
  font-size: 13px;
}

.job-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.job-status.running {
  background: #fef3c7;
  color: #92400e;
}

.job-status.completed {
  background: #dcfce7;
  color: #166534;
}

.job-status.failed {
  background: #fee2e2;
  color: #991b1b;
}

.job-status.cancelled {
  background: #f3f4f6;
  color: #6b7280;
}

.btn-cancel-job {
  margin-left: auto;
  padding: 2px 6px;
  background: transparent;
  border: 1px solid #dc2626;
  color: #dc2626;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.btn-cancel-job:hover {
  background: #fee2e2;
}

.job-progress-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.job-progress-fill {
  height: 100%;
  background: #2563eb;
  transition: width 0.3s;
}

.job-meta {
  font-size: 12px;
  color: #6b7280;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.progress-info {
  margin-bottom: 16px;
}

.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: #2563eb;
  transition: width 0.3s;
}

.progress-text {
  text-align: center;
  font-size: 13px;
  color: #6b7280;
}

.progress-logs {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  line-height: 1.6;
  color: #d1d5db;
}

.progress-logs .log-line {
  margin-bottom: 2px;
}

.progress-logs .log-error {
  color: #f87171;
}

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

/* Responsive */
@media (max-width: 1024px) {
  .drive-status {
    display: none;
  }
}

@media (max-width: 768px) {
  .drive-sidebar {
    width: 220px;
  }

  .header-actions {
    flex-wrap: wrap;
  }
}
