/* ============================================
   PORTAL SOPORTE 24x7 - Vicidial.cl
   Hereda variables CSS del sitio principal
   ============================================ */

:root {
  --primary: #0066FF;
  --primary-dark: #0052CC;
  --primary-light: #E8F0FE;
  --secondary: #00B4D8;
  --accent: #00C853;
  --gradient: linear-gradient(135deg, #0066FF 0%, #00B4D8 100%);
  --gradient-hover: linear-gradient(135deg, #0052CC 0%, #0096B4 100%);
  --bg-body: #F0F2F5;
  --bg-card: #FFFFFF;
  --bg-dark: #0F172A;
  --text-heading: #0F172A;
  --text-body: #334155;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --border-light: #E2E8F0;
  --border-card: #E8EDF2;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --card-radius: 16px;
  --btn-radius: 10px;
  --transition-fast: 0.2s ease;
  --transition-base: 0.3s ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-body);
  background: var(--bg-body);
  min-height: 100vh;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--gradient);
  padding: 20px;
}

.login-container { width: 100%; max-width: 420px; }

.login-card {
  background: var(--bg-card);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.login-header {
  background: var(--gradient);
  padding: 40px 30px 30px;
  text-align: center;
  color: white;
}

.login-logo {
  width: 64px; height: 64px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
}

.logo-icon {
  font-size: 28px; font-weight: 800; color: white;
}

.login-header h1 {
  font-size: 22px; font-weight: 700; margin: 0;
}

.login-header p {
  font-size: 14px; opacity: 0.85; margin-top: 6px;
}

.login-form { padding: 30px; }

.login-footer {
  text-align: center; padding: 0 30px 24px;
}

.login-footer a {
  color: var(--text-muted); font-size: 13px; text-decoration: none;
}

.login-footer a:hover { color: var(--primary); }

/* ============================================
   FORMS
   ============================================ */
.form-group {
  margin-bottom: 18px; flex: 1;
}

.form-group label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #F8FAFC;
  color: var(--text-body);
  transition: var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,255,0.1);
  background: white;
}

.form-row {
  display: flex; gap: 16px;
}

.form-subtitle {
  font-size: 15px; font-weight: 600;
  color: var(--primary);
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.form-actions {
  display: flex; gap: 12px; justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  margin-top: 24px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--btn-radius);
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-fast);
  gap: 6px;
}

.btn-primary {
  background: var(--gradient);
  color: white;
}

.btn-primary:hover {
  background: var(--gradient-hover);
  box-shadow: 0 4px 12px rgba(0,102,255,0.3);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-body);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: #EF4444;
  color: white;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-full { width: 100%; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin: 0 30px 16px;
}

.alert-error {
  background: #FEF2F2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

.alert-success {
  background: #F0FDF4;
  color: #166534;
  border: 1px solid #BBF7D0;
}

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
  background: white;
  border-bottom: 1px solid var(--border-light);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex; align-items: center; gap: 12px;
}

.topbar-logo {
  width: 36px; height: 36px;
  background: var(--gradient);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: white;
}

.topbar-title {
  font-size: 16px; font-weight: 600; color: var(--text-heading);
  display: flex; align-items: center; gap: 8px;
}

.topbar-right {
  display: flex; align-items: center; gap: 12px;
}

.topbar-user {
  font-size: 13px; color: var(--text-muted);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

.badge-admin { background: #FEF3C7; color: #92400E; }
.badge-open { background: #DBEAFE; color: #1E40AF; }
.badge-in_progress { background: #FEF3C7; color: #92400E; }
.badge-resolved { background: #D1FAE5; color: #065F46; }
.badge-closed { background: #F1F5F9; color: #475569; }

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--card-radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-card);
}

.stat-number {
  font-size: 32px; font-weight: 800;
  color: var(--primary);
}

.stat-value {
  font-size: 18px; font-weight: 600;
  color: var(--text-heading);
  margin-top: 4px;
}

.stat-label {
  font-size: 13px; color: var(--text-muted);
  margin-top: 4px;
}

.stat-warning .stat-number { color: #D97706; }
.stat-success .stat-number { color: var(--accent); }

/* ============================================
   SECTION CARDS
   ============================================ */
.section-card {
  background: white;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-card);
  margin-bottom: 24px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.section-header h2 {
  font-size: 18px; font-weight: 700;
  color: var(--text-heading);
}

/* ============================================
   TABLES
   ============================================ */
.table-responsive { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

.data-table tr:hover { background: #FAFBFD; }

.data-table code {
  background: #F1F5F9;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}

.actions { white-space: nowrap; display: flex; gap: 6px; }

/* ============================================
   WELCOME CARD
   ============================================ */
.welcome-card {
  background: var(--gradient);
  border-radius: var(--card-radius);
  padding: 32px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0,102,255,0.2);
}

.welcome-card h1 {
  font-size: 24px; font-weight: 700; margin-bottom: 6px;
}

.welcome-card p {
  font-size: 14px; opacity: 0.85;
}

.welcome-card .btn {
  background: white;
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.welcome-card .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 24px;
  padding: 0 24px;
}

.tab {
  padding: 12px 20px;
  font-size: 14px; font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -2px;
  transition: var(--transition-fast);
  font-family: inherit;
}

.tab:hover { color: var(--primary); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
  padding: 0 24px;
}

.tab-content.active { display: block; }

/* ============================================
   CHAT PAGE
   ============================================ */
.chat-page {
  display: flex; flex-direction: column;
  height: 100vh;
}

.chat-container {
  flex: 1;
  display: flex; flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column;
  gap: 16px;
}

.chat-msg {
  display: flex; gap: 10px;
  max-width: 85%;
}

.chat-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg-assistant { align-self: flex-start; }

.chat-msg-avatar {
  width: 36px; height: 36px;
  background: var(--gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.chat-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.chat-msg-user .chat-msg-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-msg-bubble {
  background: white;
  border: 1px solid var(--border-card);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.chat-msg-content { word-break: break-word; }

.chat-msg-content code {
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.chat-msg-time {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

.chat-msg-user .chat-msg-time {
  color: rgba(255,255,255,0.7);
  text-align: right;
}

/* Chat Input */
.chat-input-area {
  background: white;
  border-top: 1px solid var(--border-light);
  padding: 16px 24px;
}

.chat-status {
  font-size: 13px;
  color: var(--primary);
  padding: 6px 0;
  display: flex; align-items: center; gap: 8px;
}

.chat-status::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.chat-form {
  display: flex; gap: 12px; align-items: flex-end;
}

.chat-form textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  background: #F8FAFC;
}

.chat-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.chat-form .btn {
  height: 44px;
  padding: 0 24px;
}

/* ============================================
   CHAT HISTORY (ticket view)
   ============================================ */
.chat-history {
  padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}

.chat-history .chat-msg {
  max-width: 100%;
}

.chat-msg-meta {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 4px;
}

.chat-msg-meta strong { color: var(--text-heading); }
.chat-msg-meta span { color: var(--text-light); }

/* ============================================
   TICKET META
   ============================================ */
.ticket-meta {
  padding: 16px 24px;
  display: flex; flex-wrap: wrap; gap: 20px;
  font-size: 14px;
}

/* ============================================
   REPORTS
   ============================================ */
.report-content { padding: 24px; }

.report-field {
  margin-bottom: 20px;
}

.report-field label {
  font-size: 13px; font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: block;
}

.report-field p {
  font-size: 14px; line-height: 1.7;
  color: var(--text-body);
  background: #F8FAFC;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .form-row { flex-direction: column; gap: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .welcome-card { flex-direction: column; text-align: center; gap: 16px; }
  .topbar { padding: 0 16px; }
  .topbar-user { display: none; }
  .dashboard-container { padding: 16px; }
  .chat-msg { max-width: 95%; }
  .tabs { overflow-x: auto; padding: 0 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; gap: 8px; align-items: flex-start; }
}
