/* Reset e Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --secondary: #3b82f6;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-900: #111827;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--gray-100);
  border-radius: 20px;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gray-300);
  animation: pulse 2s infinite;
}

.status-badge.connected .status-dot {
  background: var(--primary);
}

.status-badge.error .status-dot {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Navigation */
.nav {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-btn {
  flex: 1;
  min-width: 100px;
  padding: 14px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card h2 {
  font-size: 18px;
  margin-bottom: 16px;
  font-weight: 600;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* QR Code */
.qr-container {
  text-align: center;
  padding: 20px;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-container img {
  max-width: 100%;
  height: auto;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px;
}

.instructions {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

.instructions h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--gray-700);
}

.instructions ol {
  padding-left: 20px;
}

.instructions li {
  margin-bottom: 8px;
  color: var(--gray-600);
}

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

.conversation-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.conversation-item:hover {
  background: var(--gray-100);
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.conversation-content {
  flex: 1;
  min-width: 0;
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.conversation-name {
  font-weight: 600;
  font-size: 15px;
}

.conversation-time {
  font-size: 12px;
  color: var(--gray-600);
}

.conversation-preview {
  font-size: 14px;
  color: var(--gray-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-badge {
  background: var(--warning);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  font-size: 24px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.stat-label {
  font-size: 12px;
  color: var(--gray-600);
}

/* Settings */
.setting-group {
  padding: 20px 0;
  border-bottom: 1px solid var(--gray-200);
}

.setting-group:last-child {
  border-bottom: none;
}

.setting-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.setting-group h3 {
  font-size: 16px;
  margin-bottom: 8px;
  font-weight: 600;
}

.setting-description {
  font-size: 14px;
  color: var(--gray-600);
  margin-bottom: 12px;
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--gray-700);
}

.form-group input[type="time"] {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.weekdays {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.weekdays label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--gray-100);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.weekdays input[type="checkbox"] {
  margin: 0;
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--gray-300);
  transition: 0.3s;
  border-radius: 28px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* Buttons */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

.btn-refresh {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

/* Status List */
.status-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-item {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 8px;
}

.status-value {
  font-weight: 600;
  color: var(--primary);
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-600);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  background: var(--gray-900);
  color: white;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.3s ease-out;
}

.toast.success {
  background: var(--primary);
}

.toast.error {
  background: var(--danger);
}

.toast.warning {
  background: var(--warning);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Training Interface */
.description {
  color: var(--gray-600);
  margin-bottom: 24px;
  line-height: 1.5;
}

.training-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-badge {
  flex: 1;
  background: linear-gradient(135deg, var(--primary), #1565c0);
  color: white;
  padding: 16px;
  border-radius: 12px;
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 32px;
  font-weight: bold;
  margin-bottom: 4px;
}

.stat-text {
  display: block;
  font-size: 13px;
  opacity: 0.9;
}

.training-form {
  background: #f5f5f5;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 32px;
}

.training-form h3 {
  margin: 0 0 20px 0;
  color: var(--gray-900);
  font-size: 18px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--gray-700);
  font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

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

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.training-list {
  margin-top: 32px;
}

.training-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.training-list-header h3 {
  margin: 0;
  font-size: 18px;
}

.training-filters {
  display: flex;
  gap: 8px;
  align-items: center;
}

.training-filters select {
  padding: 8px 12px;
  border: 2px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.examples-container {
  display: grid;
  gap: 16px;
}

.example-card {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s;
}

.example-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.1);
}

.example-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.example-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-category {
  background: #e3f2fd;
  color: #1976d2;
}

.badge-tone {
  background: #f3e5f5;
  color: #7b1fa2;
}

.badge-quality {
  background: #fff3e0;
  color: #f57c00;
}

.btn-delete {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.btn-delete:hover {
  background: #ffebee;
}

.example-content {
  margin-bottom: 12px;
}

.example-section {
  margin-bottom: 12px;
}

.example-section strong {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.example-section p {
  margin: 6px 0 0 0;
  line-height: 1.5;
  font-size: 14px;
}

.example-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.example-footer {
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
  text-align: right;
}

/* Responsive */
@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .training-stats {
    flex-direction: column;
  }

  .training-list-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

@media (min-width: 768px) {
  .header h1 {
    font-size: 24px;
  }

  .card {
    padding: 24px;
  }

  .main {
    padding: 32px 16px;
  }

  .qr-container {
    min-height: 400px;
  }
}

/* Commands View */
.command-input-section {
  margin-bottom: 32px;
}

.command-input-wrapper {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.command-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  transition: all 0.2s;
}

.command-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.quick-commands {
  margin-bottom: 32px;
  padding: 24px;
  background: var(--gray-50);
  border-radius: 12px;
}

.quick-commands h3 {
  margin-bottom: 16px;
  color: var(--gray-700);
}

.quick-commands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.quick-cmd-btn {
  padding: 12px 16px;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-cmd-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.quick-cmd-btn.warning:hover {
  background: var(--warning);
  border-color: var(--warning);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.command-output-section {
  margin-bottom: 32px;
}

.command-output-section h3 {
  margin-bottom: 12px;
  color: var(--gray-700);
}

.command-output {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 20px;
  border-radius: 8px;
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
}

.output-placeholder {
  color: #6b7280;
  font-style: italic;
}

.output-success {
  color: #10b981;
}

.output-error {
  color: #ef4444;
}

.output-info {
  color: #3b82f6;
}

.output-timestamp {
  color: #9ca3af;
  font-size: 11px;
  margin-top: 8px;
}

.command-history-section {
  margin-top: 32px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h3 {
  color: var(--gray-700);
}

.command-history {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.history-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item.success {
  border-left: 3px solid var(--primary);
}

.history-item.error {
  border-left: 3px solid var(--danger);
}

.history-command {
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-900);
}

.history-result {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 4px;
}

.history-timestamp {
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
}
