/* ReplyGenius - AI-Powered Email Response System */
/* Design System Colors */
:root {
  --primary-blue: #2563EB;
  --primary-blue-hover: #1D4ED8;
  --success-green: #059669;
  --success-green-light: #D1FAE5;
  --warning-amber: #D97706;
  --warning-amber-light: #FEF3C7;
  --demo-purple: #7C3AED;
  --demo-purple-light: #EDE9FE;
  --info-blue-light: #EFF6FF;
  --gray-900: #111827;
  --gray-700: #374151;
  --gray-600: #4B5563;
  --gray-500: #6B7280;
  --gray-400: #9CA3AF;
  --gray-300: #D1D5DB;
  --gray-200: #E5E7EB;
  --gray-100: #F3F4F6;
  --gray-50: #F9FAFB;
  --white: #FFFFFF;
  --danger-red: #DC2626;
  --danger-red-light: #FEE2E2;

  --sidebar-width: 260px;
  --header-height: 60px;
  --bottom-nav-height: 70px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--gray-100);
  color: var(--gray-700);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--primary-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--gray-900);
  font-weight: 600;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar (Desktop) */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-blue);
  margin-bottom: 4px;
}

.tagline {
  font-size: 0.8rem;
  color: var(--gray-500);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--gray-600);
  text-decoration: none;
  margin-bottom: 4px;
  transition: all 0.15s ease;
}

.sidebar-nav .nav-item:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  text-decoration: none;
}

.sidebar-nav .nav-item.active {
  background: var(--info-blue-light);
  color: var(--primary-blue);
}

.sidebar-nav .nav-item svg {
  flex-shrink: 0;
}

/* Bottom Nav (Mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.75rem;
  min-width: 64px;
  min-height: 44px;
  justify-content: center;
}

.bottom-nav .nav-item.active {
  color: var(--primary-blue);
}

.bottom-nav .nav-item:hover {
  text-decoration: none;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  padding-bottom: 32px;
  min-height: 100vh;
}

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

.page-header h2 {
  font-size: 1.75rem;
}

.header-actions {
  display: flex;
  gap: 12px;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  min-height: 44px;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

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

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

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  background: var(--white);
  color: var(--danger-red);
  border: 1px solid var(--gray-300);
}

.btn-danger:hover {
  background: var(--danger-red-light);
  border-color: var(--danger-red);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  min-height: 36px;
}

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

.btn-back {
  padding-left: 12px;
}

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

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

.badge-new {
  background: var(--info-blue-light);
  color: var(--primary-blue);
}

.badge-draft {
  background: var(--warning-amber-light);
  color: var(--warning-amber);
}

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

.badge-demo {
  background: var(--demo-purple-light);
  color: var(--demo-purple);
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
}

.card-header {
  margin-bottom: 20px;
}

.card-header h3 {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.card-description {
  color: var(--gray-500);
  font-size: 0.9rem;
}

/* Demo Banner */
.demo-banner {
  background: var(--demo-purple-light);
  border: 1px solid var(--demo-purple);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}

.empty-state svg {
  color: var(--gray-400);
  margin-bottom: 16px;
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--gray-700);
}

.empty-state p {
  color: var(--gray-500);
  margin-bottom: 20px;
}

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

.message-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 16px 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.message-card:hover {
  border-color: var(--gray-300);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 12px;
}

.sender-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sender-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-blue);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  flex-shrink: 0;
}

.sender-avatar.sent {
  background: var(--success-green);
}

.sender-details {
  display: flex;
  flex-direction: column;
}

.sender-name {
  font-weight: 600;
  color: var(--gray-900);
}

.sender-email {
  font-size: 0.85rem;
  color: var(--gray-500);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.message-time {
  color: var(--gray-500);
  font-size: 0.85rem;
}

.message-body {
  margin-bottom: 12px;
}

.message-subject {
  font-size: 1rem;
  margin-bottom: 4px;
  color: var(--gray-900);
}

.message-preview {
  color: var(--gray-600);
  font-size: 0.9rem;
  line-height: 1.5;
}

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

/* Response View (Side-by-side) */
.response-view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 150px);
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-header h3 {
  font-size: 1rem;
}

.panel-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.panel-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

/* Message Meta Info */
.message-meta-info {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}

.meta-row {
  display: flex;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.meta-row:last-child {
  margin-bottom: 0;
}

.meta-label {
  color: var(--gray-500);
  min-width: 80px;
  flex-shrink: 0;
}

.meta-value {
  color: var(--gray-900);
}

.message-full-body pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--gray-700);
}

/* Tone Selector */
.tone-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tone-selector label {
  color: var(--gray-600);
  font-size: 0.9rem;
}

.tone-selector select {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--white);
  cursor: pointer;
}

/* Response Editor */
#response-editor textarea {
  width: 100%;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 300px;
}

#response-editor textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.no-response {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.no-response p {
  margin-bottom: 16px;
}

/* Sent Response */
.sent-response {
  padding: 0;
}

.sent-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--success-green);
  font-size: 0.9rem;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--success-green-light);
  border-radius: 6px;
}

.response-text pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--gray-700);
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-content {
  background: var(--white);
  border-radius: 12px;
  padding: 32px 48px;
  text-align: center;
}

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

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

/* Search Bar */
.search-bar {
  margin-bottom: 24px;
}

.search-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}

.search-input-wrapper input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--primary-blue);
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.history-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-date {
  font-size: 0.9rem;
  color: var(--gray-500);
  font-weight: 500;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

/* Settings */
.settings-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 800px;
}

.settings-card {
  padding: 24px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 500;
  color: var(--gray-700);
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
  color: var(--gray-500);
  font-size: 0.8rem;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  padding-top: 8px;
}

/* Radio Group */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 12px 16px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  transition: all 0.15s ease;
}

.radio-label:hover {
  border-color: var(--gray-300);
}

.radio-label input[type="radio"] {
  margin-top: 4px;
}

.radio-label input[type="radio"]:checked + .radio-text {
  color: var(--primary-blue);
}

.radio-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-text strong {
  font-weight: 500;
}

.radio-text small {
  color: var(--gray-500);
  font-size: 0.85rem;
}

/* FAQ Manager */
.faq-manager {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.faq-add-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--gray-50);
  border-radius: 8px;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.faq-content {
  flex: 1;
}

.faq-question {
  margin-bottom: 8px;
  color: var(--gray-900);
}

.faq-answer {
  color: var(--gray-600);
  font-size: 0.9rem;
}

.faq-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.empty-faqs {
  text-align: center;
  padding: 24px;
  color: var(--gray-500);
  background: var(--gray-50);
  border-radius: 8px;
}

/* Demo Controls */
.demo-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.demo-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gray-300);
}

.status-indicator.active {
  background: var(--success-green);
}

.demo-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-content form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 8px;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-error {
  background: var(--danger-red-light);
  color: var(--danger-red);
  border: 1px solid var(--danger-red);
}

.alert-success {
  background: var(--success-green-light);
  color: var(--success-green);
  border: 1px solid var(--success-green);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 100px;
  right: 24px;
  background: var(--gray-900);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 1100;
  animation: slideIn 0.3s ease;
}

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

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

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-bottom: calc(var(--bottom-nav-height) + 16px);
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header h2 {
    font-size: 1.5rem;
  }

  .header-actions {
    justify-content: flex-end;
  }

  .response-view {
    grid-template-columns: 1fr;
  }

  .panel {
    max-height: none;
  }

  .panel-actions {
    flex-direction: column;
  }

  .panel-actions .btn {
    width: 100%;
  }

  .message-header {
    flex-direction: column;
    align-items: stretch;
  }

  .message-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

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

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

  .radio-group {
    gap: 8px;
  }

  .faq-item {
    flex-direction: column;
  }

  .faq-actions {
    align-self: flex-end;
  }

  .demo-actions {
    flex-direction: column;
  }

  .demo-actions .btn {
    width: 100%;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: calc(var(--bottom-nav-height) + 16px);
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 220px;
  }

  .main-content {
    margin-left: 220px;
    padding: 20px;
  }

  .response-view {
    gap: 16px;
  }
}
