/* ================================================
   Portal de Cliente - MOWISE IT Solutions
   ================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: #f0f4f8;
  color: #1f2937;
  min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ── */
.portal-topbar {
  background: #004080;
  color: white;
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.portal-topbar-logo img {
  height: 36px;
}

.portal-topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.portal-topbar-user span {
  opacity: 0.85;
}

.portal-topbar-user strong {
  color: #93c5fd;
}

.btn-logout {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.25);
  text-decoration: none;
}

/* ── Layout principal ── */
.portal-main {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.portal-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 0.25rem;
}

.portal-page-subtitle {
  color: #6b7280;
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* ── Cards ── */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e5f3ff;
}

.card-header-icon {
  width: 40px;
  height: 40px;
  background: #e5f3ff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1e3a8a;
}

.card-header p {
  font-size: 0.85rem;
  color: #6b7280;
  margin-top: 2px;
}

/* ── Grid de informações ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.info-item label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.info-item span {
  font-size: 1rem;
  color: #1f2937;
  font-weight: 500;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-active   { background: #d1fae5; color: #065f46; }
.badge-suspended { background: #fef3c7; color: #92400e; }
.badge-expired  { background: #fee2e2; color: #991b1b; }

/* ── SLA highlight ── */
.sla-highlight {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.sla-stat {
  background: #f0f7ff;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
}

.sla-stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: #2563eb;
  line-height: 1;
}

.sla-stat-value small {
  font-size: 1rem;
  font-weight: 600;
}

.sla-stat-label {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 4px;
}

/* ── Botões ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
  text-decoration: none;
  color: white;
}

.btn-outline {
  background: white;
  color: #2563eb;
  border: 2px solid #2563eb;
}

.btn-outline:hover {
  background: #eff6ff;
  text-decoration: none;
}

/* ── Placeholder (fases futuras) ── */
.coming-soon {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #9ca3af;
}

.coming-soon i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  display: block;
  color: #d1d5db;
}

.coming-soon p {
  font-size: 0.95rem;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
}

.empty-state i {
  font-size: 2rem;
  color: #d1d5db;
  margin-bottom: 0.5rem;
  display: block;
}

.empty-state p {
  color: #6b7280;
  font-size: 0.95rem;
}

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f0f4f8;
  padding: 1rem;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  text-align: center;
}

.login-card img {
  max-width: 150px;
  margin-bottom: 1.5rem;
}

.login-card h2 {
  color: #1e3a8a;
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}

.login-card p.subtitle {
  color: #6b7280;
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.form-group {
  text-align: left;
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: #2563eb;
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 1rem;
}

.alert {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-error   { background: #fef2f2; color: #dc2626; }
.alert-success { background: #f0fdf4; color: #16a34a; }
.alert-info    { background: #eff6ff; color: #2563eb; }

.login-footer {
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

/* ── Tabelas ── */
.table-wrap {
  overflow-x: auto;
}

table.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.portal-table th {
  background: #f8fafc;
  color: #374151;
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid #e5e7eb;
}

.portal-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: #4b5563;
}

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

/* ── Hamburger button ── */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  padding: 7px 9px;
  width: 38px;
  height: 38px;
}
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all 0.25s ease;
  transform-origin: center;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Nav do portal ── */
.portal-nav {
  background: white;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 2rem;
  display: flex;
  gap: 0.25rem;
  position: relative;
  z-index: 90;
}

.portal-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #6b7280;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.portal-nav a:hover,
.portal-nav a.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  text-decoration: none;
}

/* ── Admin nav (dark) ── */
.portal-nav.nav-admin {
  background: #1e3a8a;
  border-bottom: 1px solid #1d4ed8;
}
.portal-nav.nav-admin a {
  color: rgba(255,255,255,0.75);
  border-bottom-color: transparent;
}
.portal-nav.nav-admin a:hover,
.portal-nav.nav-admin a.active {
  color: white;
  border-bottom-color: #60a5fa;
}

/* ── Responsivo mobile ── */
@media (max-width: 768px) {
  .portal-topbar { padding: 0 1rem; }

  .portal-topbar-user span { display: none; } /* esconde nome em mobile */

  .hamburger-btn { display: flex; }

  .portal-nav {
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem 0;
    position: sticky;
    top: 60px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  }
  .portal-nav.nav-open { display: flex; }

  .portal-nav a {
    padding: 0.85rem 1.5rem;
    border-bottom: none;
    border-left: 3px solid transparent;
    font-size: 0.95rem;
  }
  .portal-nav a:hover,
  .portal-nav a.active {
    border-bottom: none;
    border-left-color: #2563eb;
    background: #f0f7ff;
  }
  .portal-nav.nav-admin a:hover,
  .portal-nav.nav-admin a.active {
    border-left-color: #60a5fa;
    background: rgba(255,255,255,0.1);
  }

  .portal-main { margin: 1.25rem auto; padding: 0 1rem; }
  .portal-page-title { font-size: 1.2rem; }
}

/* ── Badges de ticket ── */
.badge-open           { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress    { background: #fef3c7; color: #92400e; }
.badge-waiting_client { background: #ede9fe; color: #5b21b6; }
.badge-closed         { background: #f3f4f6; color: #6b7280; }

.badge-low    { background: #f3f4f6; color: #6b7280; }
.badge-normal { background: #dbeafe; color: #1d4ed8; }
.badge-high   { background: #fef3c7; color: #92400e; }
.badge-urgent { background: #fee2e2; color: #dc2626; }

/* ── Thread de mensagens ── */
.message-thread {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.5rem 0;
}

.message {
  max-width: 85%;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  line-height: 1.6;
}

.message-client {
  align-self: flex-end;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.message-admin {
  align-self: flex-start;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}

.message-meta {
  font-size: 0.78rem;
  color: #9ca3af;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.message-client .message-meta { justify-content: flex-end; }

.message-body {
  font-size: 0.95rem;
  color: #1f2937;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 4px 10px;
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #1d4ed8;
  text-decoration: none;
  transition: background 0.15s;
}

.attachment-link:hover {
  background: #dbeafe;
  text-decoration: none;
}

.attachment-link span {
  color: #9ca3af;
  font-size: 0.78rem;
}

/* ── Textarea de resposta ── */
.reply-area {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
  outline: none;
  transition: border-color 0.2s;
}

.reply-area:focus { border-color: #2563eb; }

/* ── Ticket row clickável ── */
.ticket-row { cursor: pointer; transition: background 0.15s; }
.ticket-row:hover td { background: #f8fafc; }

/* ── Responsivo extra-small ── */
@media (max-width: 480px) {
  .sla-highlight { grid-template-columns: 1fr 1fr; }
  .logout-label  { display: none; } /* só ícone em ecrãs muito pequenos */
}
