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

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --secondary: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Font Awesome icon styling */
i.fa-solid, i.fa-brands, i.fa-regular {
  margin-right: 6px;
}

h1 i, h2 i, h3 i {
  color: var(--primary);
}

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

.empty-state-icon i {
  font-size: 48px;
  color: var(--text-light);
}

.notification-icon i {
  font-size: 18px;
}

.doc-icon i {
  font-size: 24px;
  color: var(--primary);
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

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

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

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

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

.btn-danger:hover {
  background: #dc2626;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 20px;
  position: relative;
}

/* User Menu Dropdown */
.user-menu {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

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

.user-btn i {
  font-size: 12px;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  overflow: hidden;
  z-index: 1000;
}

.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
}

.dropdown-menu a:hover {
  background: var(--bg);
}

.dropdown-menu a i {
  width: 16px;
  color: var(--text-light);
}

/* Login Page */
.login-container {
  max-width: 400px;
  margin: 100px auto;
  padding: 40px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-container h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-light);
  margin-bottom: 30px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#login-form input {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

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

.error {
  color: var(--danger);
  font-size: 14px;
  margin-top: 10px;
}

/* Main Layout */
#main-app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr;
  min-height: 100vh;
}

/* Header */
.header {
  grid-column: 1 / -1;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.header h1 {
  font-size: 20px;
}

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

#user-name {
  color: var(--text-light);
}

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
}

/* Sidebar */
.sidebar {
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 20px 0;
}

.sidebar ul {
  list-style: none;
}

.sidebar a {
  display: block;
  padding: 12px 24px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
}

.sidebar a:hover,
.sidebar a.active {
  background: var(--bg);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}

/* Content */
.content {
  padding: 24px;
  overflow-y: auto;
}

.view-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.view-header h2 {
  flex: 1;
}

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

.description {
  color: var(--text-light);
  margin-bottom: 24px;
}

/* Cards Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

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

.card h3 {
  margin-bottom: 8px;
}

.card p {
  color: var(--text-light);
  font-size: 14px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-light);
}

/* Status Badge */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}

.status-active, .status-in-progress {
  background: #dcfce7;
  color: #166534;
}

.status-completed {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-pending, .status-on-hold {
  background: #fef3c7;
  color: #92400e;
}

/* Phases */
.phases-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Project Progress */
.project-progress {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 8px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
}

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #4ade80);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.progress-legend {
  display: flex;
  gap: 20px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-light);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.pending {
  background: #f59e0b;
}

.legend-dot.in-progress {
  background: #3b82f6;
}

.legend-dot.completed {
  background: #22c55e;
}

.phase-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
  border-left: 4px solid var(--primary);
}

.phase-card:hover {
  box-shadow: var(--shadow-lg);
}

.phase-info {
  flex: 1;
  cursor: pointer;
}

.phase-info:hover h4 {
  color: var(--primary);
}

.phase-info h4 {
  margin-bottom: 4px;
  transition: color 0.2s;
}

.phase-info p {
  color: var(--text-light);
  font-size: 14px;
}

.phase-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.phase-arrow {
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  padding: 8px;
  transition: all 0.2s;
}

.phase-arrow:hover {
  color: var(--primary);
  transform: translateX(4px);
}

.phase-count {
  font-size: 13px;
  color: var(--text-light);
}

/* Phase Status Select */
.phase-status-control {
  position: relative;
}

.status-select {
  appearance: none;
  padding: 8px 32px 8px 12px;
  border-radius: 20px;
  border: 2px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: all 0.2s;
}

.status-select:hover:not(:disabled) {
  border-color: var(--primary);
}

.status-select:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.status-select.status-pending {
  background-color: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.status-select.status-in-progress {
  background-color: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.status-select.status-completed {
  background-color: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}

.status-select.status-active {
  background-color: #dbeafe;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.status-select.status-on-hold {
  background-color: #f3e8ff;
  border-color: #a855f7;
  color: #7c3aed;
}

/* Project title wrapper with status */
.project-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.project-title-wrapper h2 {
  margin: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.status-active {
  background-color: #dbeafe;
  color: #1d4ed8;
}

.status-badge.status-in-progress {
  background-color: #fef3c7;
  color: #92400e;
}

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

.status-badge.status-on-hold {
  background-color: #f3e8ff;
  color: #7c3aed;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  background: var(--text);
  color: white;
  font-size: 14px;
  z-index: 3000;
  animation: toast-in 0.3s ease;
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.toast.fade-out {
  animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

/* Documents */
.section {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

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

.section h3 {
  margin-bottom: 0;
}

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

.document-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
}

.document-item:hover {
  background: var(--border);
}

.document-icon {
  font-size: 24px;
}

.document-name {
  flex: 1;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-badge {
  font-size: 14px;
  opacity: 0.6;
}

.document-item:hover .view-badge {
  opacity: 1;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.document-item:hover .delete-btn,
.comment:hover .delete-btn {
  opacity: 1;
}

/* Comments */
.comments-container {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.comment {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.comment:last-child {
  border-bottom: none;
}

.comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.comment-content {
  flex: 1;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-author {
  font-weight: 600;
}

.comment-role {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg);
  border-radius: 10px;
  color: var(--text-light);
}

.comment-time {
  font-size: 12px;
  color: var(--text-light);
}

.comment-text {
  font-size: 14px;
  line-height: 1.6;
}

.comment-text .mention {
  color: var(--primary);
  font-weight: 500;
}

.comment-form {
  margin-top: 16px;
}

.comment-form textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

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

.comment-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

.comment-form-actions small {
  color: var(--text-light);
}

/* Markdown Toolbar */
.markdown-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  flex-wrap: wrap;
}

.markdown-toolbar button {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.markdown-toolbar .toolbar-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
}

.markdown-toolbar .toolbar-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
  transition: all 0.2s;
}

.markdown-toolbar button:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.markdown-toolbar button.active {
  background: var(--primary);
  color: white;
}

.toolbar-divider {
  width: 1px;
  background: var(--border);
  margin: 0 8px;
}

.comment-form textarea {
  border-radius: 0;
}

.comment-form textarea:first-of-type {
  border-radius: 0 0 8px 8px;
}

/* Markdown Preview */
.markdown-preview {
  padding: 16px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  background: var(--card-bg);
  min-height: 100px;
  max-height: 300px;
  overflow-y: auto;
}

.markdown-preview.active {
  display: block;
}

/* Markdown Content Styling */
.markdown-content {
  line-height: 1.7;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
  margin: 16px 0 8px;
}

.markdown-content p {
  margin: 8px 0;
}

.markdown-content ul,
.markdown-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

.markdown-content li {
  margin: 4px 0;
}

.markdown-content code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
}

.markdown-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.markdown-content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text-light);
  font-style: italic;
}

.markdown-content a {
  color: var(--primary);
  text-decoration: none;
}

.markdown-content a:hover {
  text-decoration: underline;
}

.markdown-content img {
  max-width: 100%;
  border-radius: 8px;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.markdown-content th {
  background: var(--bg);
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Comment Edit Mode */
.comment-edit-form {
  margin-top: 8px;
}

.comment-edit-form textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

.comment-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.comment-edit-actions button {
  padding: 6px 14px;
  font-size: 13px;
}

.edit-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 12px;
}

.comment:hover .edit-btn {
  opacity: 1;
}

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

.comment-raw {
  display: none;
}

/* Notifications */
.notifications-container {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.notification-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

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

.notification-item.unread {
  background: #eef2ff;
}

.notification-icon {
  font-size: 20px;
}

.notification-content {
  flex: 1;
}

.notification-message {
  font-size: 14px;
  margin-bottom: 4px;
}

.notification-time {
  font-size: 12px;
  color: var(--text-light);
}

/* Tables */
.table-container {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

th, td {
  padding: 14px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--text-light);
}

/* Modal */
.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 {
  background: var(--card-bg);
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

/* Document Viewer Modal */
.doc-viewer-modal {
  max-width: 900px;
  width: 95%;
  height: 90vh;
  display: flex;
  flex-direction: column;
}

.doc-viewer-modal .modal-header {
  flex-shrink: 0;
}

.doc-viewer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-viewer-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: var(--card-bg);
}

.doc-viewer-content .markdown-content {
  max-width: 100%;
}

.doc-viewer-content .markdown-content img {
  max-width: 100%;
  height: auto;
}

.doc-viewer-content pre {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Image viewer */
.doc-viewer-content.image-viewer {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
}

.doc-viewer-content.image-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* PDF viewer */
.doc-viewer-content iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Document Editor */
.doc-editor {
  flex: 1;
  width: 100%;
  padding: 24px;
  border: none;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  background: #1e293b;
  color: #e2e8f0;
}

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

.edit-status {
  font-size: 12px;
  color: var(--text-light);
  margin-right: 8px;
}

.edit-status.saving {
  color: var(--warning);
}

.edit-status.saved {
  color: var(--success);
}

.edit-status.editing {
  color: var(--primary);
}

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

/* Collaboration status indicator */
.collab-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  animation: pulse-bg 2s infinite;
}

.collab-status:empty {
  display: none;
}

.collab-status.live {
  background: #dcfce7;
  color: #166534;
}

@keyframes pulse-bg {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

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

.btn-success:hover {
  background: #16a34a !important;
  border-color: #16a34a !important;
}

/* Real-time notification toast */
.notification-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  max-width: 350px;
  z-index: 2000;
  animation: slideIn 0.3s ease;
  cursor: pointer;
}

.notification-toast:hover {
  transform: translateX(-4px);
}

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

.notification-toast .toast-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
}

.notification-toast .toast-message {
  font-size: 14px;
  color: var(--text-light);
}

.notification-toast .toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-light);
}

/* Typing indicator */
.typing-indicator {
  padding: 12px 20px;
  color: var(--text-light);
  font-size: 13px;
  font-style: italic;
}

/* Real-time user badge */
.realtime-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #dcfce7;
  color: #166534;
  border-radius: 12px;
  font-size: 11px;
  margin-left: 8px;
}

.realtime-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

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

/* Text/Code viewer */
.doc-viewer-content.text-viewer {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 14px;
  white-space: pre-wrap;
  background: #1e293b;
  color: #e2e8f0;
}

/* Document with line numbers */
.doc-lines-container {
  background: #1e293b;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 10px;
}

.doc-with-lines {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.doc-line {
  display: flex;
  transition: background-color 0.2s;
}

.doc-line:hover {
  background: rgba(255, 255, 255, 0.05);
}

.doc-line.highlighted {
  background: rgba(79, 70, 229, 0.3);
  animation: highlight-pulse 1s ease-out;
}

@keyframes highlight-pulse {
  0% { background: rgba(79, 70, 229, 0.6); }
  100% { background: rgba(79, 70, 229, 0.3); }
}

.line-number {
  min-width: 50px;
  padding: 2px 12px 2px 8px;
  text-align: right;
  background: rgba(0, 0, 0, 0.2);
  color: #64748b;
  user-select: none;
  border-right: 1px solid #334155;
  cursor: pointer;
  font-size: 12px;
}

.line-number:hover {
  color: #94a3b8;
  background: rgba(0, 0, 0, 0.3);
}

.line-content {
  flex: 1;
  padding: 2px 12px;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Document link in comments */
.doc-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  border-radius: 4px;
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s;
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.doc-link:hover {
  background: rgba(79, 70, 229, 0.2);
  border-color: rgba(79, 70, 229, 0.4);
}

.doc-link i {
  margin-right: 0;
}

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

.modal-header h3 {
  margin: 0;
}

#modal-content {
  padding: 24px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

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

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* Project Meta */
.project-meta {
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-light);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

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

  .sidebar {
    display: none;
  }

  .header h1 {
    font-size: 16px;
  }

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

/* Project Content Wrapper */
.project-content-wrapper {
  display: flex;
  gap: 20px;
  position: relative;
}

.project-content-wrapper .phases-container {
  flex: 1;
}

/* Chat Panel */
.chat-panel {
  width: 350px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  height: 500px;
  position: sticky;
  top: 20px;
}

.chat-panel.hidden {
  display: none;
}

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

.chat-header h4 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.chat-header h4 i {
  color: var(--primary);
  margin-right: 8px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.chat-message.own {
  align-self: flex-end;
}

.chat-message.other {
  align-self: flex-start;
}

.chat-message-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.chat-message-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.chat-message-role {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--primary);
  color: white;
}

.chat-message-role.client {
  background: var(--secondary);
}

.chat-message-time {
  font-size: 10px;
  color: var(--text-light);
}

.chat-message-bubble {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.chat-message-content {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-message-actions {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  gap: 4px;
  background: var(--card-bg);
  border-radius: 8px;
  padding: 4px;
  box-shadow: var(--shadow);
}

.chat-message.own .chat-message-actions {
  left: -60px;
}

.chat-message.other .chat-message-actions {
  right: -60px;
}

.chat-message-bubble:hover .chat-message-actions {
  display: flex;
}

.chat-message-actions button {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-light);
  font-size: 12px;
  border-radius: 4px;
  transition: all 0.2s;
}

.chat-message-actions button:hover {
  background: var(--bg);
  color: var(--primary);
}

.chat-message-actions button:last-child:hover {
  color: var(--danger);
}

.chat-message.own .chat-message-content {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.other .chat-message-content {
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Chat inline edit form */
.chat-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  min-width: 200px;
}

.chat-edit-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  width: 100%;
}

.chat-edit-input:focus {
  border-color: var(--primary);
}

.chat-edit-buttons {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.chat-edit-buttons button {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.chat-edit-buttons .btn-save {
  background: var(--success);
  color: white;
}

.chat-edit-buttons .btn-save:hover {
  background: #16a34a;
}

.chat-edit-buttons .btn-cancel {
  background: var(--bg);
  color: var(--text);
}

.chat-edit-buttons .btn-cancel:hover {
  background: var(--danger);
  color: white;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  outline: none;
}

.chat-form input:focus {
  border-color: var(--primary);
}

.chat-form button {
  border-radius: 50%;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-form button i {
  margin: 0;
}

.chat-empty {
  text-align: center;
  color: var(--text-light);
  padding: 40px 20px;
}

.chat-empty i {
  font-size: 32px;
  margin-bottom: 12px;
  display: block;
}

/* Responsive chat */
@media (max-width: 900px) {
  .project-content-wrapper {
    flex-direction: column;
  }
  
  .chat-panel {
    width: 100%;
    position: static;
    height: 400px;
  }
}

/* Clients Grid */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.client-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.client-card:hover {
  box-shadow: var(--shadow-lg);
}

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

.client-info {
  flex: 1;
  min-width: 0;
}

.client-info h4 {
  margin: 0 0 4px 0;
  font-size: 16px;
  color: var(--text);
}

.client-email {
  margin: 0;
  font-size: 13px;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-date {
  margin: 4px 0 0 0;
  font-size: 12px;
  color: var(--text-light);
}

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

.client-actions .btn-sm {
  padding: 8px 10px;
}

.client-actions .btn-sm i {
  margin: 0;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  min-width: 250px;
}

.autocomplete-dropdown.hidden {
  display: none;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: rgba(79, 70, 229, 0.1);
}

.autocomplete-item i {
  color: var(--primary);
  width: 18px;
  text-align: center;
}

.autocomplete-item .item-name {
  font-weight: 500;
  color: var(--text);
}

.autocomplete-item .item-hint {
  font-size: 12px;
  color: var(--text-light);
  margin-left: auto;
}

.autocomplete-header {
  padding: 8px 14px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-light);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.comment-form {
  position: relative;
}

/* Admin card styling */
.admin-avatar {
  background: #7c3aed !important;
}

.super-admin-card {
  border: 2px solid #7c3aed;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.05), rgba(124, 58, 237, 0.02));
}

.super-badge {
  display: inline-block;
  padding: 2px 8px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  text-transform: uppercase;
  margin-left: 8px;
  vertical-align: middle;
}
