/* ==============================================================
   Automoby Design System: Jira Light + Element Green
   Full Responsive (Mobile, Tablet, Desktop)
   ============================================================== */

:root {
  --jira-primary: #0052CC;
  --jira-hover: #0747A6;
  --jira-light: #DEEBFF;
  --jira-focus: rgba(0, 82, 204, 0.2);
  
  --element-primary: #0DBD8B;
  --element-hover: #0BA377;
  --element-light: #E7F9F3;
  --element-focus: rgba(13, 189, 139, 0.2);

  --bg-app: #F4F5F7;
  --bg-card: #FFFFFF;
  --bg-input: #FAFBFC;
  --bg-dark: #091E42;
  
  --border-color: #DFE1E6;
  --border-focus: #4C9AFF;
  
  --text-main: #172B4D;
  --text-muted: #5E6C84;
  --text-light: #8993A4;
  
  --danger: #DE350B;
  --danger-hover: #BF2600;
  --danger-light: #FFEBE6;
  
  --warning: #FFAB00;
  --warning-light: #FFF0B3;
  
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(9, 30, 66, 0.08);
  --shadow-md: 0 4px 14px rgba(9, 30, 66, 0.1);
  --shadow-lg: 0 8px 24px rgba(9, 30, 66, 0.14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ==============================================================
   AUTH & LOGIN SCREEN
   ============================================================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #091E42 0%, #172B4D 50%, #0747A6 100%);
}

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 36px 32px;
  animation: slideUp 0.35s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.brand-badges {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.badge-jira {
  background-color: var(--jira-primary);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.brand-plus {
  color: var(--text-muted);
  font-weight: 800;
  font-size: 14px;
}

.badge-element {
  background-color: var(--element-primary);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
}

.auth-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.field-icon {
  position: absolute;
  right: 14px;
  color: var(--text-light);
  pointer-events: none;
  transition: color 0.2s;
}

.input-with-icon input {
  padding-right: 42px !important;
}

.input-with-icon input:focus + .field-icon,
.input-with-icon input:focus ~ .field-icon {
  color: var(--jira-primary);
}

.auth-footer {
  margin-top: 24px;
  text-align: center;
}

.security-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-app);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

/* ==============================================================
   APP LAYOUT & NAVBAR
   ============================================================== */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.brand-info {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-env {
  background: var(--jira-light);
  color: var(--jira-primary);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.nav-user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-app);
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.status-dot-online {
  width: 8px;
  height: 8px;
  background-color: var(--element-primary);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px var(--element-light);
}

/* Segmented Control Tabs */
.tabs-wrapper {
  background: #FAFBFC;
  border-top: 1px solid #EBECF0;
  padding: 8px 20px;
}

.nav-tabs-segmented {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  background: #EBECF0;
  padding: 4px;
  border-radius: var(--radius-md);
  gap: 4px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 44px;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--jira-primary);
  box-shadow: 0 2px 6px rgba(9, 30, 66, 0.1);
}

/* ==============================================================
   MAIN CONTENT & CARDS
   ============================================================== */
.main-content {
  max-width: 1200px;
  width: 100%;
  margin: 24px auto;
  padding: 0 20px 40px 20px;
  flex: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  margin-bottom: 22px;
}

.card-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.5;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

/* ==============================================================
   FORMS & INPUTS (iOS & Touch Optimized)
   ============================================================== */
.form-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}

input[dir="ltr"] {
  text-align: left;
  direction: ltr;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

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

/* 16px font-size prevents iOS Safari auto-zoom on input focus */
input[type="text"],
input[type="password"],
input[type="email"],
select {
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  color: var(--text-main);
  outline: none;
  min-height: 46px;
  transition: all 0.2s ease;
  width: 100%;
}

input:focus, select:focus {
  border-color: var(--jira-primary);
  background-color: #FFFFFF;
  box-shadow: 0 0 0 3px var(--jira-focus);
}

.help-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Username Preview Box */
.username-preview-box {
  background-color: #F4F5F7;
  border: 1.5px dashed #B3D4FF;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.preview-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--jira-primary);
}

.username-preview-box code {
  font-family: 'Inter', monospace;
  font-size: 15px;
  font-weight: 800;
  color: var(--jira-primary);
  background: #FFFFFF;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid #C1C7D0;
  letter-spacing: 0.5px;
  word-break: break-all;
}

/* Pipeline Box */
.pipeline-info-box {
  background: var(--element-light);
  border: 1px solid rgba(13, 189, 139, 0.35);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 22px;
}

.pipeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #077353;
  margin-bottom: 10px;
}

.pipeline-header h4 {
  font-size: 13px;
  font-weight: 800;
}

.pipeline-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-list li {
  font-size: 12px;
  color: #075E44;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}

.pipeline-dot {
  width: 6px;
  height: 6px;
  background-color: var(--element-primary);
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

/* ==============================================================
   BUTTONS
   ============================================================== */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 44px;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--jira-primary);
  color: #FFFFFF;
}

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

.btn-element {
  background-color: var(--element-primary);
  color: #FFFFFF;
}

.btn-element:hover {
  background-color: var(--element-hover);
}

.btn-secondary {
  background-color: var(--bg-app);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: #EBECF0;
}

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

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

.btn-outline-danger {
  background-color: transparent;
  color: var(--danger);
  border-color: rgba(222, 53, 11, 0.3);
}

.btn-outline-danger:hover {
  background-color: var(--danger-light);
  border-color: var(--danger);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 48px;
  font-size: 15px;
}

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

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}

/* Alert Boxes */
.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.alert-danger {
  background-color: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(222, 53, 11, 0.3);
}

/* ==============================================================
   RESULT & HANDOVER CARD
   ============================================================== */
.result-card {
  margin-top: 24px;
  border-color: var(--element-primary);
  background: #FCFDFD;
  border-width: 1.5px;
}

.result-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.success-icon {
  width: 44px;
  height: 44px;
  background-color: var(--element-primary);
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(13, 189, 139, 0.3);
}

.result-title-group h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.result-title-group p {
  font-size: 13px;
  color: var(--text-muted);
}

.steps-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.step-chip {
  background: var(--element-light);
  color: #077353;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(13, 189, 139, 0.3);
}

.handover-box {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.handover-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.handover-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-main);
}

.handover-content {
  background: #091E42;
  color: #EBECF0;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-family: 'Vazirmatn', -apple-system, sans-serif;
  font-size: 13px;
  white-space: pre-wrap;
  direction: rtl;
  text-align: right;
  line-height: 1.8;
  border: 1px solid #253858;
  user-select: all;
  overflow-x: auto;
}

/* ==============================================================
   USERS LIST - DESKTOP & MOBILE RESPONSIVE
   ============================================================== */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 240px;
}

.search-icon {
  position: absolute;
  right: 12px;
  color: var(--text-light);
  pointer-events: none;
}

.search-box input {
  padding-right: 36px !important;
  min-height: 40px;
  font-size: 14px;
}

.btn-refresh {
  min-height: 40px;
}

/* Desktop Table View */
.desktop-table-container {
  overflow-x: auto;
  margin-top: 18px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 13px;
}

.data-table th {
  background: #FAFBFC;
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #FAFBFC;
}

.user-tag {
  font-family: 'Inter', monospace;
  font-weight: 700;
  color: var(--jira-primary);
  background: var(--jira-light);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  display: inline-block;
}

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

.status-active {
  background: var(--element-light);
  color: #077353;
  border: 1px solid rgba(13, 189, 139, 0.3);
}

.status-missing {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(222, 53, 11, 0.2);
}

.table-actions {
  display: flex;
  gap: 6px;
}

/* Mobile Cards View */
.mobile-cards-container {
  display: none;
  margin-top: 16px;
}

.user-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-card-item {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  border-bottom: 1px solid #EBECF0;
  padding-bottom: 10px;
}

.user-card-title h4 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.user-card-statuses {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #FAFBFC;
  padding: 10px;
  border-radius: var(--radius-sm);
}

.status-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-row-label {
  font-size: 11px;
  color: var(--text-muted);
}

.user-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ==============================================================
   MODALS
   ============================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 30, 66, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.btn-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
}

.modal-body {
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ==============================================================
   TOAST & SPINNER
   ============================================================== */
.toast {
  position: fixed;
  top: 70px;
  left: 20px;
  right: 20px;
  max-width: 360px;
  margin: 0 auto;
  background: rgba(9, 30, 66, 0.95);
  backdrop-filter: blur(4px);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  display: none;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  border-right: 4px solid var(--element-primary);
  animation: slideDownToast 0.25s ease-out;
  text-align: center;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--jira-light);
  border-top-color: var(--jira-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==============================================================
   RESPONSIVE BREAKPOINTS (Mobile & Tablet)
   ============================================================== */
@media (max-width: 768px) {
  .nav-container {
    padding: 8px 12px;
  }
  
  .tabs-wrapper {
    padding: 6px 12px;
  }
  
  .main-content {
    margin: 12px auto;
    padding: 0 12px 40px 12px;
  }

  .card {
    padding: 18px 14px;
    border-radius: var(--radius-md);
  }

  .two-col {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .form-row {
    margin-bottom: 14px;
  }

  .hide-mobile {
    display: none;
  }

  .brand-title {
    font-size: 13px;
  }

  .badge-env {
    display: none;
  }

  .logo-icons .badge-jira,
  .logo-icons .badge-element {
    font-size: 10px;
    padding: 3px 6px;
  }

  .admin-badge {
    padding: 4px 8px;
    font-size: 11px;
  }

  .admin-name {
    display: none;
  }

  /* Show Card View and Hide Table on Mobile */
  .desktop-table-container {
    display: none !important;
  }

  .mobile-cards-container {
    display: block !important;
  }

  .flex-between {
    flex-direction: column;
    align-items: stretch;
  }

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

  .search-box {
    min-width: unset;
    flex: 1;
  }

  .username-preview-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .username-preview-box code {
    width: 100%;
    text-align: center;
  }

  .modal-card {
    padding: 20px 16px;
    margin: 10px;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }
}
