/* ============================================================
   ATTFT Client Dashboard  Stylesheet
   Extends the design tokens defined in css/style.css
   ============================================================ */

body { background: var(--clr-bg); }

/* ── Auth pages ── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(99,102,241,0.12), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(6,182,212,0.10), transparent 40%),
    var(--clr-bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-card);
}
.auth-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.auth-logo img { height: 36px; }
.auth-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 6px; }
.auth-sub { font-size: 0.9rem; color: var(--clr-muted); text-align: center; margin-bottom: 28px; }
.auth-footer { text-align: center; font-size: 0.85rem; color: var(--clr-muted); margin-top: 20px; }
.auth-footer a { color: var(--clr-primary-light); text-decoration: none; font-weight: 600; }
.auth-error {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  color: #f87171; font-size: 0.85rem; padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 16px; display: none;
}
.auth-error.visible { display: block; }
.btn-block { width: 100%; justify-content: center; }

/* ── Dashboard shell ── */
.dash {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .dash { grid-template-columns: 1fr; }
  .dash-sidebar { display: none; }
  .dash-sidebar.open { display: flex; position: fixed; inset: 0; z-index: 200; }
}

.dash-sidebar {
  background: var(--clr-bg2);
  border-right: 1px solid var(--clr-border);
  padding: 24px 16px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.dash-logo { display: flex; align-items: center; gap: 10px; padding: 8px 12px 24px; }
.dash-logo img { height: 28px; }
.dash-nav { list-style: none; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.dash-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--clr-muted); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: var(--transition);
  background: none; width: 100%; text-align: left;
}
.dash-nav-item svg { flex-shrink: 0; opacity: 0.8; }
.dash-nav-item:hover { background: var(--clr-surface); color: var(--clr-text); }
.dash-nav-item.active {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.25);
  color: var(--clr-primary-light);
}
.dash-nav-divider { height: 1px; background: var(--clr-border); margin: 12px 4px; }
.dash-nav-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--clr-subtle); padding: 8px 14px 4px; }
.dash-badge {
  margin-left: auto; font-size: 0.7rem; font-weight: 700;
  background: var(--clr-primary); color: #fff;
  border-radius: 100px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.dash-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--clr-surface); border: 1px solid var(--clr-border);
  margin-top: 12px;
}
.dash-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0;
}
.dash-user-info { min-width: 0; flex: 1; }
.dash-user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-user-role { font-size: 0.72rem; color: var(--clr-muted); text-transform: capitalize; }
.dash-signout { background: none; border: none; color: var(--clr-subtle); cursor: pointer; padding: 6px; flex-shrink: 0; }
.dash-signout:hover { color: #f87171; }

.dash-main { min-width: 0; }
.dash-topbar {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--clr-border);
  position: sticky; top: 0; background: var(--clr-bg); z-index: 50;
}
@media (max-width: 900px) { .dash-topbar { display: flex; } }
.dash-topbar-menu { background: none; border: 1px solid var(--clr-border); border-radius: var(--radius-sm); color: var(--clr-text); padding: 8px 10px; cursor: pointer; }

.dash-content { padding: 32px; max-width: 1200px; }
@media (max-width: 600px) { .dash-content { padding: 20px; } }
.dash-section { display: none; }
.dash-section.active { display: block; animation: dashFadeIn 0.25s ease; }
@keyframes dashFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.dash-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.dash-page-title { font-size: 1.6rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.dash-page-sub { font-size: 0.9rem; color: var(--clr-muted); margin-top: 4px; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius);
  padding: 20px;
}
.stat-card-label { font-size: 0.8rem; color: var(--clr-muted); margin-bottom: 8px; }
.stat-card-value { font-size: 1.7rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.stat-card-value.gradient-text { display: inline-block; }

/* ── Generic panels/cards ── */
.panel {
  background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius-lg);
  padding: 24px; margin-bottom: 20px;
}
.panel-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 16px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--clr-muted); }
.empty-state svg { opacity: 0.4; margin-bottom: 12px; }

/* ── Services grid ── */
.services-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-chip {
  padding: 7px 16px; border-radius: 100px; font-size: 0.82rem; font-weight: 600;
  background: var(--clr-surface); border: 1px solid var(--clr-border); color: var(--clr-muted);
  cursor: pointer; transition: var(--transition);
}
.filter-chip:hover { color: var(--clr-text); }
.filter-chip.active { background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.3); color: var(--clr-primary-light); }

.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.service-card {
  background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius);
  padding: 24px; display: flex; flex-direction: column; gap: 12px;
  transition: var(--transition);
}
.service-card:hover { border-color: var(--clr-border2); transform: translateY(-2px); }
.service-cat {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--clr-accent); align-self: flex-start;
  background: rgba(6,182,212,0.1); border: 1px solid rgba(6,182,212,0.2);
  padding: 4px 10px; border-radius: 100px;
}
.service-name { font-size: 1.1rem; font-weight: 700; }
.service-desc { font-size: 0.86rem; color: var(--clr-muted); line-height: 1.6; flex: 1; }
.service-price { font-size: 1.3rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; }
.service-price span { font-size: 0.78rem; font-weight: 500; color: var(--clr-muted); }
.service-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.btn-sm { padding: 10px 18px; font-size: 0.85rem; }
.btn-paypal { background: #ffc439; color: #003087; }
.btn-paypal:hover { background: #ffb713; }
.btn-outline {
  background: transparent; border: 1px solid var(--clr-border2); color: var(--clr-text);
}
.btn-outline:hover { border-color: var(--clr-primary); }

/* ── Tables ── */
.dash-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.dash-table th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--clr-subtle); padding: 10px 14px; border-bottom: 1px solid var(--clr-border);
}
.dash-table td { padding: 14px; border-bottom: 1px solid var(--clr-border); vertical-align: middle; }
.dash-table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem; font-weight: 600; padding: 4px 12px; border-radius: 100px;
  text-transform: capitalize;
}
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-open, .status-paid, .status-new, .status-resolved, .status-completed { color: #10b981; background: rgba(16,185,129,0.1); }
.status-pending, .status-reviewing { color: #f59e0b; background: rgba(245,158,11,0.1); }
.status-closed, .status-failed, .status-declined { color: #94a3b8; background: rgba(148,163,184,0.1); }
.status-quoted, .status-accepted { color: #6366f1; background: rgba(99,102,241,0.1); }
.status-urgent, .status-high { color: #ef4444; background: rgba(239,68,68,0.1); }

/* ── Tickets ── */
.ticket-list-item {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  border-bottom: 1px solid var(--clr-border); cursor: pointer; transition: var(--transition);
}
.ticket-list-item:last-child { border-bottom: none; }
.ticket-list-item:hover { background: var(--clr-surface2); }
.ticket-list-main { flex: 1; min-width: 0; }
.ticket-list-subject { font-weight: 600; font-size: 0.92rem; margin-bottom: 4px; }
.ticket-list-meta { font-size: 0.78rem; color: var(--clr-muted); display: flex; gap: 8px; align-items: center; }

.ticket-thread { display: flex; flex-direction: column; gap: 14px; max-height: 420px; overflow-y: auto; padding: 4px 4px 4px 0; margin-bottom: 16px; }
.msg-bubble { max-width: 75%; padding: 12px 16px; border-radius: var(--radius); font-size: 0.88rem; line-height: 1.55; }
.msg-bubble .msg-meta { font-size: 0.72rem; color: var(--clr-subtle); margin-bottom: 4px; display: block; }
.msg-mine { align-self: flex-end; background: var(--gradient); color: #fff; border-bottom-right-radius: 4px; }
.msg-mine .msg-meta { color: rgba(255,255,255,0.75); }
.msg-theirs { align-self: flex-start; background: var(--clr-surface2); border: 1px solid var(--clr-border); border-bottom-left-radius: 4px; }

.composer { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1; background: var(--clr-bg); border: 1px solid var(--clr-border2); border-radius: var(--radius-sm);
  padding: 12px 16px; color: var(--clr-text); font-family: inherit; font-size: 0.9rem; resize: none; outline: none; min-height: 46px; max-height: 140px;
}
.composer textarea:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.composer .btn { padding: 13px 20px; }

/* ── Live chat ── */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  height: min(700px, calc(100vh - 240px));
  min-height: 420px;
}
.chat-layout.has-conv-list { grid-template-columns: 280px 1fr; }
@media (max-width: 800px) {
  .chat-layout.has-conv-list { grid-template-columns: 1fr; height: auto; }
}
.chat-conv-list { background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius-lg); overflow-y: auto; }
.chat-conv-item { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--clr-border); cursor: pointer; }
.chat-conv-item:hover, .chat-conv-item.active { background: var(--clr-surface2); }
.chat-conv-name { font-size: 0.86rem; font-weight: 600; }
.chat-conv-preview { font-size: 0.76rem; color: var(--clr-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.chat-panel { background: var(--clr-surface); border: 1px solid var(--clr-border); border-radius: var(--radius-lg); display: flex; flex-direction: column; min-height: 0; }
.chat-panel-header { padding: 16px 20px; border-bottom: 1px solid var(--clr-border); font-weight: 600; display: flex; align-items: center; gap: 10px; }
.chat-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--clr-accent2); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.chat-composer { padding: 14px 16px; border-top: 1px solid var(--clr-border); display: flex; gap: 10px; }
.chat-composer input {
  flex: 1; background: var(--clr-bg); border: 1px solid var(--clr-border2); border-radius: 100px;
  padding: 12px 18px; color: var(--clr-text); font-family: inherit; font-size: 0.9rem; outline: none;
}
.chat-composer input:focus { border-color: var(--clr-primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.chat-composer button { width: 44px; height: 44px; border-radius: 50%; background: var(--gradient); border: none; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }

/* ── Floating chat launcher (client view) ── */
.chat-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  width: 58px; height: 58px; border-radius: 50%; background: var(--gradient);
  display: flex; align-items: center; justify-content: center; color: #fff; border: none; cursor: pointer;
  box-shadow: var(--shadow-glow); transition: var(--transition);
}
.chat-fab:hover { transform: scale(1.06); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; z-index: 400; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--clr-bg2); border: 1px solid var(--clr-border2); border-radius: var(--radius-lg);
  padding: 32px; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-close { float: right; background: none; border: none; color: var(--clr-muted); cursor: pointer; font-size: 1.2rem; }
.modal-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 20px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--clr-bg2); border: 1px solid var(--clr-border2); border-radius: var(--radius-sm);
  padding: 14px 22px; font-size: 0.88rem; box-shadow: var(--shadow-card);
  opacity: 0; pointer-events: none; transition: var(--transition); z-index: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(239,68,68,0.4); color: #f87171; }
.toast.success { border-color: rgba(16,185,129,0.4); color: #10b981; }

/* ── Loading ── */
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.dash-loading { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
