/* =============================================================
   DocSeva Bug Tracker — Styles
   ============================================================= */

:root {
  --green-900: #1B5E20;
  --green-800: #2E7D32;
  --green-700: #388E3C;
  --green-600: #43A047;
  --green-100: #E8F5E9;
  --green-50: #F1F8E9;
  --red-600: #D32F2F;
  --red-100: #FFEBEE;
  --red-50: #FFF5F5;
  --orange-600: #E65100;
  --orange-100: #FFF3E0;
  --blue-600: #1565C0;
  --blue-100: #E3F2FD;
  --gray-900: #111827;
  --gray-700: #374151;
  --gray-600: #4B5563;
  --gray-500: #6B7280;
  --gray-400: #9CA3AF;
  --gray-300: #D1D5DB;
  --gray-200: #E5E7EB;
  --gray-100: #F3F4F6;
  --gray-50: #F9FAFB;
  --white: #FFFFFF;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── LOGIN ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-900) 0%, var(--green-700) 100%);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-icon {
  width: 56px;
  height: 56px;
  background: var(--green-100);
  color: var(--green-800);
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--green-900);
}

.login-logo p {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

.login-error {
  background: var(--red-50);
  color: var(--red-600);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 24px;
}

/* ── FORM FIELDS (shared) ── */
.form-field { margin-bottom: 0; }
.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--gray-900);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(67, 160, 71, 0.15);
}

.form-field textarea { resize: vertical; min-height: 64px; }
.form-field input::placeholder,
.form-field textarea::placeholder { color: var(--gray-400); }

.form-row {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row.two { grid-template-columns: 1fr 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-row.full { grid-template-columns: 1fr; }

/* ── BUTTONS ── */
.btn-primary {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  background: var(--green-800);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary:hover { background: var(--green-900); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }

.btn-outline {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-ghost {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.5); }

.btn-danger {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  background: var(--white);
  color: var(--red-600);
  border: 1px solid var(--red-600);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-danger:hover { background: var(--red-50); }

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

/* ── TOPBAR ── */
.topbar {
  background: var(--green-900);
  color: var(--white);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
}
.topbar-title span {
  font-weight: 400;
  opacity: 0.8;
  margin-left: 6px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  font-size: 13px;
  opacity: 0.8;
}

/* ── MAIN CONTENT ── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px;
}

/* ── STATS ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.stat-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.stat-open .stat-num { color: var(--orange-600); }
.stat-critical .stat-num { color: var(--red-600); }
.stat-resolved .stat-num { color: var(--green-700); }

/* ── TABS BAR ── */
.tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-full);
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { background: var(--gray-100); }
.tab.active {
  background: var(--green-100);
  color: var(--green-900);
  border-color: var(--green-700);
  font-weight: 600;
}

.tab .tab-count {
  font-size: 11px;
  background: var(--gray-200);
  color: var(--gray-600);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: 4px;
}
.tab.active .tab-count {
  background: var(--green-800);
  color: var(--white);
}

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

/* ── LIST CARD ── */
.list-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.search-wrap {
  flex: 1;
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}
.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--white);
  outline: none;
}
.search-wrap input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(67, 160, 71, 0.12);
}

.list-toolbar select {
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--font);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--gray-700);
  cursor: pointer;
  outline: none;
  min-width: 120px;
}

/* ── BUG ROWS ── */
.bug-row {
  display: grid;
  grid-template-columns: 72px 1fr 110px 86px 96px 90px 90px 80px;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  transition: background 0.1s;
}

.bug-row:hover:not(.header-row) {
  background: var(--gray-50);
  cursor: pointer;
}

.header-row {
  background: var(--gray-50);
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 9px 16px;
  border-bottom: 1px solid var(--gray-200);
  cursor: default;
}

.header-row span { cursor: pointer; user-select: none; }
.header-row .col-title,
.header-row .col-assignee,
.header-row .col-reporter { cursor: default; }

.sort-icon::after { content: ''; margin-left: 2px; }
.sort-icon.asc::after { content: ' \u25B2'; font-size: 9px; }
.sort-icon.desc::after { content: ' \u25BC'; font-size: 9px; }

.col-id {
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--gray-500);
}

.col-title { min-width: 0; }
.col-title .bug-title-text {
  font-weight: 500;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.col-title .bug-subtitle {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-reporter, .col-assignee, .col-date {
  font-size: 12px;
  color: var(--gray-600);
}

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-critical { background: #FCEBEB; color: #791F1F; }
.badge-high { background: #FFF3E0; color: #7C3A00; }
.badge-medium { background: #E3F2FD; color: #0C447C; }
.badge-low { background: var(--gray-100); color: var(--gray-600); }

.badge-open { background: #FCEBEB; color: #791F1F; }
.badge-progress { background: #FFF3E0; color: #7C3A00; }
.badge-resolved { background: #E8F5E9; color: #1B5E20; }
.badge-closed { background: var(--gray-100); color: var(--gray-600); }

.badge-doctor { background: #E3F2FD; color: #0C447C; }
.badge-patient { background: #E8F5E9; color: #1B5E20; }
.badge-admin { background: #FFF3E0; color: #7C3A00; }

/* ── EMPTY STATE ── */
.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--gray-500);
}

.empty-state svg {
  color: var(--gray-300);
  margin-bottom: 12px;
}

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

.empty-state small {
  font-size: 12px;
  color: var(--gray-400);
}

/* ── LOADING ── */
.loading {
  padding: 40px;
  text-align: center;
  color: var(--gray-500);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--green-700);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  animation: modalIn 0.2s ease-out;
}

.modal-wide { max-width: 760px; }

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

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  font-size: 20px;
  color: var(--gray-600);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--gray-200); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--gray-200);
}
.modal-footer .btn-danger { margin-right: auto; }

/* ── DETAIL MODAL ── */
.detail-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.detail-bug-id {
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.detail-header-left h2 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
}
.detail-meta.secondary { border-bottom: none; margin-bottom: 8px; }

.detail-meta-item { display: flex; flex-direction: column; gap: 3px; }
.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-meta-item span:last-child { font-size: 13px; color: var(--gray-900); }
.detail-meta-item select {
  padding: 4px 8px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
}
.detail-meta-item select:focus { border-color: var(--green-600); }

.detail-section {
  margin-bottom: 16px;
}
.detail-section h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.detail-section pre {
  font-family: var(--font);
  font-size: 13px;
  color: var(--gray-700);
  background: var(--gray-50);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--gray-100);
  min-height: 32px;
}

.detail-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── COMMENTS ── */
.comment-count {
  font-weight: 400;
  color: var(--gray-400);
}

.comments-list {
  margin-bottom: 12px;
  max-height: 240px;
  overflow-y: auto;
}

.comment-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.comment-item:last-child { border-bottom: none; }

.comment-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}

.comment-time {
  font-size: 11px;
  color: var(--gray-400);
  margin-left: 8px;
}

.comment-text {
  font-size: 13px;
  color: var(--gray-700);
  margin-top: 3px;
  white-space: pre-wrap;
}

.comment-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.comment-form textarea {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  resize: none;
  outline: none;
}
.comment-form textarea:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(67, 160, 71, 0.12);
}

.no-comments {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--gray-400);
}

/* ── DROPZONE ── */
.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--gray-50);
}
.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--green-600);
  background: var(--green-50);
}
.dropzone.drag-over {
  border-style: solid;
}
.dropzone-content svg {
  color: var(--gray-400);
  margin-bottom: 8px;
}
.dropzone-content p {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 2px;
}
.dropzone-content small {
  font-size: 11px;
  color: var(--gray-400);
}
.dropzone-link {
  color: var(--green-700);
  font-weight: 600;
  cursor: pointer;
}

/* Upload previews */
.upload-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.upload-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--gray-200);
}
.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.upload-thumb .thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(0,0,0,0.6);
  color: var(--white);
  border: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-thumb .thumb-remove:hover { background: var(--red-600); }
.upload-thumb.uploading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-thumb .thumb-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--green-700);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  z-index: 1;
}

/* Upload progress bar */
.upload-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--green-700);
  border-radius: 2px;
  transition: width 0.2s;
  width: 0%;
}
.progress-text {
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
}

/* ── SCREENSHOT GALLERY (detail modal) ── */
.screenshot-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.screenshot-thumb {
  width: 120px;
  height: 90px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.screenshot-thumb:hover {
  transform: scale(1.04);
  box-shadow: var(--shadow-md);
}
.screenshot-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.screenshot-count {
  font-weight: 400;
  color: var(--gray-400);
}
.no-screenshots {
  font-size: 12px;
  color: var(--gray-400);
  padding: 12px 0;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: var(--white);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.25s ease-out;
}

.toast.toast-error { background: var(--red-600); }
.toast.toast-success { background: var(--green-800); }

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

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .bug-row {
    grid-template-columns: 64px 1fr 90px 80px 80px;
  }
  .col-assignee, .col-reporter, .col-date { display: none; }
  .header-row .col-assignee,
  .header-row .col-reporter,
  .header-row .col-date { display: none; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .main-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .tabs-bar { flex-direction: column; align-items: stretch; }
  .tabs { overflow-x: auto; }
  .tabs-actions { justify-content: flex-end; }
  .form-row.three { grid-template-columns: 1fr; }
  .form-row.two { grid-template-columns: 1fr; }
  .detail-columns { grid-template-columns: 1fr; }
  .modal { margin: 10px; }
  .bug-row {
    grid-template-columns: 56px 1fr 72px 72px;
  }
  .col-status { display: none; }
  .header-row .col-status { display: none; }
}
