/* 
 * Fix My Text - Premium Styling Sheet 
 * Custom Blue & White Theme, Glassmorphism, Noto Nastaliq Urdu and Inter typography, RTL support.
 */

/* Root Custom Properties */
:root {
  --primary-color: #02529C;
  --primary-hover: #013A70;
  --primary-light: #EAF2FA;
  --accent-color: #0EA5E9;
  --success-color: #10B981;
  --success-bg: #ECFDF5;
  --error-color: #EF4444;
  --error-bg: #FEF2F2;
  --white: #ffffff;
  
  --bg-gradient: linear-gradient(135deg, #F4F8FC 0%, #E6EEF8 100%);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(2, 82, 156, 0.12);
  --card-shadow: 0 12px 36px rgba(2, 82, 156, 0.08);
  --card-shadow-hover: 0 20px 48px rgba(2, 82, 156, 0.14);
  
  --text-main: #1E293B;
  --text-muted: #64748B;
  --border-radius-lg: 20px;
  --border-radius-md: 12px;
  
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-urdu: 'Noto Nastaliq Urdu', 'Dubai', 'Jameel Noori Nastaleeq', 'Tahoma', 'Arial', sans-serif;
  
  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset and Global Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-family: var(--font-sans);
  color: var(--text-main);
  background: var(--bg-gradient);
  min-height: 100vh;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Accessibility: Skip to Main Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 20px;
  background: var(--primary-color);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--accent-color);
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Base Layout Containers */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header Styling */
.app-header {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.brand-logo {
  border-radius: 10px;
  transition: transform var(--transition-normal);
}

.logo-area:hover .brand-logo {
  transform: scale(1.08) rotate(5deg);
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1.2;
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-nav {
  display: flex;
  gap: 20px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color var(--transition-fast);
  padding: 8px 12px;
  border-radius: var(--border-radius-md);
}

.nav-link:hover, .nav-link:focus {
  color: var(--primary-color);
  background: var(--primary-light);
  outline: none;
}

/* Main Grid Area */
.main-layout {
  flex: 1;
  padding-top: 32px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* AdSense Banner Placeholders */
.ad-placeholder {
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed rgba(2, 82, 156, 0.25);
  border-radius: var(--border-radius-md);
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
}

.ad-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.ad-box-resp {
  width: 100%;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 82, 156, 0.03);
  border-radius: var(--border-radius-md);
}

/* Top and bottom banner sizes */
.top-banner, .bottom-banner {
  max-height: 140px;
}

.middle-banner {
  max-height: 120px;
}

/* Central Editor Structure */
.editor-section {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Card Structures with Premium Shadows and Rounded Corners */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: box-shadow var(--transition-normal), transform var(--transition-normal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.card:hover {
  box-shadow: var(--card-shadow-hover);
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.4);
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--white);
  letter-spacing: 0.5px;
}

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

.bg-success {
  background-color: var(--success-color);
}

.card-heading {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

/* Dynamic Language Indicator Badge */
.lang-detector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  padding: 6px 12px;
  border-radius: 30px;
  border: 1px solid var(--card-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
  transition: background-color var(--transition-fast);
}

.lang-detector.detecting .indicator-dot {
  background-color: var(--accent-color);
  animation: pulse-dot 1.5s infinite;
}

.lang-detector.english .indicator-dot {
  background-color: var(--primary-color);
}

.lang-detector.urdu .indicator-dot {
  background-color: var(--success-color);
}

/* Textarea Layout and Formatting */
.textarea-container {
  position: relative;
  width: 100%;
}

textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 24px;
  font-size: 16px;
  font-family: var(--font-sans);
  color: var(--text-main);
  resize: vertical;
  line-height: 1.7;
}

textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

textarea:focus-visible {
  background: rgba(2, 82, 156, 0.01);
}

/* Output Text Box Container */
.output-container {
  min-height: 180px;
  max-height: 600px;
  overflow-y: auto;
  padding: 24px;
}

#fixed-text-output {
  width: 100%;
  font-size: 16px;
  font-family: var(--font-sans);
  color: var(--text-main);
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  outline: none;
  min-height: 132px;
}

#fixed-text-output.placeholder-text {
  color: var(--text-muted);
  opacity: 0.75;
  user-select: none;
}

/* Custom RTL Text Alignment rules for Noto Nastaliq Urdu */
.rtl-active {
  direction: rtl;
  text-align: right;
  font-family: var(--font-urdu) !important;
  line-height: 2.2 !important;
  font-size: 19px !important;
}

/* Card Footers */
.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.text-metrics {
  display: flex;
  gap: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.metric strong {
  color: var(--text-main);
}

/* Interactive Buttons */
.button-group {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--border-radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  user-select: none;
  transition: all var(--transition-fast);
}

.btn-icon {
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.btn:hover .btn-icon {
  transform: translateY(-1px);
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(2, 82, 156, 0.2);
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(2, 82, 156, 0.3);
}

.btn-primary:active {
  transform: translateY(1px);
}

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

.btn-secondary:hover, .btn-secondary:focus {
  background-color: var(--primary-light);
  border-color: rgba(2, 82, 156, 0.3);
  color: var(--primary-color);
}

.btn.disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Status / Ready Indicator on Output Card */
.status-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--primary-light);
  padding: 6px 14px;
  border-radius: 30px;
  border: 1px solid rgba(2, 82, 156, 0.1);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.status-badge.processing {
  color: var(--accent-color);
  background-color: #F0F9FF;
  border-color: rgba(14, 165, 233, 0.15);
}

.status-badge.processing::before {
  background-color: var(--accent-color);
  animation: pulse-dot 1.2s infinite;
}

.status-badge.success {
  color: var(--success-color);
  background-color: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.15);
}

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

.status-badge.error {
  color: var(--error-color);
  background-color: var(--error-bg);
  border-color: rgba(239, 68, 68, 0.15);
}

.status-badge.error::before {
  background-color: var(--error-color);
}

/* Interactive Loading Ripple Overlay */
.loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.loader-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.ripple-ring {
  display: inline-block;
  position: relative;
  width: 64px;
  height: 64px;
}

.ripple-ring div {
  position: absolute;
  border: 4px solid var(--primary-color);
  opacity: 1;
  border-radius: 50%;
  animation: ripple-ring-anim 1.2s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.ripple-ring div:nth-child(2) {
  animation-delay: -0.5s;
}

.loader-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

/* Info Bento Grid Styles */
.info-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.grid-col-2 {
  grid-column: span 2;
}

.info-card {
  padding: 28px;
  background-color: var(--white);
}

.info-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 12px;
}

.info-card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.info-card p:not(:last-child) {
  margin-bottom: 12px;
}

/* Toast System (Accessible Alert boxes) */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  max-width: 380px;
  width: calc(100% - 48px);
}

.toast {
  background: var(--white);
  border-left: 4px solid var(--error-color);
  border-radius: var(--border-radius-md);
  padding: 16px 20px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-content h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.toast-content p {
  font-size: 13px;
  color: var(--text-muted);
}

.toast-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
}

.toast-close:hover {
  color: var(--text-main);
}

/* Footer layout */
.app-footer {
  background-color: var(--white);
  border-top: 1px solid var(--card-border);
  padding: 48px 0 24px 0;
  margin-top: 64px;
}

.footer-container {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 40px;
  margin-bottom: 32px;
}

.footer-brand {
  max-width: 320px;
}

.footer-logo {
  border-radius: 6px;
  margin-bottom: 12px;
}

.footer-brand h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.footer-brand p {
  font-size: 13px;
  color: var(--text-muted);
}

.footer-links-group {
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
}

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

.links-column h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.links-column a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.links-column a:hover {
  color: var(--primary-color);
}

.powered-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
}

.footer-bottom {
  border-top: 1px solid var(--card-border);
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Modals layout */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(2, 82, 156, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal {
  background-color: var(--white);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  max-width: 500px;
  width: calc(100% - 32px);
  overflow: hidden;
  animation: modal-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.btn-close-modal {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  transition: color var(--transition-fast);
}

.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-body p {
  font-size: 14px;
  margin-bottom: 16px;
  color: var(--text-main);
}

.modal-body ul {
  padding-left: 20px;
  margin-bottom: 16px;
}

.modal-body li {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Animations and Keyframes */
@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes ripple-ring-anim {
  0% {
    top: 32px;
    left: 32px;
    width: 0;
    height: 0;
    opacity: 0;
  }
  4.9% {
    top: 32px;
    left: 32px;
    width: 0;
    height: 0;
    opacity: 0;
  }
  5% {
    top: 32px;
    left: 32px;
    width: 0;
    height: 0;
    opacity: 1;
  }
  100% {
    top: 0px;
    left: 0px;
    width: 64px;
    height: 64px;
    opacity: 0;
  }
}

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

@keyframes modal-enter {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* Keyboard and focus indicators (WCAG) */
button:focus-visible, 
textarea:focus-visible, 
a:focus-visible,
div[tabindex="0"]:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

/* Pulse animation utility */
.pulse {
  animation: pulse-button 2s infinite;
}

@keyframes pulse-button {
  0% { box-shadow: 0 0 0 0 rgba(2, 82, 156, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(2, 82, 156, 0); }
  100% { box-shadow: 0 0 0 0 rgba(2, 82, 156, 0); }
}

/* Responsive Grid Breakpoints */
@media (max-width: 900px) {
  .info-section {
    grid-template-columns: 1fr;
  }
  .grid-col-2 {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .header-container {
    padding: 0 16px;
  }
  .main-layout {
    padding: 20px 16px;
  }
  .footer-container {
    flex-direction: column;
    gap: 32px;
  }
  .footer-links-group {
    flex-direction: column;
    gap: 24px;
  }
  .card-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .button-group {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
}
