/* Root Variables */
:root {
  --primary-color: #05386B;
  --secondary-color: #379683;
  --accent-color: #5CDB95;
  --light-accent: #8EE4AF;
  --background-light: #EDF5E1;
  --text-dark: #2c3e50;
  --text-muted: #6c757d;
  --white: #ffffff;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --border-radius: 15px;
  --transition: all 0.3s ease;
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --primary-color: #0a4d7a;
  --secondary-color: #4aa896;
  --background-light: #1a1a1a;
  --text-dark: #ffffff;
  --text-muted: #b8b8b8;
  --white: #2d2d2d;
}

/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text-dark);
  background-color: var(--background-light);
  transition: var(--transition);
  padding-top: 76px;
}

/* Logo Styles */
.logo-navbar {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1); /* Makes logo white */
}


.logo-footer {
  height: 24px;
  width: auto;
  filter: brightness(0) invert(1); /* Makes logo white */
}

.logo-modal {
  height: 40px;
  width: auto;
  filter: brightness(0) invert(1); /* Makes logo white */
}

.logo-welcome {
  height: 80px;
  width: auto;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

.logo-offcanvas {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1); /* Makes logo white */
}

/* Status bar spacing for mobile devices */
@supports (padding: max(0px)) {
  body {
    padding-top: max(20px, env(safe-area-inset-top, 20px));
  }
}

/* Fallback for browsers that don't support env() */
@media (max-width: 768px) {
  body {
    padding-top: 20px;
  }
}

/* Safe area support for hero section */
@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    .hero-section {
      padding-top: calc(3rem + max(20px, env(safe-area-inset-top, 20px)));
    }
  }
  
  @media (max-width: 576px) {
    .hero-section {
      padding-top: calc(2rem + max(20px, env(safe-area-inset-top, 20px)));
    }
  }
  
  @media (max-width: 400px) {
    .hero-section {
      padding-top: calc(1.5rem + max(20px, env(safe-area-inset-top, 20px)));
    }
  }
}

/* Main dashboard status bar considerations */
@media (max-width: 768px) {
  main.container {
    padding-top: calc(3rem + 20px);
  }
}

@media (max-width: 576px) {
  main.container {
    padding-top: calc(2rem + 20px);
  }
}

@media (max-width: 400px) {
  main.container {
    padding-top: calc(1.5rem + 20px);
  }
}

/* Features section status bar considerations */
@media (max-width: 768px) {
  section#features {
    padding-top: calc(3rem + 20px);
  }
}

@media (max-width: 576px) {
  section#features {
    padding-top: calc(2rem + 20px);
  }
}

@media (max-width: 400px) {
  section#features {
    padding-top: calc(1.5rem + 20px);
  }
}

/* Custom Bootstrap Classes */
.bg-primary-custom {
  background-color: var(--primary-color) !important;
}

.bg-secondary-custom {
  background-color: var(--secondary-color) !important;
}

.bg-light-custom {
  background-color: var(--background-light) !important;
}

.text-primary-custom {
  color: var(--primary-color) !important;
}

.text-secondary-custom {
  color: var(--secondary-color) !important;
}

.btn-primary-custom {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--white);
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.btn-primary-custom:hover {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  transform: translateY(-2px);
}

.btn-outline-primary-custom {
  color: var(--primary-color);
  border-color: var(--primary-color);
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.btn-outline-primary-custom:hover {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.btn-outline-secondary-custom {
  color: var(--secondary-color);
  border-color: var(--secondary-color);
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.btn-outline-secondary-custom:hover {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  transform: translateY(-2px);
}

/* Sketch/Handmade Style Elements */
.sketch-card {
  border: 2px solid var(--text-dark);
  border-radius: var(--border-radius);
  background-color: var(--white);
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
}

.sketch-card::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, var(--accent-color), var(--light-accent));
  border-radius: var(--border-radius);
  z-index: -1;
  opacity: 0;
  transition: var(--transition);
}

.sketch-card:hover::before {
  opacity: 0.1;
}

.sketch-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.sketch-btn {
  border: 2px solid currentColor;
  border-radius: var(--border-radius);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.sketch-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: var(--transition);
}

.sketch-btn:hover::before {
  left: 100%;
}

.sketch-title {
  position: relative;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sketch-title::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 50px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-color), var(--light-accent));
  border-radius: 2px;
}

/* Navigation */
.navbar {
  backdrop-filter: blur(10px);
  background-color: rgba(5, 56, 107, 0.95) !important;
  box-shadow: var(--shadow);
}

/* Navbar status bar considerations */
.navbar.fixed-top {
  top: 0;
}

@supports (padding: max(0px)) {
  .navbar.fixed-top {
    top: max(0px, env(safe-area-inset-top, 0px));
  }
}

@media (max-width: 768px) {
  .navbar.fixed-top {
    top: 0;
  }
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
}

.nav-link {
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover {
  transform: translateY(-1px);
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, var(--background-light) 0%, rgba(92, 219, 149, 0.1) 100%);
  min-height: 70vh;
  display: flex;
  align-items: center;
  padding: 4rem 0;
}

.hero-content {
  max-width: 600px;
  margin: 0 auto;
}

.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}


/* Modal Improvements */
.modal-content {
  border: none;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.1);
  overflow: hidden; /* Prevent content overflow */
}

.modal-header {
  position: relative;
  overflow: hidden;
}

.modal-body {
  overflow-y: auto;
  max-height: 60vh; /* Prevent modal from becoming too tall */
}

.modal-footer {
  overflow: hidden;
}

/* Account for mobile ad banners */
.modal-dialog {
  margin-bottom: var(--ad-banner-height, 80px); /* Space for mobile ad banners */
}

@media (min-width: 768px) {
  .modal-dialog {
    margin-bottom: var(--ad-banner-height, 20px); /* Less space needed on desktop */
  }
}

/* Dynamic adjustment based on detected banner height */
body.has-ad-banner .modal-dialog {
  margin-bottom: var(--ad-banner-height, 100px);
}

body.has-ad-banner .offcanvas {
  bottom: var(--ad-banner-height, 100px) !important;
  max-height: calc(100vh - var(--ad-banner-height, 100px)) !important;
}

.modal-header {
  border-radius: 20px 20px 0 0;
  padding: 1.5rem;
}

.modal-footer {
  border-radius: 0 0 20px 20px;
  padding: 1.5rem;
}

/* Remove modal animations */
.modal.fade .modal-dialog {
  transition: none;
}

.modal.show .modal-dialog {
  transform: none;
}

.offcanvas-header {
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.offcanvas-body {
  padding: 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.offcanvas-content {
  overflow: hidden;
}

/* Welcome Modal Specific */
.welcome-icon {
  animation: float 3s ease-in-out infinite;
}

/* Text overflow prevention */
.modal-title,
.offcanvas-title {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.modal-header small,
.offcanvas-header small {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Form elements overflow prevention */
.form-label {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.alert {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Offcanvas Button Improvements */
.btn[onclick*="loadRoutineTemplate"] {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn[onclick*="loadRoutineTemplate"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn[onclick*="loadRoutineTemplate"]:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Loading state for template buttons */
.btn[onclick*="loadRoutineTemplate"].loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn[onclick*="loadRoutineTemplate"].loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  margin: auto;
  border: 2px solid transparent;
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Habit Cards */
.habit-card {
  transition: var(--transition);
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
}

.habit-card:hover {
  border-color: var(--accent-color);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.habit-card:hover::after {
  content: '💡 Clique para dicas';
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent-color);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 1;
  animation: fadeIn 0.3s ease;
}

.habit-card::after {
  content: '';
  opacity: 0;
  transition: var(--transition);
}

.habit-card.completed {
  background-color: rgba(92, 219, 149, 0.1);
  border-color: var(--accent-color);
}

.habit-card.completed::before {
  content: '✅';
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 1.2rem;
  z-index: 1;
  pointer-events: none;
}

.habit-icon {
  transition: var(--transition);
}

.habit-card:hover .habit-icon {
  transform: scale(1.1);
}

.habit-check {
  transform: scale(1.2);
  accent-color: var(--accent-color);
  pointer-events: auto !important;
  z-index: 10;
  position: relative;
}

/* Progress Elements */
.progress {
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.1);
}

.progress-bar {
  border-radius: 10px;
  transition: width 0.6s ease;
}

/* Modal Customizations */
.modal-content {
  border: none;
  border-radius: var(--border-radius);
}

.modal-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* Offcanvas Customizations */
.offcanvas {
  border: none;
  background-color: var(--white);
}

.offcanvas-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Form Elements */
.form-control, .form-select {
  border: 2px solid var(--text-muted);
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 0.2rem rgba(92, 219, 149, 0.25);
}

/* Accordion */
.accordion-item {
  border: 2px solid var(--text-muted);
  border-radius: var(--border-radius) !important;
  margin-bottom: 1rem;
}

.accordion-button {
  border-radius: var(--border-radius) !important;
  background-color: var(--white);
  color: var(--text-dark);
  font-weight: 600;
}

.accordion-button:not(.collapsed) {
  background-color: var(--accent-color);
  color: var(--white);
}

.accordion-button:focus {
  box-shadow: 0 0 0 0.2rem rgba(92, 219, 149, 0.25);
}

/* List Group */
.list-group-item {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background-color: var(--white);
  color: var(--text-dark);
  transition: var(--transition);
}

.list-group-item:hover {
  background-color: rgba(92, 219, 149, 0.05);
}

/* Notifications */
.notification {
  background-color: var(--white);
  border: 2px solid var(--accent-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification.success {
  border-color: var(--accent-color);
}

.notification.warning {
  border-color: #ffc107;
}

.notification.error {
  border-color: #dc3545;
}

.notification.info {
  border-color: #17a2b8;
}

/* Dark Mode Styles */
[data-theme="dark"] body {
  background-color: var(--background-light);
  color: var(--text-dark);
}

[data-theme="dark"] .sketch-card {
  background-color: var(--white);
  border-color: var(--text-muted);
  color: var(--text-dark);
}

[data-theme="dark"] .modal-content {
  background-color: var(--white);
  color: var(--text-dark);
}

[data-theme="dark"] .offcanvas {
  background-color: var(--white);
  color: var(--text-dark);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: var(--background-light);
  border-color: var(--text-muted);
  color: var(--text-dark);
}

[data-theme="dark"] .list-group-item {
  background-color: var(--white);
  border-color: var(--text-muted);
  color: var(--text-dark);
}

[data-theme="dark"] .accordion-button {
  background-color: var(--white);
  color: var(--text-dark);
}

/* Dark mode text legibility improvements */
[data-theme="dark"] .text-muted {
  color: #a0a0a0 !important;
}

[data-theme="dark"] .alert-info {
  background-color: #1e3a8a;
  border-color: #3b82f6;
  color: #dbeafe;
}

[data-theme="dark"] .alert-info .bi {
  color: #60a5fa;
}

[data-theme="dark"] .modal-footer.bg-light {
  background-color: #2d3748 !important;
  border-top-color: #4a5568;
}

[data-theme="dark"] .bg-light-custom {
  background-color: #2d3748 !important;
}

[data-theme="dark"] .card-text.text-muted {
  color: #9ca3af !important;
}

[data-theme="dark"] .small.text-muted {
  color: #9ca3af !important;
}

[data-theme="dark"] .lead.text-muted {
  color: #a0a0a0 !important;
}

[data-theme="dark"] .form-text {
  color: #9ca3af !important;
}

[data-theme="dark"] .list-group-item {
  color: var(--text-dark) !important;
}

[data-theme="dark"] .offcanvas-body .text-muted {
  color: #9ca3af !important;
}

[data-theme="dark"] .btn-outline-secondary {
  border-color: #6b7280;
  color: #d1d5db;
}

[data-theme="dark"] .btn-outline-secondary:hover {
  background-color: #6b7280;
  border-color: #6b7280;
  color: #ffffff;
}

/* Dark mode logo adjustments */
[data-theme="dark"] .logo-navbar,
[data-theme="dark"] .logo-footer {
  filter: brightness(0) invert(1); /* Keep logos white in dark mode */
}


/* Responsive Design */
@media (max-width: 768px) {
  .hero-section {
    text-align: center;
    padding: calc(3rem + 20px) 0 3rem 0;
    min-height: 60vh;
  }
  
  /* Daily Progress Card tablet improvements */
  .card-body .d-flex {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  
  .card-body .d-flex .d-flex {
    flex: 1 1 auto;
    min-width: 0;
  }
  
  .card-body .row {
    flex-direction: column;
  }
  
  .card-body .col-md-8,
  .card-body .col-md-4 {
    flex: 1 1 100%;
    max-width: 100%;
  }
  
  .card-body .col-md-4 {
    margin-top: 1rem;
  }
  
  .card-body .col-md-4 .btn {
    width: 100%;
  }
  
  .card-title {
    font-size: 1.1rem;
  }
  
  #progressText {
    font-size: 0.95rem;
  }
  
  .hero-content {
    max-width: 100%;
    padding: 0 1rem;
  }
  
  .display-3 {
    font-size: 2.5rem;
    line-height: 1.2;
    word-wrap: break-word;
  }
  
  .hero-buttons {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }
  
  .hero-buttons .btn {
    width: 100%;
    max-width: 280px;
  }
  
  .btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
  }
  
  .habit-card {
    margin-bottom: 1rem;
  }
  
  .modal-dialog {
    margin: 0.5rem;
  }
  
  .offcanvas {
    width: 90% !important;
  }
  
  
  .logo-navbar {
    height: 28px;
  }
}

@media (max-width: 576px) {
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .hero-section {
    padding: calc(2rem + 20px) 0 2rem 0;
    min-height: 50vh;
  }
  
  .hero-section .display-3 {
    font-size: 2rem;
    line-height: 1.2;
    word-wrap: break-word;
  }
  
  .hero-section .lead {
    font-size: 1rem;
    line-height: 1.4;
    word-wrap: break-word;
  }
  
  .hero-buttons .btn {
    max-width: 100%;
    padding: 0.75rem 1rem;
  }
  
  
  .logo-navbar {
    height: 24px;
  }
  
  /* Navbar mobile improvements */
  .navbar-brand {
    font-size: 1rem;
    max-width: calc(100% - 60px);
  }
  
  .navbar-brand img {
    flex-shrink: 0;
  }
  
  .navbar-brand span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .navbar-toggler {
    padding: 0.25rem 0.5rem;
    border: none;
    background: rgba(255,255,255,0.1);
    border-radius: 0.375rem;
  }
  
  .navbar-toggler:focus {
    box-shadow: none;
  }
  
  .navbar-nav .nav-link {
    padding: 0.75rem 1rem;
    text-align: center;
    border-radius: 0.375rem;
    margin: 0.25rem 0;
  }
  
  .navbar-nav .nav-link:hover {
    background: rgba(255,255,255,0.1);
  }
  
  .navbar-nav .btn {
    margin: 0.5rem auto;
    display: block;
    width: fit-content;
  }
  
  .logo-modal {
    height: 32px;
  }
  
  .logo-welcome {
    height: 60px;
  }
  
  .logo-offcanvas {
    height: 28px;
  }
  
  /* Modal responsiveness */
  .modal-dialog {
    margin: calc(0.5rem + 20px) 0.5rem var(--ad-banner-height, 100px) 0.5rem; /* Extra top margin for status bar */
    max-width: calc(100% - 1rem);
  }
  
  .modal-lg {
    max-width: calc(100% - 1rem);
  }
  
  .modal-xl {
    max-width: calc(100% - 1rem);
  }
  
  .modal-header {
    padding: 1rem;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .modal-header .d-flex {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .modal-header .d-flex > div {
    flex: 1 1 100%;
    min-width: 0;
  }
  
  .modal-header .btn-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
  }
  
  
  .modal-footer {
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .modal-footer .btn {
    width: 100%;
    margin: 0;
  }
  
  .card-body {
    padding: 1rem;
  }
  
  /* Habits grid mobile improvements */
  .habit-card {
    margin-bottom: 1rem;
    min-height: auto;
  }
  
  .habit-card .card-body {
    padding: 1rem 0.75rem;
  }
  
  .habit-icon .display-4 {
    font-size: 2rem;
  }
  
  .habit-card .card-title {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }
  
  .habit-card .card-text {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
  }
  
  .form-check {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .form-check-input {
    margin-top: 0;
    margin-right: 0.5rem;
  }
  
  .form-check-label {
    font-size: 0.9rem;
  }
  
  .btn {
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    min-height: 44px; /* Touch target minimum */
  }
  
  .btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
  }
  
  .btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* Extra small devices (phones in portrait, less than 400px) */
@media (max-width: 400px) {
  .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .hero-section {
    padding: calc(1.5rem + 20px) 0 1.5rem 0;
    min-height: 40vh;
  }
  
  .display-3 {
    font-size: 1.75rem;
    line-height: 1.2;
    word-wrap: break-word;
  }
  
  .lead {
    font-size: 1rem;
  }
  
  .hero-buttons {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .hero-buttons .btn {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    min-height: 48px;
  }
  
  .hero-buttons {
    gap: 1rem;
  }
  
  .navbar-brand {
    font-size: 0.9rem;
  }
  
  .logo-navbar {
    height: 20px;
  }
  
  .modal-dialog {
    margin: calc(0.25rem + 20px) 0.25rem var(--ad-banner-height, 120px) 0.25rem; /* Extra top margin for status bar */
    max-width: calc(100% - 0.5rem);
  }
  
  .modal-header {
    padding: 0.75rem;
    position: relative;
  }
  
  .modal-header .d-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .modal-header .d-flex > div {
    flex: none;
    width: 100%;
  }
  
  .modal-header .modal-title {
    font-size: 1rem;
    line-height: 1.2;
    word-wrap: break-word;
    white-space: normal;
  }
  
  .modal-header small {
    font-size: 0.75rem;
    line-height: 1.2;
    word-wrap: break-word;
    white-space: normal;
  }
  
  .modal-header .btn-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
  }
  
  .modal-body {
    padding: 0.75rem;
  }
  
  .modal-footer {
    padding: 0.75rem;
  }
  
  .card-body {
    padding: 0.75rem;
  }
  
  .habit-icon .display-4 {
    font-size: 1.5rem;
  }
  
  .offcanvas-header {
    padding: 0.75rem;
    position: relative;
  }
  
  .offcanvas-header .d-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .offcanvas-header .d-flex > div {
    flex: none;
    width: 100%;
  }
  
  .offcanvas-title {
    font-size: 1rem;
    line-height: 1.2;
    word-wrap: break-word;
    white-space: normal;
  }
  
  .offcanvas-header .btn-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
  }
  
  .offcanvas-body {
    padding: 0.75rem;
  }
  
  /* Daily Progress Card mobile improvements */
  .card-body {
    padding: 1rem 0.75rem;
  }
  
  .card-body .d-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .card-body .d-flex .d-flex {
    width: 100%;
    justify-content: space-between;
    align-items: center;
  }
  
  .card-title {
    font-size: 1rem;
    line-height: 1.3;
    word-wrap: break-word;
  }
  
  .card-body .row {
    margin: 0;
  }
  
  .card-body .col-md-8,
  .card-body .col-md-4 {
    flex: 1 1 100%;
    max-width: 100%;
    padding: 0;
  }
  
  .card-body .col-md-4 {
    margin-top: 1rem;
  }
  
  .card-body .col-md-4 .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Progress bar mobile improvements */
  .progress {
    height: 16px;
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
  }
  
  .progress-bar {
    font-size: 0.75rem;
    line-height: 16px;
  }
  
  #progressText {
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0;
  }
  
  /* Badge mobile improvements */
  .badge {
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
  }
  
  /* Alert mobile improvements */
  .alert {
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
  }
  
  .alert .bi {
    font-size: 1rem;
  }
  
  /* Daily Progress Card extra small screens */
  .card-body .d-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .card-body .d-flex .d-flex {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  
  .card-title {
    font-size: 0.9rem;
    text-align: center;
  }
  
  .card-body .col-md-4 {
    margin-top: 0.75rem;
  }
  
  #progressText {
    font-size: 0.85rem;
    text-align: center;
  }
  
  .progress {
    height: 14px;
    margin-bottom: 0.5rem;
  }
  
  .progress-bar {
    font-size: 0.7rem;
    line-height: 14px;
  }
  
  /* Back to Home button mobile improvements */
  #backToHomeBtn {
    width: 100%;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    padding: 0.5rem;
  }
  
  /* Badge mobile improvements */
  .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
  }
  
  /* Gap adjustments for mobile */
  .gap-2 {
    gap: 0.5rem !important;
  }
  
  /* List group mobile improvements */
  .list-group-item {
    padding: 0.75rem;
    font-size: 0.9rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
  }
  
  .list-group-item:last-child {
    margin-bottom: 0;
  }
  
  /* Card mobile improvements */
  .card {
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .card-title {
    font-size: 1.1rem;
    line-height: 1.3;
    margin-bottom: 0.75rem;
  }
  
  .card-text {
    font-size: 0.9rem;
    line-height: 1.4;
  }
}

/* Offcanvas mobile improvements */
@media (max-width: 768px) {
  .offcanvas {
    width: 100% !important;
    bottom: var(--ad-banner-height, 80px) !important; /* Space for mobile ad banners */
    top: 20px !important; /* Space for status bar */
    max-height: calc(100vh - var(--ad-banner-height, 80px) - 20px) !important;
  }
  
  .offcanvas-end {
    transform: translateX(100%);
  }
  
  .offcanvas-start {
    transform: translateX(-100%);
  }
  
  .offcanvas-header {
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }
  
  .offcanvas-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Ad banner considerations - different banner heights */
@media (max-width: 768px) {
  /* Standard mobile banner (320x50) */
  .modal-dialog {
    margin-bottom: 80px;
  }
  
  .offcanvas {
    bottom: 80px !important;
    max-height: calc(100vh - 80px) !important;
  }
  
  /* Large mobile banner (320x100) */
  &.large-banner .modal-dialog {
    margin-bottom: 120px;
  }
  
  &.large-banner .offcanvas {
    bottom: 120px !important;
    max-height: calc(100vh - 120px) !important;
  }
  
  /* Extra large banner (320x250) */
  &.extra-large-banner .modal-dialog {
    margin-bottom: 270px;
  }
  
  &.extra-large-banner .offcanvas {
    bottom: 270px !important;
    max-height: calc(100vh - 270px) !important;
  }
}

/* Automatic ad banner detection and adjustment */
body:has(.ad-banner) .modal-dialog {
  margin-bottom: 100px;
}

body:has(.ad-banner) .offcanvas {
  bottom: 100px !important;
  max-height: calc(100vh - 100px) !important;
}

/* Specific ad banner heights */
body:has(.ad-banner.large) .modal-dialog {
  margin-bottom: 120px;
}

body:has(.ad-banner.large) .offcanvas {
  bottom: 120px !important;
  max-height: calc(100vh - 120px) !important;
}

body:has(.ad-banner.extra-large) .modal-dialog {
  margin-bottom: 270px;
}

body:has(.ad-banner.extra-large) .offcanvas {
  bottom: 270px !important;
  max-height: calc(100vh - 270px) !important;
}

/* Safe area considerations for devices with notches */
@supports (padding: max(0px)) {
  .modal-dialog {
    margin-bottom: max(80px, env(safe-area-inset-bottom, 80px));
    margin-top: max(20px, env(safe-area-inset-top, 20px));
  }
  
  .offcanvas {
    bottom: max(80px, env(safe-area-inset-bottom, 80px)) !important;
    top: max(20px, env(safe-area-inset-top, 20px)) !important;
  }
  
  .navbar.fixed-top {
    top: max(0px, env(safe-area-inset-top, 0px));
  }
}

/* Form mobile improvements */
@media (max-width: 576px) {
  .form-control,
  .form-select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
    border-radius: 0.5rem;
  }
  
  .form-label {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
  }
  
  .form-text {
    font-size: 0.8rem;
    margin-top: 0.25rem;
  }
  
  .form-check-label {
    font-size: 0.9rem;
    line-height: 1.4;
  }
  
  .form-check-input {
    width: 1.1em;
    height: 1.1em;
    margin-top: 0.125rem;
  }
  
  .form-check {
    margin-bottom: 0.75rem;
  }
  
  .input-group {
    flex-wrap: wrap;
  }
  
  .input-group-text {
    font-size: 0.9rem;
    padding: 0.75rem;
  }
}

/* Routine cards mobile improvements */
@media (max-width: 576px) {
  .routine-template-card {
    margin-bottom: 1rem;
    min-height: auto;
  }
  
  .routine-template-card .card-body {
    padding: 1rem;
    text-align: center;
  }
  
  .routine-template-card .card-title {
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 0.75rem;
    word-wrap: break-word;
  }
  
  .routine-template-card .card-text {
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 1rem;
    word-wrap: break-word;
  }
  
  .routine-template-card .btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    width: 100%;
    margin-top: 0.5rem;
  }
  
  .list-unstyled {
    text-align: left;
    margin: 1rem 0;
  }
  
  .list-unstyled li {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    word-wrap: break-word;
  }
  
  .routine-icon {
    margin-bottom: 1rem;
  }
  
  .routine-icon .display-4 {
    font-size: 2.5rem;
  }
}

/* Footer mobile improvements */
@media (max-width: 768px) {
  .footer {
    padding: 2rem 0;
    text-align: center;
  }
  
  .footer .row {
    text-align: center;
  }
  
  .footer .col-md-6 {
    margin-bottom: 1.5rem;
  }
  
  .footer .col-md-6:last-child {
    margin-bottom: 0;
  }
  
  .footer .d-flex {
    justify-content: center;
  }
  
  .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
  }
  
  .footer-links a {
    margin: 0;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.3s ease;
  }
  
  .footer-links a:hover {
    background: rgba(255,255,255,0.1);
  }
}

@media (max-width: 576px) {
  .footer {
    padding: 1.5rem 0;
  }
  
  .footer .logo-footer {
    height: 20px;
  }
  
  .footer h6 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }
  
  .footer p {
    font-size: 0.9rem;
  }
  
  .footer .list-unstyled {
    margin-bottom: 1rem;
  }
  
  .footer .list-unstyled li {
    margin-bottom: 0.5rem;
  }
  
  .footer .list-unstyled a {
    font-size: 0.9rem;
  }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px; /* iOS touch target minimum */
    padding: 0.75rem 1rem;
  }
  
  .form-check-input {
    width: 1.25em;
    height: 1.25em;
  }
  
  .habit-card {
    cursor: pointer;
  }
  
  .habit-card:active {
    transform: scale(0.98);
  }
  
  .routine-template-card {
    cursor: pointer;
  }
  
  .routine-template-card:active {
    transform: scale(0.98);
  }
  
  .nav-link {
    padding: 1rem;
  }
  
  .btn-close {
    width: 2rem;
    height: 2rem;
  }
}

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

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

.slide-up {
  animation: slideUp 0.3s ease-out;
}

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

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(92, 219, 149, 0.3);
  border-left-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background-light);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Print Styles */
@media print {
  .navbar,
  .btn,
  .modal,
  .offcanvas,
  #notificationContainer {
    display: none !important;
  }
  
  .container {
    max-width: none !important;
  }
  
  .sketch-card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
  }
}

/* Accessibility Improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus Styles */
.btn:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000000;
    --secondary-color: #333333;
    --accent-color: #0066cc;
    --text-dark: #000000;
    --white: #ffffff;
  }
}

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

/* Custom Utilities */
.text-shadow {
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.box-shadow-lg {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

.border-sketch {
  border: 2px solid var(--text-dark) !important;
  border-radius: var(--border-radius) !important;
}

.bg-gradient-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
}

.bg-gradient-accent {
  background: linear-gradient(135deg, var(--accent-color), var(--light-accent)) !important;
}

/* Routine Template Cards */
.routine-template-card {
  transition: var(--transition);
  border: 2px solid transparent !important;
}

.routine-template-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
  border-color: var(--accent-color) !important;
}

.routine-template-card .routine-icon {
  transition: var(--transition);
}

.routine-template-card:hover .routine-icon {
  transform: scale(1.1);
}

/* Welcome Modal Enhancements */
.welcome-icon {
  animation: float 6s ease-in-out infinite;
}

/* Form Enhancements */
.form-select-lg, .form-control-lg {
  border: 2px solid var(--text-muted);
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.form-select-lg:focus, .form-control-lg:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 0.2rem rgba(92, 219, 149, 0.25);
}

/* Alert Enhancements */
.alert {
  border-radius: var(--border-radius);
  border: 2px solid transparent;
}

.alert-info {
  background-color: rgba(23, 162, 184, 0.1);
  border-color: rgba(23, 162, 184, 0.2);
  color: var(--text-dark);
}

.alert-success {
  background-color: rgba(40, 167, 69, 0.1);
  border-color: rgba(40, 167, 69, 0.2);
  color: var(--text-dark);
}

/* Chart Container */
.chart-container {
  position: relative;
  height: 300px;
  margin-bottom: 2rem;
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--accent-color);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}
