/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --secondary: #6b7280;
  --danger: #ef4444;
  --bg: #ffffff;
  --bg-secondary: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-secondary: #6b7280;
}

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Navigation */
.navbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
}

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.nav-links a:hover {
  color: var(--primary);
}

/* Hero section */
.hero {
  padding: 4rem 0;
  text-align: center;
}

.hero h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.hero .lead {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
}

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

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

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

.btn-secondary:hover {
  background: var(--border);
}

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

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

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

/* Features */
.features {
  padding: 4rem 0;
  background: var(--bg-secondary);
}

.features h2 {
  text-align: center;
  margin-bottom: 3rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.feature h3 {
  margin-bottom: 0.5rem;
}

/* Forms */
.auth-page {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-container {
  max-width: 400px;
  width: 100%;
  padding: 2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.auth-form {
  margin-top: 1.5rem;
}

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

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

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 1rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.auth-footer {
  margin-top: 1rem;
  text-align: center;
  color: var(--text-secondary);
}

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

/* Document list */
.document-list-page {
  padding: 2rem;
}

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

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

.document-card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  position: relative;
  transition: box-shadow 0.2s;
}

.document-card:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.document-card-link {
  text-decoration: none;
  color: var(--text);
  display: block;
}

.document-card h3 {
  margin-bottom: 0.5rem;
}

.document-meta {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

/* Document editor */
.document-editor-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
}

.back-link {
  text-decoration: none;
  color: var(--text-secondary);
}

.title-input {
  flex: 1;
  font-size: 1.25rem;
  font-weight: 600;
  border: none;
  padding: 0.5rem;
}

.title-input:focus {
  outline: none;
  background: var(--bg-secondary);
}

.saving-indicator {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Collaborative Editor */
.collaborative-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-indicator {
  font-size: 0.875rem;
  font-weight: 500;
}

.status-indicator.connected {
  color: #10b981;
}

.status-indicator.connecting {
  color: #f59e0b;
}

.status-indicator.disconnected {
  color: #ef4444;
}

.collaborators {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

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

.collaborator {
  font-size: 1.25rem;
  cursor: default;
}

.save-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.save-button {
  padding: 0.5rem 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.save-button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.save-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.last-saved {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Tiptap Editor */
.tiptap-editor {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

.tiptap-editor .ProseMirror {
  min-height: 100%;
  outline: none;
  font-size: 1rem;
  line-height: 1.6;
}

.tiptap-editor .ProseMirror p {
  margin-bottom: 1rem;
}

.tiptap-editor .ProseMirror h1,
.tiptap-editor .ProseMirror h2,
.tiptap-editor .ProseMirror h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.tiptap-editor .ProseMirror h1 {
  font-size: 2rem;
}

.tiptap-editor .ProseMirror h2 {
  font-size: 1.5rem;
}

.tiptap-editor .ProseMirror h3 {
  font-size: 1.25rem;
}

.tiptap-editor .ProseMirror ul,
.tiptap-editor .ProseMirror ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.tiptap-editor .ProseMirror code {
  background: var(--bg-secondary);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: monospace;
}

.tiptap-editor .ProseMirror pre {
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: 0.375rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.tiptap-editor .ProseMirror pre code {
  background: none;
  padding: 0;
}

.tiptap-editor .ProseMirror blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  margin-left: 0;
  color: var(--text-secondary);
}

/* Collaboration cursors */
.tiptap-editor .collaboration-cursor__caret {
  border-left: 2px solid;
  border-color: inherit;
  margin-left: -1px;
  margin-right: -1px;
  pointer-events: none;
  position: relative;
  word-break: normal;
}

.tiptap-editor .collaboration-cursor__label {
  border-radius: 0.25rem;
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  left: -1px;
  line-height: normal;
  padding: 0.125rem 0.25rem;
  position: absolute;
  top: -1.4em;
  user-select: none;
  white-space: nowrap;
}

.editor-container {
  flex: 1;
  padding: 2rem;
}

.editor-textarea {
  width: 100%;
  height: 100%;
  border: none;
  resize: none;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.6;
}

.editor-textarea:focus {
  outline: none;
}

.save-indicator {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--primary);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  animation: fadeOut 2s forwards;
}

@keyframes fadeOut {
  0%, 80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Utility classes */
.loading, .error {
  padding: 2rem;
  text-align: center;
}

.error {
  color: var(--danger);
}

/* Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  text-align: center;
  color: var(--text-secondary);
}
/* Folder Tree */
.folder-tree {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  max-height: 500px;
  overflow-y: auto;
}

.folder-item-container {
  margin-left: 0;
}

.folder-item,
.document-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 0.25rem;
  transition: background-color 0.2s;
}

.folder-item:hover,
.document-item:hover {
  background: var(--bg-secondary);
}

.folder-item.selected {
  background: var(--primary);
  color: white;
}

.folder-item.root {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.folder-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  color: inherit;
}

.folder-contents {
  margin-left: 1.5rem;
}

.folder-item svg,
.document-item svg {
  flex-shrink: 0;
}

.document-item {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Dashboard Styles */
.dashboard-container {
  min-height: 100vh;
  background: var(--bg-secondary);
}

.dashboard-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 2rem;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.user-info {
  display: flex;
  gap: 1rem;
  align-items: center;
  color: var(--text-secondary);
}

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

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

.account-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.account-card:hover {
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

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

.account-card h3 {
  font-size: 1.25rem;
  margin: 0;
}

.account-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.account-badge.owner {
  background: #dbeafe;
  color: #1e40af;
}

.account-badge.member {
  background: #f3f4f6;
  color: #4b5563;
}

.account-stats {
  display: flex;
  gap: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.account-card-footer {
  margin-top: 1rem;
}

.last-updated {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Account Layout */
.account-layout {
  min-height: 100vh;
  background: var(--bg-secondary);
}

.account-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
}

.account-header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-button {
  padding: 0.5rem !important;
}

.account-tabs {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.tab {
  padding: 1rem 0;
  text-decoration: none;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

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

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

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

/* Documents View */
.documents-view {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
}

.documents-sidebar {
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 1rem;
  height: fit-content;
}

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

.documents-main {
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 1.5rem;
}

.documents-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

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

.document-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.document-card:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.document-card h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.document-date {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Groups View */
.groups-view {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
}

.groups-list {
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 1.5rem;
}

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

.group-cards {
  display: grid;
  gap: 1rem;
}

.group-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.group-card:hover,
.group-card.selected {
  border-color: var(--primary);
  background: var(--bg);
}

.group-card h3 {
  margin-bottom: 0.5rem;
}

.group-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.group-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.group-details {
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 1.5rem;
  height: fit-content;
}

.member-list {
  list-style: none;
  margin-top: 1rem;
}

.member-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.member-info {
  display: flex;
  flex-direction: column;
}

.member-info span {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Permissions View */
.permissions-view {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
}

.permissions-sidebar {
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 1rem;
  height: fit-content;
}

.folder-list {
  margin-top: 1rem;
}

.folder-item {
  padding: 0.75rem;
  cursor: pointer;
  border-radius: 0.25rem;
  margin-bottom: 0.25rem;
  transition: background 0.2s;
}

.folder-item:hover {
  background: var(--bg-secondary);
}

.folder-item.selected {
  background: var(--primary);
  color: white;
}

.permissions-main {
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 1.5rem;
}

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

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
}

.table th,
.table td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
}

.table tbody tr:hover {
  background: var(--bg-secondary);
}

.permissions-table table {
  width: 100%;
  border-collapse: collapse;
}

.permissions-table th,
.permissions-table td {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.permissions-table th {
  font-weight: 600;
  color: var(--text-secondary);
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.badge-read {
  background: #dbeafe;
  color: #1e40af;
}

.badge-write {
  background: #dcfce7;
  color: #166534;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-error {
  background: #fee2e2;
  color: #991b1b;
}

.badge-secondary {
  background: #f3f4f6;
  color: #6b7280;
}

/* Settings View */
.settings-view {
  max-width: 800px;
}

.settings-section {
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 2rem;
  margin-bottom: 2rem;
}

.settings-section h2 {
  margin-bottom: 1.5rem;
}

.danger-zone {
  border: 2px solid var(--danger);
}

.danger-zone-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

/* Invitations List */
.invitations-list {
  margin-top: 1rem;
}

.invitations-list .btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

/* Profile Page */
.profile-page {
  min-height: 100vh;
  background: var(--bg-secondary);
}

.profile-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
}

.profile-main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.profile-section {
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 2rem;
  margin-bottom: 2rem;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal,
.modal-content {
  background: var(--bg);
  border-radius: 0.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}

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

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
}

.form-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Alert Styles */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-secondary);
}

.empty-state h2 {
  margin-bottom: 0.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
}

.info-message {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

/* Button Size Variants */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .documents-view,
  .groups-view,
  .permissions-view {
    grid-template-columns: 1fr;
  }

  .documents-sidebar,
  .permissions-sidebar {
    display: none;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .danger-zone-content {
    flex-direction: column;
    align-items: stretch;
  }

  .account-tabs {
    overflow-x: auto;
    white-space: nowrap;
  }
}