/* Support Vibe - Google-inspired Design System */

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #1e8e3e;
  --success-light: #e6f4ea;
  --warning: #f9ab00;
  --warning-light: #fef7e0;
  --error: #d93025;
  --error-light: #fce8e6;
  --text-primary: #202124;
  --text-secondary: #5f6368;
  --text-disabled: #9aa0a6;
  --border: #dadce0;
  --border-light: #e8eaed;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-hover: #f1f3f4;
  --shadow-sm: 0 1px 2px rgba(60,64,67,0.1);
  --shadow-md: 0 2px 6px rgba(60,64,67,0.15);
  --shadow-lg: 0 4px 12px rgba(60,64,67,0.2);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  min-height: 100vh;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand a {
  font-size: 20px;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-links a {
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.nav-links a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-links a.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-name {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Main Content */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #c5221f;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
}

/* Cards */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 500;
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

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

.form-hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

th {
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:hover {
  background: var(--bg-hover);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 100px;
}

.badge-open {
  background: var(--success-light);
  color: var(--success);
}

.badge-closed {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.badge-pending {
  background: var(--warning-light);
  color: #b06000;
}

.badge-draft {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.badge-published {
  background: var(--success-light);
  color: var(--success);
}

.badge-admin {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-member {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* Alerts */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
}

.alert-error {
  background: var(--error-light);
  color: var(--error);
}

.alert-warning {
  background: var(--warning-light);
  color: #b06000;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 500;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 400;
  color: var(--text-primary);
}

/* Filters */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters .form-input,
.filters .form-select {
  width: auto;
  min-width: 150px;
}

/* Messages */
.message-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 14px;
  flex-shrink: 0;
}

.message-avatar.customer {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.message-content {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.message-content.own {
  background: var(--primary-light);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-sender {
  font-weight: 500;
}

.message-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.message-text {
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.message-attachments {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
}

.attachment-link:hover {
  background: var(--bg-hover);
}

/* Message Input */
.message-input-container {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.typing-indicator {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 8px;
  min-height: 18px;
}

/* Notes */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note {
  background: var(--warning-light);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.note-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
  color: #b06000;
}

.note-content {
  color: var(--text-primary);
}

/* Sidebar Layout */
.ticket-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
}

.ticket-main {
  min-width: 0;
}

.ticket-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (max-width: 900px) {
  .ticket-layout {
    grid-template-columns: 1fr;
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* Auth Pages */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

.auth-card h1 {
  font-size: 24px;
  font-weight: 400;
  text-align: center;
  margin-bottom: 8px;
}

.auth-card .auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.auth-card .form-group:last-of-type {
  margin-bottom: 24px;
}

.auth-card .btn {
  width: 100%;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Code Block */
.code-block {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.code-block .keyword { color: #569cd6; }
.code-block .string { color: #ce9178; }
.code-block .comment { color: #6a9955; }

/* Secret Display */
.secret-display {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.secret-display code {
  display: block;
  background: var(--bg-primary);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  word-break: break-all;
  margin-top: 8px;
}

/* Rich Text Editor */
.editor-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.editor-toolbar button {
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
}

.editor-toolbar button:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.editor-content {
  min-height: 300px;
  padding: 16px;
  outline: none;
}

/* AI Suggestion */
.ai-suggestion {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.ai-suggestion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--primary);
}

.ai-suggestion-content {
  background: var(--bg-primary);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.ai-suggestion-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   ADMIN TICKET DETAIL V2 - Modern Chat UI
   ============================================ */

/* Page Header */
.page-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.back-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.page-header-info h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.page-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.meta-divider {
  color: var(--border);
}

/* Ticket Layout V2 */
.ticket-layout-v2 {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  height: calc(100vh - 180px);
  min-height: 500px;
}

.ticket-layout-v2 .ticket-sidebar {
  position: sticky;
  top: 80px;
  height: fit-content;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.ticket-main-v2 {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Conversation Container */
.conversation-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-secondary);
}

.message-list-v2 {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Message Bubbles */
.message-v2 {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.message-incoming {
  align-self: flex-start;
}

.message-outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar-v2 {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.avatar-customer {
  background: #e8f5e9;
  color: #2e7d32;
}

.avatar-support {
  background: var(--primary-light);
  color: var(--primary);
}

.message-bubble {
  background: var(--bg-primary);
  padding: 12px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.message-incoming .message-bubble {
  border-bottom-left-radius: 4px;
}

.message-outgoing .message-bubble {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.message-sender-v2 {
  font-weight: 600;
}

.message-outgoing .message-sender-v2 {
  color: rgba(255,255,255,0.9);
}

.message-time-v2 {
  color: var(--text-secondary);
  font-size: 11px;
}

.message-outgoing .message-time-v2 {
  color: rgba(255,255,255,0.7);
}

.ai-tag {
  background: #fef3c7;
  color: #92400e;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

.message-text-v2 {
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Message Attachments V2 */
.message-attachments-v2 {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-thumb {
  display: block;
  max-width: 200px;
  border-radius: 8px;
  overflow: hidden;
}

.attachment-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

.attachment-video-v2 {
  max-width: 280px;
  border-radius: 8px;
}

.attachment-file-v2 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.05);
  border-radius: 6px;
  font-size: 12px;
  color: inherit;
  text-decoration: none;
}

.message-outgoing .attachment-file-v2 {
  background: rgba(255,255,255,0.2);
}

/* Typing Indicator */
.typing-indicator-v2 {
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}

/* Reply Container - Sticky */
.reply-container {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  padding: 16px 20px;
}

/* AI Suggestion V2 */
.ai-suggestion-v2 {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.ai-suggestion-header-v2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 13px;
  color: #92400e;
  margin-bottom: 8px;
}

.ai-dismiss-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: #92400e;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.ai-suggestion-content-v2 {
  background: white;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.ai-suggestion-actions-v2 {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

/* Reply Form */
.reply-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-preview-v2 {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.file-preview-v2 .file-preview-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  font-size: 12px;
}

.reply-input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.reply-input-wrapper {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.reply-input-wrapper:focus-within {
  border-color: var(--primary);
}

.reply-textarea {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  min-height: 44px;
  max-height: 150px;
  outline: none;
}

.reply-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reply-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.reply-action-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
  border-color: var(--primary);
}

.reply-action-btn.ai-btn {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #fbbf24;
  color: #92400e;
}

.reply-action-btn.ai-btn:hover {
  transform: scale(1.05);
}

.reply-send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  height: 40px;
}

/* File Upload Preview - Admin (legacy) */
.file-preview-admin {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.file-preview-admin .file-preview-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.file-preview-admin .file-preview-item span {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-remove-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.file-remove-btn:hover {
  color: var(--error);
}

.file-upload-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Loading Spinner */
.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1024px) {
  .ticket-layout-v2 {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .ticket-sidebar {
    order: -1;
  }
}

@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding: 12px;
    gap: 12px;
  }

  .nav-links {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .main-content {
    padding: 16px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .page-header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .page-header-info h1 {
    font-size: 16px;
  }

  .filters {
    flex-direction: column;
  }

  .filters .form-input,
  .filters .form-select {
    width: 100%;
  }
  
  .message-v2 {
    max-width: 95%;
  }
  
  .reply-input-row {
    flex-wrap: wrap;
  }
  
  .reply-input-wrapper {
    width: 100%;
  }
  
  .reply-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
