:root {
  --background: #fff;
  --container-bg: #f8f9fa;
  --text-color: #1a1a1a;
  --text-muted: #6b7280;
  --primary: #10a37f;
  --primary-hover: #0e8b6e;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --border: #e5e7eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-lg: rgba(0, 0, 0, 0.15);
  --transition: all 0.2s ease;
}

/* Reset e configurações base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text-color);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  overflow-x: hidden;
}

/* Layout principal */
.app-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem;
  min-height: calc(100vh - 120px);
}

.container {
  background: var(--container-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border: 1px solid var(--border);
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

h1 {
  font-weight: 600;
  font-size: 1.75rem;
  color: var(--text-color);
  letter-spacing: -0.025em;
}

/* Input group */
.input-group {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
}

.input-group input {
  flex: 1;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  font-size: 1rem;
  outline: none;
  background: white;
  color: var(--text-color);
  transition: var(--transition);
  font-family: inherit;
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.input-group button {
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  min-width: 48px;
  height: 48px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 1.25rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.input-group button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.input-group button:active {
  transform: translateY(0);
}

.btn-text {
  font-weight: 600;
  margin-left: 0.25rem;
}

/* Task container */
.task-container {
  position: relative;
  min-height: 200px;
}

ul {
  list-style: none;
  padding: 0;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Empty state */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state.show {
  display: flex;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.empty-state span {
  font-size: 0.875rem;
}

/* Task items */
li {
  background: white;
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

li:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

li.fade-in {
  animation: fadeIn 0.4s ease;
}

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

li.swipe-delete {
  transform: translateX(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

li.dragging {
  opacity: 0.6;
  cursor: grabbing;
  transform: rotate(2deg);
  z-index: 10;
}

li span {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
  cursor: pointer;
  color: var(--text-color);
  font-weight: 500;
  word-break: break-word;
}

li.completed span {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.7;
  font-weight: 400;
}

.check-icon {
  color: var(--primary);
  font-size: 1.25rem;
  flex-shrink: 0;
  transition: var(--transition);
}

li.completed .check-icon {
  color: var(--primary);
  opacity: 0.8;
}

/* Actions */
.actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.actions button {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.actions button:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-hover);
}

/* Clear button */
.clear-container {
  text-align: center;
  margin-top: 0.5rem;
}

#clearCompletedBtn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
  font-weight: 500;
  cursor: pointer;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
}

#clearCompletedBtn:hover {
  background: rgba(239, 68, 68, 0.05);
  border-color: var(--danger);
  color: var(--danger-hover);
}

#clearCompletedBtn i {
  font-size: 1rem;
}

/* Toast */
#toast {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 1000;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  max-width: calc(100vw - 2rem);
  text-align: center;
}

#toast.show {
  bottom: 2rem;
  opacity: 1;
}

/* Scrollbar */
ul::-webkit-scrollbar {
  width: 6px;
}

ul::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 6px;
}

ul::-webkit-scrollbar-track {
  background: transparent;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: var(--transition);
  border-radius: 28px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: var(--transition);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* Dark mode */
body.dark {
  --background: #0f0f0f;
  --container-bg: #1a1a1a;
  --text-color: #e5e5e5;
  --text-muted: #a1a1aa;
  --border: #2a2a2a;
  --shadow: rgba(0, 0, 0, 0.3);
  --shadow-lg: rgba(0, 0, 0, 0.5);
}

body.dark li {
  background: #262626;
  border-color: #2a2a2a;
}

body.dark .input-group input {
  background: #262626;
  border-color: #2a2a2a;
  color: var(--text-color);
}

body.dark .input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.2);
}

body.dark #clearCompletedBtn {
  border-color: #2a2a2a;
}

body.dark #clearCompletedBtn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}

/* Google Ads Styling */
.ads-banner {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1rem 0;
  min-height: 50px;
}

.ads-top {
  margin-top: 0;
  margin-bottom: 1rem;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
}

.ads-middle {
  margin: 1.5rem 0;
  display: none; /* Oculto por padrão no mobile */
}

.ads-footer {
  width: 100%;
  padding: 1rem;
  margin-top: auto;
  display: flex;
  justify-content: center;
  background: rgba(0,0,0,0.02);
  border-top: 1px solid var(--border);
}

.adsbygoogle {
  display: block !important;
  width: 100%;
  max-width: 100%;
  min-height: 50px;
}

body.dark .ads-top,
body.dark .ads-footer {
  background: rgba(255,255,255,0.05);
  border-color: #2a2a2a;
}

/* Responsive Design */

/* Smartphones (até 480px) */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }
  
  .app-wrapper {
    padding: 0.5rem;
    min-height: calc(100vh - 100px);
  }
  
  .container {
    padding: 1rem;
    border-radius: var(--radius-sm);
    gap: 1rem;
    max-width: 100%;
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  .input-group {
    gap: 0.5rem;
  }
  
  .input-group input {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  
  .input-group button {
    min-width: 44px;
    height: 44px;
  }
  
  li {
    padding: 0.875rem;
  }
  
  .actions button {
    width: 32px;
    height: 32px;
    padding: 0.25rem;
  }
  
  #clearCompletedBtn {
    padding: 0.625rem 1rem;
    font-size: 0.8rem;
  }
  
  .ads-top {
    margin: 0.5rem 0;
    padding: 0.25rem;
  }
  
  .ads-footer {
    padding: 0.5rem;
  }
  
  .adsbygoogle {
    min-height: 50px;
  }
  
  #toast {
    bottom: 1rem;
    font-size: 0.8rem;
    padding: 0.75rem 1rem;
  }
  
  #toast.show {
    bottom: 1rem;
  }
}

/* Tablets (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .app-wrapper {
    padding: 1rem;
  }
  
  .container {
    max-width: 600px;
    padding: 2rem;
  }
  
  .ads-middle {
    display: flex; /* Mostrar banner intermediário em tablets */
  }
  
  .adsbygoogle {
    min-height: 90px;
  }
}

/* Desktop (769px+) */
@media (min-width: 769px) {
  .app-wrapper {
    padding: 2rem;
    align-items: center;
  }
  
  .container {
    max-width: 480px;
  }
  
  .ads-middle {
    display: flex; /* Mostrar banner intermediário em desktop */
  }
  
  .ads-footer .adsbygoogle {
    max-width: 728px;
    min-height: 90px;
  }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 600px) {
  .app-wrapper {
    padding: 0.5rem;
  }
  
  .container {
    padding: 1rem;
    gap: 1rem;
  }
  
  ul {
    max-height: 250px;
  }
  
  .ads-top {
    margin: 0.25rem 0;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .container {
    box-shadow: 0 2px 10px var(--shadow);
  }
  
  li {
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }
}

/* Touch devices */
@media (hover: none) and (pointer: coarse) {
  .input-group button,
  .actions button,
  #clearCompletedBtn {
    min-height: 44px;
    min-width: 44px;
  }
  
  li span {
    padding: 0.25rem 0;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  .ads-banner,
  .ads-footer,
  .theme-toggle,
  .input-group,
  #clearCompletedBtn {
    display: none !important;
  }
  
  .container {
    box-shadow: none;
    border: 1px solid #000;
  }
}

