/* ============================================
   Upwork Proposal Generator - Dashboard Styles
   Mobile-first responsive design
   ============================================ */

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

:root {
  --primary: #14a800;
  --primary-dark: #0f7a00;
  --secondary: #6772e5;
  --danger: #dc3545;
  --text: #1a1a2e;
  --text-light: #5e6c84;
  --bg: #f7f8fc;
  --card: #ffffff;
  --border: #e3e5e8;
  --success: #14a800;
  --warning: #f5a623;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

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

/* App Container */
.app {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--card);
  padding: 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

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

.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}

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

.user-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
}

/* Navigation */
.nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  flex: 1;
  min-width: 70px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

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

/* Main Content */
.content {
  flex: 1;
  padding: 16px;
}

/* Tabs */
.tab {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab.active {
  display: block;
}

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

/* Headings */
.tab h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

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

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

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

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

.hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
}

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

/* Buttons */
.btn {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

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

.btn-secondary:hover:not(:disabled) {
  background: #e8e9ec;
}

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

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  gap: 12px;
}

.input-group input {
  flex: 1;
}

/* Status Messages */
.status {
  display: inline-block;
  margin-left: 12px;
  font-size: 13px;
  color: var(--text-light);
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

/* Result Container */
.result-container {
  margin-top: 24px;
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.result-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.model-badge {
  font-size: 11px;
  padding: 4px 8px;
  background: var(--secondary);
  color: white;
  border-radius: 4px;
  font-weight: 500;
}

.proposal-output {
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 400px;
  overflow-y: auto;
}

/* Error Container */
.error-container {
  margin-top: 16px;
  padding: 16px;
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: var(--radius);
  color: var(--danger);
}

/* Stats Container */
.stats-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid var(--border);
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.filters select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 14px;
}

/* Logs Container */
.logs-container {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.log-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease;
}

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

.log-item:hover {
  background: var(--bg);
}

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

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

.log-title {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-light);
}

/* Keys List */
.keys-list {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 12px;
}

.key-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

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

.key-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}

.key-status.active {
  background: #d4edda;
  color: #155724;
}

.key-status.inactive {
  background: #f8d7da;
  color: #721c24;
}

/* Info Box */
.info-box {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
}

.info-box p {
  margin-bottom: 8px;
}

.info-box p:last-child {
  margin-bottom: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

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

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

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Loading State */
.loading {
  text-align: center;
  padding: 24px;
  color: var(--text-light);
}

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

/* Log Detail Modal */
.log-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.log-modal-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

.log-modal-header h3 {
  font-size: 16px;
}

.log-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
}

.log-modal-body {
  padding: 16px;
}

.log-modal-body h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-light);
}

.log-modal-body pre {
  background: var(--bg);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 13px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .header {
    padding: 12px;
  }
  
  .header h1 {
    font-size: 16px;
  }

  .header-top {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 10px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .content {
    padding: 12px;
  }
  
  .nav-btn {
    padding: 8px 10px;
    font-size: 13px;
    min-width: 60px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  
  .stats-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  
  .stat {
    padding: 12px 8px;
  }
  
  .stat-value {
    font-size: 20px;
  }
  
  .btn-group {
    flex-direction: column;
  }
  
  .btn-group .btn {
    width: 100%;
  }
  
  .input-group {
    flex-direction: column;
  }
  
  .filters {
    flex-direction: column;
  }
  
  .proposal-output {
    max-height: 300px;
  }
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  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); }
}

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

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Auth Page */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
}

.auth-card h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-light);
  margin-bottom: 20px;
  font-size: 14px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 168, 0, 0.1);
}

.auth-form button {
  margin-top: 6px;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
}
