/* Bug Helper - App-Specific Styles
 * Layer: Application (loaded after stratum-bootstrap.css)
 * Contains: sidebar, page layout, help modal, report form,
 *   attachments, field config, criticality/report-type colors
 */

/* ===== BugHelper-specific CSS Variables ===== */
:root {
  /* Criticality colors */
  --critical-color: #c50f1f;
  --critical-bg: #fef6f6;
  --critical-bg-light: #fde7e9;
  --severe-color: #da7a00;
  --severe-bg: #fefaf3;
  --severe-bg-light: #fff4ce;
  --normal-color: #11404b;
  --mild-color: #8a8a8a;
  --mild-bg: #fafafa;
  --normal-bg-light: #e8f4fc;
  --mild-bg-light: #f0f0f0;
  --mild-text: #6d6d6d;
  --unknown-bg-light: #f5f5f5;
  --unknown-color: #a0a0a0;

  /* Criticality hover colors */
  --critical-hover: #fbd4d7;
  --severe-hover: #ffebad;
  --normal-hover: #d4ebf7;
  --mild-hover: #e4e4e4;
  --unknown-hover: #ebebeb;

  /* Report type colors */
  --feature-blue: #0078d4;
  --feature-bg: #f0f7fd;
  --task-purple: #8764b8;
  --task-bg: #f9f5fd;
}

/* ===== Sidebar - Dark SR Steel ===== */
.sidebar {
  width: 160px;
  background-color: var(--sr-steel);
  position: fixed;
  top: 2rem;
  left: 0;
  height: calc(100vh - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  transition: width 0.2s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: 48px;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  height: 2.25rem;
  padding: 0.5rem 0.625rem;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.25rem;
}

.sidebar-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.625rem;
  color: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
  font-size: 0.6875rem;
}

.sidebar .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

.sidebar .nav-link.active {
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
  border-left-color: var(--sr-orange);
}

.sidebar .nav-link i {
  font-size: 1.125rem;
  min-width: 1.25rem;
  margin-right: 0.5rem;
  text-align: center;
}

.sidebar .menu-text {
  opacity: 1;
  transition: opacity 0.15s ease;
}

.sidebar.collapsed .menu-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0.5rem;
  border-left-width: 0;
}

.sidebar.collapsed .nav-link.active {
  border-bottom-color: var(--sr-orange);
  border-bottom-width: 2px;
}

.sidebar.collapsed .nav-link i {
  margin-right: 0;
}

.sidebar.collapsed .sidebar-toggle {
  justify-content: center;
  padding: 0.5rem;
}

.sidebar-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin: 0.25rem 0;
}

/* Sidebar filter area */
.sidebar-filters {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  background-color: rgba(0, 0, 0, 0.15);
}

.sidebar-filter-section {
  padding: 0.5rem;
}

.sidebar-filter-section + .sidebar-filter-section {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.sidebar-filter-label {
  display: block;
  font-size: 0.625rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.25rem;
}

.sidebar-filter-select {
  width: 100%;
  padding: 0.2rem 0.375rem;
  font-size: 0.6875rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.25rem;
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  cursor: pointer;
}

.sidebar-filter-select:focus {
  outline: none;
  border-color: var(--sr-orange);
  background-color: rgba(255, 255, 255, 0.15);
}

.sidebar-filter-select option {
  background-color: var(--sr-steel);
  color: white;
}

.sidebar-filter-section form + form {
  margin-top: 0.375rem;
}

/* Collapsed sidebar hides filters */
.sidebar.collapsed .sidebar-filters {
  display: none;
}

/* Locked dropdown style (when global filter is active) */
.form-select-locked {
  background-color: #e8e8e8;
  color: #6d6d6d;
  cursor: not-allowed;
}

/* ===== Main Content Layout ===== */
.main-content {
  margin-left: 160px;
  min-height: calc(100vh - 2rem);
  padding: 1rem 1.25rem;
  transition: margin-left 0.2s ease;
}

.sidebar-collapsed .main-content {
  margin-left: 48px;
}

/* Disable transitions during page load */
.preload .sidebar,
.preload .main-content {
  transition: none !important;
}

/* ===== Card Layout Fixes ===== */
/* Restore flex header with title left, action button right */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Inner padding for card content that isn't the header or a table */
.card > .p-3,
.card > p {
  padding: 0.75rem;
}

/* Form content inside cards: pad rows, form-groups, and action bars */
.card > form > .row,
.card > form > .form-group,
.card > form > div > .row,
.card > form > div > .form-group {
  padding: 0.375rem 0.75rem;
}

.card > form > .mt-3 {
  padding: 0 0.75rem 0.75rem;
}

.filter-bar {
  padding: 0.75rem !important;
  border-top: 1px solid var(--sr-border-light);
}

/* ===== Page Header ===== */
.page-header {
  background-color: white;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--sr-border);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===== Landing Page Header ===== */
.landing-header {
  padding: 1.5rem 2rem;
  max-width: 900px;
}

.page-title {
  color: var(--sr-dark-grey);
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0;
}

.page-description {
  color: #6d6d6d;
  font-size: 0.6875rem;
  margin-top: 0.125rem;
  line-height: 1.2;
}

.page-intro {
  color: #444;
  font-size: 0.8125rem;
  margin-top: 0.75rem;
  padding: 0.75rem 0;
  line-height: 1.5;
  max-width: 800px;
}

/* ===== Landing Page Action Buttons ===== */
.landing-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.landing-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 80px;
  background-color: white;
  border: 1px solid var(--sr-border);
  border-radius: 0.375rem;
  color: var(--sr-steel);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  gap: 0.375rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.landing-action-btn i {
  font-size: 1.25rem;
}

.landing-action-btn:hover {
  border-color: var(--sr-steel);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  color: var(--sr-steel-dark);
  text-decoration: none;
}

/* ===== Criticality Classes ===== */
.criticality-critical {
  color: var(--critical-color);
  font-weight: 600;
}

.criticality-severe {
  color: var(--severe-color);
  font-weight: 600;
}

.criticality-normal {
  color: var(--sr-dark-grey);
}

.criticality-mild {
  color: var(--mild-color);
}

.criticality-none,
.criticality-unknown {
  color: var(--unknown-color);
}

/* ===== Custom Buttons (non-Bootstrap) ===== */
.btn-task {
  background-color: var(--task-purple);
  color: white;
  border-color: #7555a8;
}

.btn-task:hover {
  background-color: #7555a8;
  color: white;
}

.btn-xs {
  padding: 0.0625rem 0.25rem;
  font-size: 0.625rem;
  line-height: 1.2;
}

/* ===== Help Modal Overlay ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-overlay.show {
  display: flex;
}

.modal-overlay .modal-content {
  background: white;
  border: 1px solid var(--sr-border);
  box-shadow: 4px 4px 8px rgba(0,0,0,0.3);
  padding: 1.25rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-overlay .modal-close {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6d6d6d;
  line-height: 1;
  padding: 0;
  width: 1.5rem;
  height: 1.5rem;
}

.modal-overlay .modal-close:hover {
  color: var(--sr-dark-grey);
}

.modal-overlay h2 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
  color: var(--sr-steel);
}

.modal-overlay h3 {
  margin: 1rem 0 0.5rem 0;
  font-size: 0.8125rem;
  color: var(--sr-dark-grey);
}

.modal-overlay p {
  margin: 0 0 0.75rem 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #4d4d4d;
}

.modal-overlay ul {
  margin: 0 0 0.75rem 0;
  padding-left: 1.25rem;
  font-size: 0.75rem;
  line-height: 1.6;
  color: #4d4d4d;
}

.modal-overlay li {
  margin-bottom: 0.25rem;
}

/* ===== File Upload ===== */
.file-upload, .file-upload-area {
  border: 1px dashed var(--sr-border);
  padding: 1rem 0.5rem;
  text-align: center;
  cursor: pointer;
  background-color: #fafafa;
}

.file-upload:hover, .file-upload-area:hover {
  border-color: var(--sr-steel);
  background-color: #f5f5f5;
}

.file-upload.drag-over, .file-upload-area.drag-over {
  border-color: var(--sr-steel);
  border-style: solid;
  background-color: #e8f4f8;
}

.file-upload input[type="file"] {
  display: none;
}

.file-upload-text {
  color: #6d6d6d;
  margin-bottom: 0.25rem;
  font-size: 0.6875rem;
}

.file-upload-icon {
  font-size: 1.5rem;
  color: #8a8a8a;
  margin-bottom: 0.25rem;
}

.file-upload-compact {
  padding: 0.75rem;
  min-height: auto;
}

.file-upload-compact .file-upload-text {
  margin: 0;
}

/* ===== Attachments ===== */
.attachment-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background-color: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 0.25rem;
}

.attachment-item.attachment-image {
  flex-direction: column;
  align-items: flex-start;
  padding: 0.5rem;
}

.attachment-icon {
  font-size: 1rem;
}

.attachment-filename {
  color: var(--sr-steel);
  text-decoration: none;
}

.attachment-filename:hover {
  text-decoration: underline;
}

.attachment-thumbnail-link {
  display: block;
}

.attachment-thumbnail {
  max-width: 120px;
  max-height: 80px;
  object-fit: cover;
  border-radius: 0.25rem;
  border: 1px solid var(--sr-border-light);
  cursor: pointer;
}

.attachment-thumbnail:hover {
  border-color: var(--sr-steel);
  opacity: 0.9;
}

.attachment-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

/* Attachment grid for edit page */
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
}

.attachment-grid .attachment-item {
  flex-direction: column;
  position: relative;
  padding: 0.625rem;
}

.attachment-grid .attachment-preview {
  width: 100%;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9f9f9;
  border: 1px solid #e0e0e0;
  border-radius: 0.25rem;
  overflow: hidden;
}

.attachment-grid .attachment-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.attachment-grid .attachment-preview.attachment-file {
  background: #f5f5f5;
}

.attachment-grid .attachment-preview .file-icon {
  font-size: 2rem;
}

.attachment-grid .attachment-info {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
  margin-top: 0.375rem;
  width: 100%;
}

.attachment-grid .attachment-filename {
  font-size: 0.6875rem;
  word-break: break-word;
  line-height: 1.3;
}

.attachment-grid .attachment-size {
  font-size: 0.625rem;
  color: #888;
}

.attachment-grid .attachment-delete {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
}

.attachment-grid .attachment-delete .btn {
  padding: 0 0.375rem;
  font-size: 0.875rem;
  line-height: 1.4;
  min-width: auto;
}

.field-required-marker {
  color: #d13438;
  font-weight: 600;
}

/* Help text input group */
.help-text-input-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.help-text-input-group .form-control {
  flex: 1;
}

.help-text-display {
  background-color: #f8f8f8;
  color: #4d4d4d;
}

.help-text-display:hover {
  background-color: #f0f0f0;
  border-color: var(--sr-steel);
}

.markdown-edit-btn {
  padding: 0.125rem 0.3125rem;
  font-size: 0.625rem;
  white-space: nowrap;
}

/* ===== Report Form with Help Panel ===== */
.report-form-container {
  display: flex;
  gap: 1rem;
}

.report-form-main {
  flex: 1;
  min-width: 0;
}

.report-help-panel {
  width: 250px;
  flex-shrink: 0;
  background: #f8f9fa;
  border: 1px solid var(--sr-border-light);
  border-radius: 0.25rem;
  display: flex;
  flex-direction: column;
  align-self: flex-start;
  position: sticky;
  top: 0.5rem;
}

.help-panel-header {
  height: 1rem;
  background: var(--sr-steel);
  border-radius: 0.25rem 0.25rem 0 0;
}

.help-panel-content {
  padding: 0.75rem;
  overflow-y: auto;
  flex: 1;
}

#help-guidance {
  min-height: 40px;
}

#help-field {
  border-top: 1px solid #e0e0e0;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

/* ===== Field Config Page ===== */
.field-config-section {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e0e0e0;
}

.field-config-section:last-child {
  border-bottom: none;
}

.field-config-category {
  font-size: 0.875rem;
  font-weight: 600;
  color: #333;
  margin: 0 0 0.75rem 0;
}

.field-config-guidance {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.field-config-guidance label {
  font-size: 0.75rem;
  color: #666;
  white-space: nowrap;
  margin: 0;
}

.field-config-guidance .guidance-input {
  flex: 1;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.field-config-table {
  margin-bottom: 0;
}

.field-config-table th {
  font-size: 0.6875rem;
  padding: 0.375rem 0.5rem;
}

.field-config-table td {
  font-size: 0.75rem;
  padding: 0.375rem 0.5rem;
  vertical-align: middle;
}

.field-config-save {
  padding: 1rem;
  text-align: center;
  border-top: 1px solid var(--sr-border-light);
  background: #f8f8f8;
}

/* ===== Markdown Modal ===== */
.markdown-modal-content {
  max-width: 600px;
  width: 95%;
}

.markdown-textarea {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 200px;
}

.table-responsive {
  overflow-x: auto;
}

/* ===== Utility Classes ===== */
.cursor-pointer { cursor: pointer; }
.form-divider { border-top: 1px solid #d4d4d4; padding-top: 12px; }
.input-narrow { width: 60px; }
.card-centered { max-width: 600px; margin: 40px auto; text-align: center; padding-bottom: 1.5rem; }
.status-icon { font-size: 48px; margin-bottom: 16px; }
.th-label { width: 150px; }

/* ===== Shared Dropdown Base ===== */
/* Base styles shared by report-detail.css (.action-dropdown)
   and table-list.css (.inline-edit-dropdown). Each file adds
   positioning and sizing overrides. */
.dropdown-menu-custom {
  display: none;
  position: absolute;
  z-index: 100;
  min-width: 120px;
  background: white;
  border: 1px solid var(--sr-border-light);
  border-radius: 0.25rem;
}

.dropdown-menu-custom.show {
  display: block;
}

.dropdown-menu-custom-item {
  cursor: pointer;
  transition: background-color 0.1s;
}

.dropdown-menu-custom-item:hover {
  background-color: #f0f0f0;
}

.dropdown-menu-custom-item.active {
  background-color: #e8f4fc;
  font-weight: 600;
}

/* ===== Login Page ===== */
.login-body {
  background-color: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 1rem;
}

.login-card {
  background: white;
  border: 1px solid var(--sr-border);
  padding: 2rem 1.5rem;
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-header h1 {
  font-size: 1.25rem;
  color: var(--sr-steel);
  margin: 0.5rem 0 0 0;
  font-weight: 600;
}

/* ===== Sidebar User Section ===== */
.sidebar-user-name {
  color: white;
  font-size: 0.6875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.sidebar-user-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.sidebar-user-link {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.5625rem;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.sidebar-user-link:hover {
  color: white;
  text-decoration: underline;
}

.sidebar-logout-btn {
  font-family: inherit;
}

/* ===== Admin User Badges ===== */
.badge-triager {
  background-color: var(--sr-blue);
  color: white;
}

.badge-change-pw {
  background-color: var(--sr-orange);
  color: white;
}

/* Narrow temp-password input in user admin table */
.input-temp-pw {
  width: 100px;
  font-size: 0.6875rem;
}

/* Centered narrow card (change password, login) */
.card-narrow {
  max-width: 450px;
  margin: 2rem auto;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    width: 48px;
  }

  .sidebar .menu-text {
    display: none;
  }

  .sidebar .nav-link {
    justify-content: center;
    padding: 0.5rem;
  }

  .sidebar .nav-link i {
    margin-right: 0;
  }

  .main-content {
    margin-left: 48px;
  }

  .report-form-container {
    flex-direction: column;
  }

  .report-help-panel {
    width: 100%;
    position: static;
  }
}
