/* ============================================================
   FRRIDAY Support Ticket System — Master Stylesheet
   Editorial & Technical Studio Design Language
   Subdomain: https://tickets.frriday.in
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@1,9..144,400;1,9..144,600&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  /* Fonts */
  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-accent: "Fraunces", Georgia, serif;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, Menlo, monospace;

  /* Color Palette (FRRIDAY Day Theme) */
  --paper: #F7F4EE;
  --paper-2: #FDFBF6;
  --paper-3: #EFECE3;
  --ink: #1B1A17;
  --ink-soft: #423F39;
  --muted: #6B6862;
  --hairline: #E4DED2;
  --hairline-dark: #D1C9BA;

  /* Accent Colors */
  --accent: #0066FF;
  --accent-ink: #004ecc;
  --accent-glow: rgba(0, 102, 255, 0.15);
  --accent-light: #EBF2FF;

  /* Status Colors */
  --color-open: #0066FF;
  --color-open-bg: #EBF2FF;
  --color-progress: #D97706;
  --color-progress-bg: #FEF3C7;
  --color-waiting: #7C3AED;
  --color-waiting-bg: #F5F3FF;
  --color-resolved: #10B981;
  --color-resolved-bg: #ECFDF5;
  --color-closed: #64748B;
  --color-closed-bg: #F1F5F9;
  --color-urgent: #EF4444;
  --color-urgent-bg: #FEF2F2;

  /* Night Palette for Admin and Insets */
  --night: #14130E;
  --night-surface: #1C1B14;
  --night-surface-2: #232219;
  --night-ink: #F2EFE7;
  --night-muted: #8F8B80;
  --night-hairline: rgba(255, 255, 255, 0.10);

  /* Spacing & Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --maxw: 1240px;
  --maxw-narrow: 820px;
  --gutter: clamp(1rem, 0.8rem + 2vw, 2.5rem);

  /* Transitions */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --transition: 0.25s var(--ease);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background-color: var(--paper);
}

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
}

/* Typography Helpers */
.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }
.font-accent { font-family: var(--font-accent); }

/* Layout Shell */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: 2.5rem var(--gutter) 4rem;
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
}

.main-content--narrow {
  max-width: var(--maxw-narrow);
}

/* ============================================================
   HEADER & NAVIGATION
   ============================================================ */
.fr-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(247, 244, 238, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--hairline);
  padding: 0.9rem var(--gutter);
}

.fr-nav__container {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fr-nav__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.fr-nav__dot {
  color: var(--accent);
}

.fr-nav__badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  background: var(--paper-3);
  color: var(--ink-soft);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--hairline);
  text-transform: uppercase;
}

.fr-nav__links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.fr-nav__link {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: color var(--transition);
}

.fr-nav__link:hover, .fr-nav__link.active {
  color: var(--ink);
}

.fr-nav__user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn--primary {
  background-color: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn--primary:hover {
  background-color: var(--accent-ink);
  border-color: var(--accent-ink);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn--dark {
  background-color: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn--dark:hover {
  background-color: #000;
  color: #fff;
  transform: translateY(-1px);
}

.btn--outline {
  background-color: transparent;
  color: var(--ink);
  border-color: var(--hairline-dark);
}

.btn--outline:hover {
  background-color: var(--paper-3);
  border-color: var(--ink);
}

.btn--sm {
  padding: 0.4rem 0.9rem;
  font-size: 12.5px;
}

.btn--lg {
  padding: 0.85rem 1.85rem;
  font-size: 15px;
}

.btn--full {
  width: 100%;
}

.btn--success {
  background-color: var(--color-resolved);
  color: #ffffff;
}

.btn--success:hover {
  background-color: #059669;
  color: #ffffff;
}

/* ============================================================
   CARDS & CONTAINERS
   ============================================================ */
.card {
  background-color: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  box-shadow: 0 4px 20px rgba(27, 26, 23, 0.02);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card--hover:hover {
  border-color: var(--hairline-dark);
  box-shadow: 0 8px 30px rgba(27, 26, 23, 0.05);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--hairline);
}

.card__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* ============================================================
   AVATAR COMPONENT
   ============================================================ */
.fr-avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  user-select: none;
}

.fr-avatar__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fr-avatar--initials {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: -0.05em;
}

.fr-avatar__crown {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: var(--accent);
  color: #fff;
  font-size: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
}

/* ============================================================
   BADGES (STATUS & PRIORITY)
   ============================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-badge__dot {
  font-size: 9px;
  line-height: 1;
}

.status-badge--open { background: var(--color-open-bg); color: var(--color-open); border: 1px solid rgba(0, 102, 255, 0.25); }
.status-badge--inprogress { background: var(--color-progress-bg); color: var(--color-progress); border: 1px solid rgba(217, 119, 6, 0.3); }
.status-badge--waiting { background: var(--color-waiting-bg); color: var(--color-waiting); border: 1px solid rgba(124, 58, 237, 0.25); }
.status-badge--resolved { background: var(--color-resolved-bg); color: var(--color-resolved); border: 1px solid rgba(16, 185, 129, 0.3); }
.status-badge--closed { background: var(--color-closed-bg); color: var(--color-closed); border: 1px solid rgba(100, 116, 139, 0.25); }

.priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.priority-badge--low { background: #F1F5F9; color: #64748B; }
.priority-badge--medium { background: #EBF2FF; color: #0066FF; }
.priority-badge--high { background: #FEF3C7; color: #B45309; font-weight: 700; }
.priority-badge--urgent { background: #FEE2E2; color: #DC2626; font-weight: 700; animation: pulseRed 2s infinite; }

@keyframes pulseRed {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group {
  margin-bottom: 1.35rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.45rem;
}

.form-label__hint {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: #FFFFFF;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 14.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-control::placeholder {
  color: #9C988D;
}

textarea.form-control {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

/* File Upload Dropzone */
.dropzone {
  border: 2px dashed var(--hairline-dark);
  background: var(--paper-3);
  border-radius: var(--radius-md);
  padding: 1.75rem 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.dropzone__icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.dropzone__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}

.dropzone__hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.dropzone__file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.selected-files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #FFF;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ink);
}

.file-chip__remove {
  cursor: pointer;
  color: var(--muted);
  font-weight: bold;
}
.file-chip__remove:hover {
  color: var(--color-urgent);
}

/* ============================================================
   CHAT & CONVERSATION STREAM (TICKET THREAD)
   ============================================================ */
.ticket-thread {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 1.5rem 0 2.5rem;
}

.chat-bubble {
  display: flex;
  gap: 1rem;
  max-width: 90%;
}

.chat-bubble--customer {
  align-self: flex-start;
}

.chat-bubble--admin {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-bubble--note {
  align-self: center;
  max-width: 95%;
  width: 100%;
}

.chat-bubble__content {
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
  position: relative;
  min-width: 260px;
}

.chat-bubble--customer .chat-bubble__content {
  border-top-left-radius: 4px;
}

.chat-bubble--admin .chat-bubble__content {
  background: #FFFFFF;
  border-color: rgba(0, 102, 255, 0.25);
  border-top-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(0, 102, 255, 0.04);
}

.chat-bubble--note .chat-bubble__content {
  background: #FEF9C3;
  border: 1px dashed #CA8A04;
  color: #713F12;
}

.chat-bubble__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.6rem;
  font-size: 12px;
}

.chat-bubble__name {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
}

.chat-bubble__role-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: #fff;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chat-bubble__time {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 11px;
}

.chat-bubble__body {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
  word-break: break-word;
  white-space: pre-wrap;
}

/* Attachments inside Chat */
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--hairline);
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--paper-3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  transition: all var(--transition);
}

.attachment-card:hover {
  background: #FFF;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.attachment-card__icon {
  font-size: 18px;
  flex-shrink: 0;
}

.attachment-card__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.attachment-card__name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-card__size {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--muted);
}

.attachment-image-preview {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 320px;
  border: 1px solid var(--hairline);
  cursor: pointer;
}

.attachment-image-preview img {
  width: 100%;
  height: auto;
  transition: transform var(--transition);
}

.attachment-image-preview:hover img {
  transform: scale(1.02);
}

/* ============================================================
   TICKET LIST TABLE
   ============================================================ */
.ticket-table-wrapper {
  overflow-x: auto;
  background: var(--paper-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}

.ticket-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.ticket-table th {
  background: var(--paper-3);
  padding: 12px 18px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline);
}

.ticket-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}

.ticket-table tr:last-child td {
  border-bottom: none;
}

.ticket-table tr:hover td {
  background-color: rgba(0, 102, 255, 0.02);
}

.ticket-code-link {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: 13.5px;
}

.ticket-code-link:hover {
  text-decoration: underline;
}

.ticket-subject-link {
  font-weight: 600;
  color: var(--ink);
  display: block;
}

.ticket-subject-link:hover {
  color: var(--accent);
}

/* ============================================================
   FLASH ALERTS & TOASTS
   ============================================================ */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert--error {
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  color: #991B1B;
}

.alert--success {
  background: #ECFDF5;
  border: 1px solid #6EE7B7;
  color: #065F46;
}

.alert--info {
  background: #EFF6FF;
  border: 1px solid #93C5FD;
  color: #1E40AF;
}

/* ============================================================
   FOOTER
   ============================================================ */
.fr-footer {
  border-top: 1px solid var(--hairline);
  padding: 2.5rem var(--gutter) 2rem;
  background: var(--paper-2);
  margin-top: auto;
}

.fr-footer__container {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  font-size: 13px;
  color: var(--muted);
}

.fr-footer__brand {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
}

.fr-footer__links {
  display: flex;
  gap: 1.5rem;
}

.fr-footer__link:hover {
  color: var(--ink);
}

/* Responsive Mobile Rules */
@media (max-width: 768px) {
  .fr-nav__links {
    display: none;
  }
  .chat-bubble {
    max-width: 100%;
  }
  .main-content {
    padding: 1.5rem 1rem 3rem;
  }
}
