/* ==========================================================================
   ZZIP Design System 2026 - Markdown to WhatsApp
   ========================================================================== */

:root {
  /* Dynamic Theme Variables - Dark (Default) */
  --color-primary: #da2819;
  --color-primary-hover: #b51f14;
  --color-primary-alpha: rgba(218, 40, 25, 0.15);
  
  --bg-main: #171614;
  --bg-surface: #1c1b19;
  --bg-surface-hover: #262422;
  --bg-input: #131211;
  
  --text-main: #cdccca;
  --text-muted: #797876;
  --text-on-primary: #ffffff;
  
  --border-color: #393836;
  --border-focus: #da2819;
  
  /* WhatsApp Preview Dark Theme */
  --wa-header-bg: #1f2c34;
  --wa-body-bg: #0b141a;
  --wa-bubble-bg: #005c4b;
  --wa-text-color: #e9edef;
  --wa-meta-color: #8696a0;
  --wa-tick-color: #53bdeb;

  /* Fonts */
  --font-display: 'DM Sans', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'Fira Code', monospace;

  /* Shadows */
  --shadow-sm: 0 2px 8px -1px oklch(0% 0 0 / 0.2);
  --shadow-md: 0 6px 20px -2px oklch(0% 0 0 / 0.35);
  --shadow-lg: 0 12px 32px -4px oklch(0% 0 0 / 0.45);
  
  /* Border Radius (Squircle look) */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  
  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] {
  --bg-main: #f7f6f2;
  --bg-surface: #f9f8f5;
  --bg-surface-hover: #efeee9;
  --bg-input: #ffffff;
  
  --text-main: #28251d;
  --text-muted: #7a7974;
  
  --border-color: #d4d1ca;
  
  /* WhatsApp Preview Light Theme */
  --wa-header-bg: #008069;
  --wa-body-bg: #efeae2;
  --wa-bubble-bg: #d9fdd3;
  --wa-text-color: #111b21;
  --wa-meta-color: #667781;
  --wa-tick-color: #53bdeb;

  --shadow-sm: 0 2px 8px -1px oklch(20% 0 0 / 0.05);
  --shadow-md: 0 6px 20px -2px oklch(20% 0 0 / 0.08);
  --shadow-lg: 0 12px 32px -4px oklch(20% 0 0 / 0.12);
}

/* ==========================================================================
   Base Styles & Reset
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  transition: background-color var(--transition-normal), color var(--transition-normal);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* ==========================================================================
   Header
   ========================================================================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand .logo {
  height: 38px;
  width: auto;
  object-fit: contain;
  transition: transform var(--transition-fast);
}

.brand .logo:hover {
  transform: scale(1.04);
}

.brand-info h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-info h1 span {
  color: var(--color-primary);
}

.brand-info p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

/* Buttons */
button {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--text-on-primary);
  padding: 10px 18px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(218, 40, 25, 0.3);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(218, 40, 25, 0.4);
}

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

.btn-secondary {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 9px 16px;
}

.btn-secondary:hover {
  border-color: var(--text-muted);
  background: var(--bg-input);
  color: var(--text-main);
}

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

.btn-icon {
  width: 40px;
  height: 40px;
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.2rem;
}

.btn-icon:hover {
  background: var(--color-primary-alpha);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: scale(1.05);
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  border: 1px solid transparent;
}

.btn-text:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
  border-color: var(--border-color);
}

/* ==========================================================================
   Main Grid Layout
   ========================================================================== */

.converter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  flex: 1;
}

@media (max-width: 960px) {
  .converter-grid {
    grid-template-columns: 1fr;
  }
}

/* Card Components */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.card-title i {
  font-size: 1.3rem;
  color: var(--color-primary);
}

.card-title h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

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

/* Dropdown Menu */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 100;
  display: none;
  flex-direction: column;
  padding: 6px;
  animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-item {
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  justify-content: flex-start;
  font-size: 0.85rem;
}

.dropdown-item:hover {
  background: var(--color-primary-alpha);
  color: var(--color-primary);
}

/* Toolbar */
.toolbar {
  padding: 8px 16px;
  background: var(--bg-surface-hover);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.tool-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
}

.tool-btn:hover {
  background: var(--bg-surface);
  color: var(--text-main);
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 6px;
}

/* Editor Textareas */
.editor-container {
  flex: 1;
  position: relative;
  display: flex;
  min-height: 400px;
}

textarea {
  width: 100%;
  height: 100%;
  min-height: 400px;
  padding: 20px;
  background: var(--bg-input);
  color: var(--text-main);
  border: none;
  outline: none;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.6;
  tab-size: 2;
}

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

textarea:focus {
  background: var(--bg-input);
}

/* Card Footer */
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.output-footer {
  gap: 16px;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ==========================================================================
   Tabs & Output Views
   ========================================================================== */

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

.tab-btn {
  padding: 8px 14px;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
}

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

.tab-btn.active {
  background: var(--color-primary-alpha);
  color: var(--color-primary);
  border-color: var(--color-primary);
  font-weight: 600;
}

.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  display: none;
  flex: 1;
  flex-direction: column;
}

.tab-pane.active {
  display: flex;
}

/* ==========================================================================
   WhatsApp Visual Simulator
   ========================================================================== */

.wa-simulator {
  flex: 1;
  background: var(--wa-body-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 480px;
}

.wa-header {
  background: var(--wa-header-bg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.wa-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-avatar img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.wa-user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.wa-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.wa-status {
  font-size: 0.75rem;
  opacity: 0.8;
}

.wa-header-icons {
  display: flex;
  gap: 16px;
  font-size: 1.2rem;
  opacity: 0.9;
  cursor: pointer;
}

.wa-chat-body {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 16px 16px;
  overflow-y: auto;
}

.wa-date-divider {
  align-self: center;
  background: rgba(17, 27, 33, 0.7);
  color: #8696a0;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 6px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.wa-message-bubbleSent {
  align-self: flex-end;
  max-width: 85%;
  background: var(--wa-bubble-bg);
  color: var(--wa-text-color);
  padding: 8px 12px 6px 12px;
  border-radius: 8px 0px 8px 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
  position: relative;
  word-break: break-word;
  animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.wa-message-content {
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  font-family: var(--font-body);
}

.wa-message-content p {
  margin-bottom: 6px;
}

.wa-message-content p:last-child {
  margin-bottom: 0;
}

.wa-message-content b, 
.wa-message-content strong {
  font-weight: 700;
}

.wa-message-content i, 
.wa-message-content em {
  font-style: italic;
}

.wa-message-content del {
  text-decoration: line-through;
}

.wa-message-content code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

.wa-message-content pre {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85em;
  overflow-x: auto;
  margin: 6px 0;
}

.wa-message-content blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: 10px;
  margin: 4px 0;
  opacity: 0.9;
  font-style: italic;
}

.wa-message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--wa-meta-color);
  margin-top: 4px;
}

.wa-ticks {
  color: var(--wa-tick-color);
  font-size: 0.9rem;
}

/* ==========================================================================
   Toast Notification Component
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 260px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.toast.toast-success {
  border-left: 4px solid #10b981;
}

.toast.toast-success i {
  color: #10b981;
  font-size: 1.2rem;
}

.toast.toast-info {
  border-left: 4px solid var(--color-primary);
}

.toast.toast-info i {
  color: var(--color-primary);
  font-size: 1.2rem;
}

.toast.fade-out {
  opacity: 0;
  transform: translateY(10px);
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

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

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

/* Footer */
.app-footer {
  text-align: center;
  padding: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.app-footer strong {
  color: var(--color-primary);
}
