/* ===== Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-orange: #F97316;
  --dark-text: #171717;
  --light-bg: #FFFFFF;
  --gray-border: #E5E5E5;
  --gray-text: #666666;
  --success-green: #16A34A;
  --error-red: #DC2626;
  --admin-dark: #1F2937;
  --admin-darker: #111827;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--light-bg);
  color: var(--dark-text);
  line-height: 1.6;
}

/* ===== Landing Page ===== */
.landing-page {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-container {
  width: 100%;
  max-width: 500px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
}

.landing-content {
  background: white;
  border-radius: 12px;
  padding: 50px 30px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

.logo-section {
  text-align: center;
  margin-bottom: 30px;
}

.logo {
  max-width: 120px;
  height: auto;
}

.hero-section {
  text-align: center;
  margin-bottom: 40px;
}

.hero-section h1 {
  font-size: 32px;
  color: var(--primary-orange);
  margin-bottom: 10px;
  font-weight: 700;
}

.tagline {
  color: var(--gray-text);
  font-size: 16px;
}

.token-section {
  margin-bottom: 30px;
}

.token-section h2 {
  font-size: 18px;
  margin-bottom: 15px;
  color: var(--dark-text);
}

.token-form {
  display: flex;
  gap: 10px;
}

.token-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--gray-border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: border-color 0.2s;
}

.token-input:focus {
  outline: none;
  border-color: var(--primary-orange);
}

.submit-btn {
  padding: 12px 24px;
  background-color: var(--primary-orange);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.submit-btn:hover {
  background-color: #f76f0d;
}

.submit-btn:active {
  transform: scale(0.98);
}

.error-message {
  color: var(--error-red);
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

.error-message.show {
  display: block;
}

.features {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--gray-border);
}

.feature {
  text-align: center;
}

.feature-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
}

.feature p {
  font-size: 13px;
  color: var(--gray-text);
}

.landing-footer {
  text-align: center;
  margin-top: 30px;
  color: var(--gray-text);
  font-size: 12px;
}

/* ===== Chat Page ===== */
.chat-page {
  background: #f5f5f5;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-header {
  background: white;
  border-bottom: 1px solid var(--gray-border);
  padding: 15px 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-logo {
  height: 40px;
  width: auto;
}

.header-info h1 {
  font-size: 18px;
  color: var(--primary-orange);
  margin-bottom: 2px;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.token-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-radius: 6px;
  font-size: 12px;
}

.token-code {
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.copy-btn {
  padding: 4px 8px;
  background: white;
  border: 1px solid var(--gray-border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: var(--primary-orange);
  color: white;
  border-color: var(--primary-orange);
}

.exit-btn {
  padding: 8px 16px;
  background: var(--error-red);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}

.exit-btn:hover {
  background: #b91c1c;
}

.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.welcome-message {
  text-align: center;
  padding: 40px;
  color: var(--gray-text);
}

.welcome-message h2 {
  color: var(--primary-orange);
  margin-bottom: 10px;
}

.message {
  display: flex;
  gap: 10px;
  animation: slideIn 0.3s ease-out;
}

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

.message.user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.5;
  word-wrap: break-word;
}

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

.message.assistant .message-bubble {
  background: #f0f0f0;
  color: var(--dark-text);
  border-bottom-left-radius: 4px;
}

.chat-input-area {
  padding: 20px;
  background: white;
  border-top: 1px solid var(--gray-border);
}

.chat-form {
  display: flex;
  gap: 10px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.message-input {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--gray-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  max-height: 120px;
}

.message-input:focus {
  outline: none;
  border-color: var(--primary-orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.send-btn {
  padding: 12px 24px;
  background: var(--primary-orange);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
  white-space: nowrap;
}

.send-btn:hover {
  background: #f76f0d;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-sidebar {
  width: 280px;
  background: white;
  border-left: 1px solid var(--gray-border);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-section {
  border-bottom: 1px solid var(--gray-border);
  padding-bottom: 15px;
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar-section h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-text);
  margin-bottom: 12px;
}

.documents-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.document-item {
  padding: 10px;
  background: #f5f5f5;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.document-item a {
  color: var(--primary-orange);
  text-decoration: none;
  font-weight: 600;
}

.document-item a:hover {
  text-decoration: underline;
}

.empty-state {
  color: var(--gray-text);
  font-size: 12px;
  text-align: center;
  padding: 10px;
}

.generate-docs-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary-orange);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.2s;
}

.generate-docs-btn:hover {
  background: #f76f0d;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  text-align: center;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 6px;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--gray-text);
  margin-bottom: 5px;
}

.stat-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-orange);
}

/* ===== Modals ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Generic hidden class */
.hidden {
  display: none !important;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-content h2 {
  margin-bottom: 20px;
  color: var(--dark-text);
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--dark-text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-orange);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.docs-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-primary,
.btn-secondary {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: #f76f0d;
}

.btn-secondary {
  background: #f0f0f0;
  color: var(--dark-text);
  border: 1px solid var(--gray-border);
}

.btn-secondary:hover {
  background: #e5e5e5;
}

.success-message {
  padding: 15px;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  color: #065f46;
  font-size: 13px;
  margin-top: 15px;
}

.success-message.hidden {
  display: none;
}

.token-result {
  margin-top: 10px;
  display: flex;
  gap: 10px;
}

.token-result code {
  flex: 1;
  padding: 8px;
  background: white;
  border: 1px solid #a7f3d0;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

/* ===== Admin Page ===== */
.admin-page {
  background: var(--admin-dark);
  color: #e5e7eb;
  min-height: 100vh;
}

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  background: var(--admin-darker);
  padding: 40px;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  border: 1px solid #374151;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo {
  height: 50px;
  margin-bottom: 15px;
}

.login-header h1 {
  color: var(--primary-orange);
  font-size: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-form .form-group input {
  background: #1f2937;
  border-color: #374151;
  color: #e5e7eb;
}

.login-form .form-group input:focus {
  border-color: var(--primary-orange);
  background: #374151;
}

.login-btn {
  padding: 12px;
  background: var(--primary-orange);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  margin-top: 10px;
  transition: background 0.2s;
}

.login-btn:hover {
  background: #f76f0d;
}

.admin-panel {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.admin-panel.hidden {
  display: none;
}

.admin-header {
  background: var(--admin-darker);
  padding: 20px;
  border-bottom: 1px solid #374151;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-logo {
  display: flex;
  align-items: center;
  gap: 15px;
}

.admin-logo img {
  height: 40px;
}

.admin-logo h1 {
  color: var(--primary-orange);
  font-size: 20px;
}

.logout-btn {
  padding: 10px 20px;
  background: var(--error-red);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.logout-btn:hover {
  background: #b91c1c;
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
}

.dashboard-section {
  margin-bottom: 40px;
}

.dashboard-section h2 {
  color: var(--primary-orange);
  margin-bottom: 20px;
  font-size: 22px;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--admin-darker);
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #374151;
}

.stat-title {
  color: #9ca3af;
  font-size: 13px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.stat-number {
  color: var(--primary-orange);
  font-size: 28px;
  font-weight: 700;
}

.table-container {
  overflow-x: auto;
  background: var(--admin-darker);
  border-radius: 8px;
  border: 1px solid #374151;
}

.tokens-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tokens-table thead {
  background: #1f2937;
  border-bottom: 2px solid #374151;
}

.tokens-table th {
  padding: 12px;
  text-align: left;
  color: #9ca3af;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
}

.tokens-table td {
  padding: 12px;
  border-bottom: 1px solid #374151;
  color: #e5e7eb;
}

.tokens-table tr:hover {
  background: #2d3748;
}

.tokens-table code {
  background: #111827;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  color: var(--primary-orange);
}

.status-active {
  color: var(--success-green);
  font-weight: 600;
}

.status-expired {
  color: var(--error-red);
  font-weight: 600;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.action-btn {
  padding: 6px 12px;
  background: var(--primary-orange);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}

.action-btn:hover {
  background: #f76f0d;
}

.action-btn.danger {
  background: var(--error-red);
}

.action-btn.danger:hover {
  background: #b91c1c;
}

.token-details {
  background: #1f2937;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #374151;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: #9ca3af;
  font-weight: 600;
}

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .chat-container {
    flex-direction: column;
  }

  .chat-sidebar {
    width: 100%;
    max-height: 200px;
    flex-direction: row;
    overflow-x: auto;
    border-left: none;
    border-top: 1px solid var(--gray-border);
  }

  .sidebar-section {
    min-width: 250px;
    border-right: 1px solid var(--gray-border);
    border-bottom: none;
    padding-right: 15px;
  }

  .message-bubble {
    max-width: 85%;
  }

  .header-right {
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
  }

  .token-display {
    width: 100%;
    justify-content: space-between;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .tokens-table {
    font-size: 12px;
  }

  .tokens-table th,
  .tokens-table td {
    padding: 8px;
  }
}

@media (max-width: 480px) {
  .landing-content {
    padding: 30px 20px;
  }

  .hero-section h1 {
    font-size: 24px;
  }

  .features {
    grid-template-columns: 1fr;
  }

  .token-form {
    flex-direction: column;
  }

  .submit-btn {
    width: 100%;
  }

  .message-bubble {
    max-width: 95%;
  }

  .modal-content {
    width: 95%;
  }
}

/* ===== Loading State ===== */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.spinner {
  border: 2px solid #f3f4f6;
  border-top: 2px solid var(--primary-orange);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
