/* TextFancy PWA - Mobile-Optimized Styles */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #667eea;
  --primary-dark: #764ba2;
  --background: #ffffff;
  --surface: #ffffff;
  --text: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --error: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

/* Header */
.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 64px;
  flex-wrap: wrap;
  gap: 12px;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.2s;
  color: white;
}

.logo-link:hover {
  opacity: 0.9;
}

.logo-link h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: white;
}

.logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.15);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  white-space: nowrap;
}

.plan-badge {
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 12px;
}

.plan-badge.pro {
  background: rgba(255, 215, 0, 0.3);
  color: #ffd700;
}

.usage-text {
  font-size: 12px;
  opacity: 0.95;
  font-weight: 500;
}

.header-actions .btn {
  padding: 8px 16px;
  font-size: 14px;
  white-space: nowrap;
}

/* Responsive header */
@media (max-width: 480px) {
  .header {
    padding: 12px 16px;
    min-height: 56px;
  }
  
  .logo {
    width: 32px;
    height: 32px;
  }
  
  .header h1 {
    font-size: 18px;
  }
  
  .user-info {
    padding: 6px 10px;
    font-size: 11px;
    gap: 6px;
  }
  
  .plan-badge {
    font-size: 11px;
    padding: 2px 8px;
  }
  
  .usage-text {
    font-size: 11px;
  }
  
  .header-actions .btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* Login View */
.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
  padding: 20px;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.login-view.show {
  opacity: 1;
  transform: scale(1);
}

.login-container {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.login-container h2 {
  text-align: center;
  margin-bottom: 24px;
  color: var(--text);
  font-size: 24px;
}

.login-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.login-tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: -2px;
}

.login-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.privacy-link-top {
  text-align: center;
  margin-top: 16px;
  margin-bottom: 8px;
}

.privacy-link-top a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.privacy-link-top a:hover {
  text-decoration: underline;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 200px; /* Prevent layout shift */
}

.login-form > * {
  margin: 0; /* Reset margins to ensure consistent spacing */
}

.login-form input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  box-sizing: border-box;
  margin: 0; /* Ensure no margin */
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-form .status {
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  display: none;
  margin: 0; /* Ensure no margin */
}

.login-form .status.show {
  display: block;
}

.login-form .status.error {
  background: #fee2e2;
  color: var(--error);
  border: 1px solid var(--error);
}

.login-form .status:not(.error) {
  background: #d1fae5;
  color: var(--success);
  border: 1px solid var(--success);
}

.forgot-password-link {
  text-align: center;
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  margin-top: -8px;
  transition: opacity 0.2s;
}

.forgot-password-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.reset-info {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
  text-align: center;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.divider span {
  padding: 0 12px;
}

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  background: white;
  color: var(--text);
  font-weight: 500;
  transition: all 0.2s;
}

.btn-social:hover {
  background: var(--background);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-google {
  border-color: #db4437;
}

.btn-google:hover {
  border-color: #db4437;
  background: #fef5f4;
}

.btn-facebook {
  border-color: #1877f2;
  color: #1877f2;
}

.btn-facebook:hover {
  border-color: #1877f2;
  background: #f0f7ff;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.main-content.show {
  opacity: 1;
  transform: translateY(0);
}

.privacy-link-main {
  text-align: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.privacy-link-main a {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.privacy-link-main a:hover {
  text-decoration: underline;
}

/* Sections */
.input-section,
.intention-section,
.language-section,
.style-section,
.result-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Text Input */
.text-input {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  min-height: 140px;
  transition: all 0.2s ease;
  background: var(--background);
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.word-count {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
}

.word-count.warning {
  color: var(--warning);
  font-weight: 600;
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 16px;
  border: 2px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.chip:active {
  transform: scale(0.95);
}

.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Buttons */
.action-buttons,
.result-actions {
  display: flex;
  gap: 12px;
}

.btn {
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

/* Buttons in action containers should flex */
.action-buttons .btn,
.result-actions .btn {
  flex: 1;
}

/* Login form buttons should be full width but not flex */
.login-form .btn {
  flex: none;
  width: 100%;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:active {
  background: var(--background);
}

/* Result Box */
.result-box {
  padding: 16px;
  background: #f8f9fa;
  border: 2px solid var(--border);
  border-radius: 8px;
  min-height: 120px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 16px;
  line-height: 1.6;
  margin-top: 8px;
  margin-bottom: 12px;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: var(--text-secondary);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error */
.error {
  padding: 16px;
  background: #fee2e2;
  border: 2px solid var(--error);
  border-radius: 8px;
  color: var(--error);
  font-weight: 500;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 10000;
  transition: transform 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Footer */
.footer {
  padding: 20px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border);
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer a {
  color: var(--primary);
  text-decoration: none;
  transition: opacity 0.2s;
}

.footer a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.footer a:active {
  opacity: 0.6;
}

.footer span {
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 480px) {
  .main-content {
    padding: 16px;
  }
  
  .header {
    padding: 16px;
  }
  
  .header h1 {
    font-size: 20px;
  }
  
  .chips {
    gap: 6px;
  }
  
  .chip {
    padding: 6px 12px;
    font-size: 13px;
  }
}

/* RTL Support */
.result-box.rtl {
  direction: rtl;
  text-align: right;
}
