/* ======================================
   CollabCoder - Collaborative Document Coding Tool
   Comprehensive CSS with Mobile Responsiveness
   ====================================== */

/* ======================================
   CSS Variables & Root Styles
   ====================================== */

:root {
  --primary: #4285F4;
  --primary-dark: #3367D6;
  --danger: #EA4335;
  --success: #34A853;
  --bg: #ffffff;
  --bg-light: #f8f9fa;
  --border: #e0e0e0;
  --text: #202124;
  --text-secondary: #5f6368;
  --sidebar-width: 260px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 3px 6px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15), 0 3px 6px rgba(0, 0, 0, 0.10);
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.3s ease-in-out;
}

/* ======================================
   General Reset & Typography
   ====================================== */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-light);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
  transition: background var(--transition-normal);
}

::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5em;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

p {
  margin-bottom: 1em;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-dark);
}

/* ======================================
   Buttons
   ====================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-secondary {
  background-color: var(--bg-light);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg);
  border-color: var(--text-secondary);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background-color: #d33425;
  box-shadow: var(--shadow-md);
}

.btn-success {
  background-color: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background-color: #2d8659;
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
}

.btn-delete-sm {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 4px;
  background-color: transparent;
  color: var(--text-secondary);
  font-size: 1.25rem;
  font-weight: bold;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.btn-delete-sm:hover {
  background-color: var(--bg-light);
  color: var(--text);
  border-color: var(--border);
}

.btn-delete-sm.confirm-delete {
  background-color: var(--danger);
  color: white;
  border-color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ======================================
   Forms & Inputs
   ====================================== */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background-color: var(--bg);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

textarea {
  resize: vertical;
  font-family: 'Monaco', 'Courier New', monospace;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

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

.form-group:last-child {
  margin-bottom: 0;
}

/* ======================================
   Status Messages
   ====================================== */

.status {
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideDown var(--transition-normal) ease-in-out;
}

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

.status.error {
  background-color: #fce8e6;
  color: #c5221f;
  border-left: 4px solid var(--danger);
}

.status.success {
  background-color: #e6f4ea;
  color: #1b8917;
  border-left: 4px solid var(--success);
}

.status.info {
  background-color: #e8f0fe;
  color: #1f2937;
  border-left: 4px solid var(--primary);
}

.status.warning {
  background-color: #fef3c7;
  color: #92400e;
  border-left: 4px solid #f59e0b;
}

/* ======================================
   Toggle Switch
   ====================================== */

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 36px;
  height: 20px;
  background-color: #ccc;
  border-radius: 10px;
  transition: background-color var(--transition-fast);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background-color: white;
  border-radius: 50%;
  transition: left var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider {
  background-color: var(--success);
}

.toggle-switch input[type="checkbox"]:checked + .toggle-slider::after {
  left: 18px;
}

.toggle-label {
  font-weight: 500;
  color: var(--text);
}

/* ======================================
   Auth Section
   ====================================== */

#auth-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
  background-color: var(--bg);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.auth-header {
  padding: 2rem 2rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.auth-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  color: var(--primary);
}

.auth-header p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.95rem;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 1rem;
  text-align: center;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
}

.auth-tab:hover {
  color: var(--text);
  background-color: var(--bg-light);
}

.auth-tab.active {
  color: var(--primary);
}

.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--primary);
}

.auth-content {
  padding: 2rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all var(--transition-normal);
}

.auth-content.active {
  max-height: 1000px;
  opacity: 1;
}

.auth-content .form-group {
  margin-bottom: 1.25rem;
}

.auth-content .btn-primary {
  width: 100%;
  margin-top: 1rem;
}

.auth-footer {
  padding: 0 2rem 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  font-weight: 500;
}

/* ======================================
   Dashboard
   ====================================== */

#dashboard {
  min-height: 100vh;
  background-color: var(--bg-light);
}

.top-bar {
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.dashboard-content {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-header {
  margin-bottom: 2rem;
}

.dashboard-header h1 {
  margin: 0 0 0.5rem 0;
}

.dashboard-header p {
  color: var(--text-secondary);
  margin: 0;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.project-card {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  transition: all var(--transition-normal);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.project-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-normal);
}

.project-card:hover::before {
  transform: scaleX(1);
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.project-card h3 {
  margin: 0;
  flex: 1;
  word-break: break-word;
}

.project-card-delete {
  flex-shrink: 0;
  margin-left: 1rem;
}

.project-card p {
  margin: 0.5rem 0 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.project-card-meta {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.project-card-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.create-project-row {
  background-color: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  transition: all var(--transition-normal);
  cursor: pointer;
}

.create-project-row:hover {
  border-color: var(--primary);
  background-color: var(--bg-light);
}

.create-project-row h3 {
  color: var(--primary);
  margin: 0 0 0.5rem 0;
}

.create-project-row p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.9rem;
}

/* ======================================
   Project Detail Section
   ====================================== */

#project-detail {
  min-height: 100vh;
  background-color: var(--bg-light);
}

.project-detail-content {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.detail-section {
  background-color: var(--bg);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.detail-section h2 {
  margin-top: 0;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--primary);
}

.detail-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.document-list,
.tag-list,
.collaborator-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.document-item,
.tag-item,
.collaborator-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background-color: var(--bg-light);
  border-radius: 4px;
  border: 1px solid var(--border);
  transition: all var(--transition-fast);
}

.document-item:hover,
.tag-item:hover,
.collaborator-item:hover {
  background-color: var(--bg);
  border-color: var(--primary);
}

.document-item-content,
.tag-item-content,
.collaborator-item-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.tag-color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.document-link {
  font-weight: 500;
  color: var(--primary);
  flex: 1;
}

.document-link:hover {
  text-decoration: underline;
}

.tag-name {
  font-weight: 500;
  flex: 1;
}

.tag-count {
  background-color: var(--primary);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.75rem;
}

.collaborator-name {
  font-weight: 500;
}

.collaborator-role {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-left: 1rem;
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  transition: all var(--transition-normal);
  background-color: var(--bg-light);
}

.upload-area.drag-over {
  border-color: var(--primary);
  background-color: rgba(66, 133, 244, 0.05);
}

.upload-area h4 {
  margin: 0 0 0.5rem 0;
}

.upload-area p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.9rem;
}

.upload-input {
  display: none;
}

.bulk-import-textarea {
  min-height: 200px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 0.85rem;
}

.import-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ======================================
   Document Viewer Section
   ====================================== */

#viewer {
  height: 100vh;
  background-color: var(--bg-light);
  display: flex;
  flex-direction: column;
}

.viewer-toolbar {
  background-color: var(--primary);
  color: white;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  flex-wrap: wrap;
  gap: 1rem;
}

.viewer-toolbar h2 {
  margin: 0;
  font-size: 1.25rem;
}

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

.sidebar-toggle {
  background-color: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background-color var(--transition-fast);
}

.sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.viewer-container {
  display: -webkit-flex;
  display: flex;
  -webkit-flex: 1;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.viewer-sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background-color: var(--bg);
  overflow-y: auto;
  padding: 1.5rem;
  flex-shrink: 0;
  -webkit-flex-shrink: 0;
}

.viewer-sidebar.left {
  border-right: 1px solid var(--border);
}

.viewer-sidebar.right {
  border-left: 1px solid var(--border);
}

/* On desktop, hide the toggle buttons since sidebars are always visible */
.sidebar-toggle {
  display: none;
}

.sidebar-section {
  margin-bottom: 2rem;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  font-weight: 600;
  margin: 0 0 1rem 0;
  letter-spacing: 0.5px;
}

.tag-items-list,
.highlights-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tag-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.tag-list-item:hover {
  background-color: var(--bg-light);
}

.tag-list-item.active {
  background-color: var(--primary);
  color: white;
}

.tag-list-item.active .tag-list-dot {
  border-color: rgba(255, 255, 255, 0.5);
}

.tag-list-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.tag-list-name {
  flex: 1;
  font-weight: 500;
  font-size: 0.9rem;
}

.tag-list-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.tag-list-item.active .tag-list-count {
  color: rgba(255, 255, 255, 0.8);
}

.highlight-item {
  background-color: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  transition: all var(--transition-fast);
}

.highlight-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.highlight-item-text {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  font-style: italic;
  word-break: break-word;
}

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

.viewer-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  overflow: hidden;
}

.document-wrapper {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.line-numbers {
  padding: 1.5rem 12px 1.5rem 1rem;
  border-right: 1px solid var(--border);
  margin-right: 16px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-secondary);
  text-align: right;
  -webkit-user-select: none;
  user-select: none;
  white-space: pre-wrap;
  flex-shrink: 0;
  width: 50px;
}

.document-text {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.5rem 1.5rem 0;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.highlight {
  position: relative;
  background-color: rgba(255, 193, 7, 0.35);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.highlight:hover {
  background-color: rgba(255, 193, 7, 0.5);
}

.highlight.tag-1 {
  background-color: rgba(66, 133, 244, 0.35);
}

.highlight.tag-1:hover {
  background-color: rgba(66, 133, 244, 0.5);
}

.highlight.tag-2 {
  background-color: rgba(52, 168, 83, 0.35);
}

.highlight.tag-2:hover {
  background-color: rgba(52, 168, 83, 0.5);
}

.highlight.tag-3 {
  background-color: rgba(234, 67, 53, 0.35);
}

.highlight.tag-3:hover {
  background-color: rgba(234, 67, 53, 0.5);
}

.highlight-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.note-indicator {
  display: inline;
  position: relative;
  text-decoration: underline dotted var(--primary);
  text-underline-offset: 2px;
  cursor: help;
}

/* Right sidebar toggles */
.visibility-toggle-row,
.stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background-color: var(--bg-light);
  border-radius: 4px;
  font-size: 0.9rem;
}

.visibility-toggle-row label,
.stats-row label {
  margin-bottom: 0;
}

.tag-filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 0.25rem;
}

.tag-filter-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.stats-value {
  font-weight: 600;
  color: var(--primary);
  font-size: 1.1rem;
}

/* ======================================
   Tag Popup
   ====================================== */

.tag-popup {
  position: fixed;
  background-color: var(--bg);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  max-width: 350px;
  max-height: 600px;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  border: 1px solid var(--border);
}

.tag-popup.visible {
  display: flex;
}

.tag-popup-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tag-popup-header h3 {
  margin: 0 0 0.5rem 0;
}

.tag-popup-header p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.tag-popup-content {
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}

.popup-tag-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background-color: var(--bg-light);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.popup-tag-item:hover {
  background-color: var(--bg);
  border: 1px solid var(--primary);
}

.popup-tag-item input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
}

.popup-tag-item-color {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}

.popup-tag-item-name {
  flex: 1;
  font-size: 0.9rem;
}

.tag-popup-note {
  padding: 0 1rem;
}

.tag-popup-note label {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.tag-popup-note textarea {
  min-height: 80px;
  font-size: 0.85rem;
}

.tag-popup-actions {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

.tag-popup-actions .btn {
  flex: 1;
}

.tag-popup-new-tag {
  padding: 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tag-popup-new-tag .form-group {
  margin-bottom: 0.75rem;
}

.tag-popup-new-tag .form-group:last-child {
  margin-bottom: 0;
}

.tag-popup-new-tag label {
  font-size: 0.85rem;
}

/* ======================================
   Context Menu
   ====================================== */

.context-menu {
  position: fixed;
  background-color: var(--bg);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  min-width: 200px;
  max-height: 80vh;
  overflow-y: auto;
  display: none;
  border: 1px solid var(--border);
}

.context-menu.visible {
  display: block;
}

.context-menu-item {
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-bottom: 1px solid var(--border);
}

.context-menu-item:last-child {
  border-bottom: none;
}

.context-menu-item:hover {
  background-color: var(--bg-light);
}

.context-menu-item.divider {
  padding: 0;
  height: 1px;
  background-color: var(--border);
  cursor: default;
  margin: 0.5rem 0;
}

.context-menu-item.divider:hover {
  background-color: var(--border);
}

/* ======================================
   Note Editing Area
   ====================================== */

.note-editing-area {
  padding: 1rem;
  background-color: var(--bg-light);
  border-radius: 4px;
  margin-bottom: 1rem;
}

.note-editing-area label {
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.note-editing-area textarea {
  min-height: 100px;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.note-editing-area .btn {
  width: 100%;
}

/* ======================================
   Overlay & Modals
   ====================================== */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 99;
  display: none;
  animation: fadeIn var(--transition-normal);
}

.sidebar-overlay.visible {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ======================================
   Mobile Responsive Design
   ====================================== */

@media (max-width: 768px) {
  /* General */
  body {
    font-size: 16px;
  }

  /* Top bar */
  .top-bar {
    padding: 1rem;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .top-bar-left {
    gap: 1rem;
    order: 1;
  }

  .top-bar-right {
    order: 2;
    width: 100%;
    margin-top: 0.75rem;
  }

  .logo {
    font-size: 1.25rem;
  }

  /* Auth */
  #auth-section {
    padding: 1rem;
  }

  .auth-container {
    max-width: 100%;
  }

  .auth-header {
    padding: 1.5rem 1.5rem 1rem;
  }

  .auth-content {
    padding: 1.5rem;
  }

  /* Dashboard */
  .dashboard-content {
    padding: 1rem;
  }

  .projects-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Project detail */
  .project-detail-content {
    padding: 1rem;
  }

  .detail-section {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  /* Viewer */
  .viewer-toolbar {
    padding: 1rem;
    gap: 0.5rem;
  }

  .viewer-toolbar h2 {
    font-size: 1rem;
    flex: 1;
  }

  .toolbar-actions {
    gap: 0.5rem;
  }

  .sidebar-toggle {
    display: flex;
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  /* Sidebar responsive layout */
  .viewer-container {
    position: relative;
  }

  .viewer-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    max-width: 90vw;
    transition: transform 0.3s ease;
    z-index: 98;
  }

  .viewer-sidebar.left {
    left: 0;
    transform: translateX(-100%);
  }

  .viewer-sidebar.right {
    right: 0;
    transform: translateX(100%);
  }

  .viewer-sidebar.left.open {
    transform: translateX(0);
  }

  .viewer-sidebar.right.open {
    transform: translateX(0);
  }

  .viewer-main {
    width: 100%;
  }

  .document-text {
    padding: 1rem;
    font-size: 14px;
  }

  .line-numbers {
    padding: 1rem 0.5rem;
    font-size: 12px;
    min-width: 40px;
  }

  /* Mobile buttons */
  .btn {
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
  }

  .btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Tag popup on mobile */
  .tag-popup {
    max-width: 90vw;
    max-height: 80vh;
    left: 5vw !important;
    right: 5vw !important;
    top: 10vh !important;
  }

  /* Context menu on mobile */
  .context-menu {
    max-width: 90vw;
    max-height: 70vh;
    left: 5vw !important;
    right: 5vw !important;
  }

  /* Forms on mobile */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea,
  select {
    padding: 0.75rem;
    font-size: 16px;
  }

  /* List items mobile */
  .document-item,
  .tag-item,
  .collaborator-item {
    padding: 0.875rem;
    flex-wrap: wrap;
  }

  .document-item-content,
  .tag-item-content,
  .collaborator-item-content {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  /* Stats and toggles on mobile */
  .visibility-toggle-row,
  .stats-row {
    padding: 0.75rem 0.5rem;
  }

  /* Scrollbar on mobile */
  ::-webkit-scrollbar {
    width: 4px;
  }

  ::-webkit-scrollbar-thumb {
    background: #999;
  }
}

@media (max-width: 480px) {
  /* Extra small devices */
  .top-bar {
    padding: 0.75rem;
  }

  .logo {
    font-size: 1rem;
  }

  .user-info {
    display: none;
  }

  .dashboard-content,
  .project-detail-content {
    padding: 0.75rem;
  }

  .detail-section {
    padding: 0.75rem;
  }

  .viewer-toolbar {
    padding: 0.75rem;
  }

  .viewer-toolbar h2 {
    font-size: 0.9rem;
  }

  .sidebar-toggle {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .btn {
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
  }

  .document-text {
    padding: 0.75rem;
    font-size: 13px;
    line-height: 1.6;
  }

  .line-numbers {
    padding: 0.75rem 0.25rem;
    font-size: 11px;
    min-width: 35px;
  }

  .auth-header,
  .auth-content,
  .auth-footer {
    padding: 1rem;
  }

  .project-card {
    padding: 1rem;
  }
}

/* ======================================
   Utility Classes
   ====================================== */

.hidden {
  display: none !important;
}

.invisible {
  visibility: hidden;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-secondary);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.flex { display: flex; }
.flex-column { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* Print styles */
@media print {
  .top-bar,
  .sidebar-toggle,
  .toolbar-actions,
  .btn,
  .context-menu,
  .tag-popup {
    display: none !important;
  }

  .document-text {
    white-space: pre-wrap;
    word-break: break-word;
  }
}
