/* ================================================================
   LogiTrack — Custom Stylesheet
   Stack: Bootstrap 5 + custom SaaS design system
================================================================ */

/* ── Admin overrides ─────────────────────────────────────────────*/
.admin-navbar { background: #1e1b4b !important; border-bottom: 2px solid #4f46e5; }
.admin-navbar .brand-text   { color: #a5b4fc !important; }
.admin-navbar .brand-icon   { background: linear-gradient(135deg,#6d28d9,#4f46e5); }
.admin-navbar .nav-link     { color: #c7d2fe !important; }
.admin-navbar .nav-link:hover  { background: rgba(99,102,241,.2) !important; color: #e0e7ff !important; }
.admin-navbar .nav-link.active { background: #4f46e5 !important; color: #ffffff !important; border-radius: var(--radius-sm); }
.admin-navbar .company-pill { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #c7d2fe; }
.admin-navbar .company-name { color: #e0e7ff; }
.admin-navbar .gstin-badge  { color: #818cf8; }
.admin-navbar .btn-logout   { border-color: rgba(255,255,255,.2); color: #c7d2fe; }
.admin-navbar .btn-logout:hover { background: rgba(239,68,68,.2); border-color: #ef4444; color: #fca5a5; }

.admin-badge {
  display: inline-block;
  background: #fbbf24;
  color: #78350f;
  font-size: .6rem;
  font-weight: 800;
  padding: .15rem .55rem;
  border-radius: 999px;
  letter-spacing: .5px;
  vertical-align: middle;
}
.admin-panel-badge {
  display: inline-flex;
  align-items: center;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: .3rem .85rem;
  font-size: .75rem;
  font-weight: 700;
}
.admin-pill { background: rgba(99,102,241,.12) !important; border-color: rgba(99,102,241,.3) !important; }

/* Admin summary card variant */
.summary-pending .summary-icon { background: #fef3c7; color: #d97706; }

/* Company cell */
.company-cell-name { font-weight: 600; color: #0f172a; }

/* Email action card */
.email-action-card { border: 1px solid #bfdbfe !important; }
.email-action-card .detail-card-header { background: #eff6ff; color: #1e40af; border-bottom-color: #bfdbfe; }

/* Send email button */
.btn-email {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: .875rem;
  padding: .65rem 1.25rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: 0 2px 10px rgba(37,99,235,.3);
}
.btn-email:hover { opacity: .9; color: #fff; transform: translateY(-1px); }

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
  --primary:        #4f46e5;
  --primary-dark:   #3730a3;
  --primary-light:  #ede9fe;
  --success:        #10b981;
  --success-light:  #d1fae5;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --danger:         #ef4444;
  --danger-light:   #fee2e2;
  --info:           #3b82f6;
  --info-light:     #dbeafe;

  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #e2e8f0;
  --border-hover:   #cbd5e1;
  --text-primary:   #0f172a;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;

  --navbar-h:       64px;
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:      0 10px 40px rgba(0,0,0,.12);
  --transition:     all .18s ease;
}

/* ── Reset / Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--surface-2);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ================================================================
   NAVBAR
================================================================ */
.app-navbar {
  min-height: var(--navbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1rem;
}

.brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.3px;
}

.app-navbar .nav-link {
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  padding: .4rem .75rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
}

.company-pill {
  display: flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .3rem .9rem;
  font-size: .8125rem;
  color: var(--text-secondary);
  gap: .25rem;
}
.company-name { font-weight: 600; color: var(--text-primary); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gstin-badge  { font-family: monospace; font-size: .75rem; color: var(--text-muted); }

.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  font-weight: 500;
  transition: var(--transition);
}
.btn-logout:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Main layout ──────────────────────────────────────────────── */
.app-main { padding-top: 0; min-height: calc(100vh - var(--navbar-h)); }

/* ── Page title ───────────────────────────────────────────────── */
.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.3px;
}

/* ================================================================
   BUTTONS
================================================================ */
.btn-primary-custom {
  background: var(--primary);
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: .875rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(79,70,229,.25);
}
.btn-primary-custom:hover {
  background: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,70,229,.35);
  transform: translateY(-1px);
}
.btn-primary-custom:active { transform: none; }

.btn-back {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-back:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary-light); }

.btn-view {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: .3rem .6rem;
  transition: var(--transition);
}
.btn-view:hover { background: var(--primary); color: #fff; }

/* ================================================================
   SUMMARY CARDS
================================================================ */
.summary-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  transition: var(--transition);
}
.summary-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.summary-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.summary-total   .summary-icon { background: var(--primary-light); color: var(--primary); }
.summary-active  .summary-icon { background: var(--warning-light);  color: var(--warning); }
.summary-completed .summary-icon { background: var(--success-light); color: var(--success); }

.summary-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
  letter-spacing: -1px;
}
.summary-label {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-top: .2rem;
  font-weight: 500;
}

/* ================================================================
   FILTER CARD
================================================================ */
.filter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
}
.filter-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  display: block;
  margin-bottom: .35rem;
}

/* ================================================================
   TABLE CARD
================================================================ */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.app-table { font-size: .875rem; }
.app-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  padding: .875rem 1rem;
  white-space: nowrap;
  user-select: none;
}
.app-table thead th.sortable { cursor: pointer; }
.app-table thead th.sortable:hover { color: var(--primary); }
.sort-icon { font-size: .7rem; vertical-align: middle; margin-left: .2rem; }

.app-table tbody td {
  padding: .875rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.app-table tbody tr:last-child td { border-bottom: none; }
.app-table tbody tr:hover { background: #f8fafc; }

.token-id   { font-family: monospace; font-weight: 700; color: var(--primary); font-size: .875rem; }
.token-title { font-weight: 500; color: var(--text-primary); }
.date-cell   { font-size: .8125rem; line-height: 1.4; }
.date-range  { font-size: .8125rem; white-space: nowrap; }
.completed-by { font-size: .8125rem; color: var(--success); }

/* ── Status badges ────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: .25rem .75rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}
.badge-pending     { background: var(--warning-light); color: #92400e; }
.badge-in-progress { background: var(--info-light);    color: #1e40af; }
.badge-completed   { background: var(--success-light); color: #065f46; }

/* ── Days badges ─────────────────────────────────────────────── */
.days-badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  font-weight: 700;
}
.days-good { background: var(--success-light); color: #065f46; }
.days-warn { background: var(--warning-light); color: #92400e; }
.days-bad  { background: var(--danger-light);  color: #991b1b; }

/* ── Thumbnails ───────────────────────────────────────────────── */
.thumb-row   { display: flex; gap: .35rem; align-items: center; }
.thumb-link  { display: block; border-radius: 6px; overflow: hidden; border: 2px solid var(--border); transition: var(--transition); }
.thumb-link:hover { border-color: var(--primary); transform: scale(1.06); }
.thumb-img   { width: 38px; height: 38px; object-fit: cover; display: block; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}
.empty-icon { font-size: 3rem; color: var(--text-muted); margin-bottom: 1rem; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
  gap: .75rem;
}
.pagination-info { font-size: .8125rem; color: var(--text-muted); }
.page-link { border-radius: var(--radius-sm) !important; font-size: .8125rem; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ================================================================
   LOGIN PAGE
================================================================ */
.login-page { background: linear-gradient(135deg, #ede9fe 0%, #dbeafe 100%); display: flex; align-items: center; justify-content: center; }

.login-wrapper {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.login-brand { text-align: center; margin-bottom: 2rem; }
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.75rem;
  color: #fff;
  margin-bottom: .75rem;
  box-shadow: 0 8px 24px rgba(79,70,229,.3);
}
.login-title    { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: .25rem; }
.login-subtitle { font-size: .875rem; color: var(--text-muted); margin-bottom: 0; }

.btn-login {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  color: #fff;
  font-weight: 600;
  padding: .7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: .9375rem;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(79,70,229,.3);
}
.btn-login:hover { opacity: .9; color: #fff; transform: translateY(-1px); }

.pwd-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: .25rem;
  z-index: 10;
  transition: var(--transition);
}
.pwd-toggle:hover { color: var(--primary); }

.login-footer {
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0;
}

/* ================================================================
   FORM CARD (Create Token)
================================================================ */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
}

.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

/* ── Upload / Drop Zone ──────────────────────────────────────── */
.upload-label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: .5rem;
}

.drop-zone {
  position: relative;
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  transition: var(--transition);
  min-height: 130px;
}
.drop-zone.drop-active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.drop-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  pointer-events: none;  /* let input capture clicks */
}
.drop-body.d-none { display: none !important; }

.drop-icon  { font-size: 2rem; color: var(--text-muted); margin-bottom: .5rem; }
.drop-text  { font-size: .875rem; color: var(--text-secondary); margin-bottom: .25rem; }
.drop-link  { color: var(--primary); font-weight: 600; }
.drop-hint  { font-size: .75rem; color: var(--text-muted); margin-bottom: 0; }

/* ── Image Previews ──────────────────────────────────────────── */
.preview-grid { display: flex; gap: .75rem; flex-wrap: wrap; }

.preview-card {
  position: relative;
  width: 100px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--surface-2);
  transition: var(--transition);
}
.preview-card:hover { border-color: var(--primary); }
.preview-img  { width: 100%; height: 80px; object-fit: cover; display: block; }
.preview-name { font-size: .65rem; padding: .2rem .4rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.preview-remove {
  position: absolute;
  top: 3px; right: 3px;
  background: rgba(239,68,68,.85);
  border: none;
  border-radius: 50%;
  color: #fff;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}
.preview-remove:hover { background: var(--danger); transform: scale(1.1); }

/* ================================================================
   DETAIL PAGE
================================================================ */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.detail-card-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: .875rem 1.25rem;
  font-size: .875rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
}
.detail-card-body { padding: 1.25rem; }

.detail-title { font-size: 1.125rem; font-weight: 700; color: var(--text-primary); margin-bottom: .75rem; }
.detail-desc  { color: var(--text-secondary); font-size: .9rem; line-height: 1.7; white-space: pre-wrap; margin-bottom: 0; }

.meta-table td { padding: .6rem 1.25rem; font-size: .8125rem; border-color: var(--border); }
.meta-key { color: var(--text-muted); font-weight: 600; width: 40%; text-transform: uppercase; font-size: .7rem; letter-spacing: .4px; }
.meta-val { color: var(--text-primary); }

/* Attachment grid */
.attachment-grid { display: flex; gap: .75rem; flex-wrap: wrap; }
.attachment-item {
  position: relative;
  width: 110px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border);
  transition: var(--transition);
  text-decoration: none;
  display: block;
}
.attachment-item:hover { border-color: var(--primary); }
.attachment-item:hover .attachment-overlay { opacity: 1; }

.attachment-img     { width: 100%; height: 90px; object-fit: cover; display: block; }
.attachment-overlay {
  position: absolute;
  inset: 0 0 22px;
  background: rgba(79,70,229,.55);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  opacity: 0;
  transition: var(--transition);
}
.attachment-name { font-size: .65rem; padding: .25rem .4rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ================================================================
   TOAST NOTIFICATIONS
================================================================ */
.flash-container {
  position: fixed;
  top: calc(var(--navbar-h) + 12px);
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 360px;
  pointer-events: none;
}

.toast-notification {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: .85rem 1rem;
  pointer-events: all;
  animation: slideIn .25s ease;
}

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

.toast-icon   { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg    { flex: 1; font-size: .875rem; font-weight: 500; color: var(--text-primary); }
.toast-close  { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0; font-size: .9rem; flex-shrink: 0; }
.toast-close:hover { color: var(--text-primary); }

.toast-success .toast-icon { color: var(--success); }
.toast-success { border-left: 3px solid var(--success); }
.toast-danger  .toast-icon { color: var(--danger); }
.toast-danger  { border-left: 3px solid var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    .toast-icon { color: var(--info); }
.toast-info    { border-left: 3px solid var(--info); }

/* ================================================================
   GLOBAL SPINNER
================================================================ */
.global-spinner {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.65);
  backdrop-filter: blur(3px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner-box { text-align: center; }

/* ================================================================
   RESPONSIVE TWEAKS
================================================================ */
@media (max-width: 767px) {
  .login-card   { padding: 1.75rem 1.25rem; }
  .form-card    { padding: 1.25rem; }
  .summary-card { padding: 1rem; }
  .filter-card  { padding: 1rem; }
  .company-pill { display: none; }
}

/* ================================================================
   CHAT BUBBLES
================================================================ */
.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .875rem;
  line-height: 1.6;
  word-break: break-word;
}
.chat-admin {
  align-self: flex-end;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-company {
  align-self: flex-start;
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}
.chat-meta {
  font-size: .72rem;
  margin-bottom: 4px;
  opacity: .75;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.chat-admin .chat-meta  { color: rgba(255,255,255,.85); }
.chat-company .chat-meta { color: #64748b; }
.chat-time { white-space: nowrap; }
.chat-body { white-space: pre-wrap; }
.chat-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chat-file-thumb img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,.35);
  cursor: pointer;
}
.chat-company .chat-file-thumb img { border-color: #cbd5e1; }

/* ── last-reply preview pill on dashboard ── */
.last-reply-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  color: #4f46e5;
  background: #ede9fe;
  border-radius: 99px;
  padding: 2px 10px;
  max-width: 180px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.last-reply-pill.reply-company {
  color: #0f766e;
  background: #ccfbf1;
}
