/* Import component stylesheets */
@import "base.css";
@import "buttons.css";
@import "forms.css";
@import "layout.css";

/* Modern CSS with layers for better organization */
@layer base, components, utilities;

/* Base layer - reset and fundamental styles */
@layer base {
  /* Reset and normalize */
  *, *::before, *::after {
    box-sizing: border-box;
  }

  html {
    scroll-behavior: smooth;
  }

  /* Focus styles for accessibility */
  :focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
  }

  /* Selection styles */
  ::selection {
    background-color: rgba(74, 111, 165, 0.2);
  }
}

/* Components layer - reusable component styles */
@layer components {
  /* Recipe-specific styles */
  .recipe-content {
    line-height: 1.6;
    color: var(--gray-700);
  }

  .recipe-ingredients {
    background-color: var(--gray-50);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--gray-200);
  }

  .recipe-ingredients ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .recipe-ingredients li {
    padding-left: 0;
    position: relative;
  }

  .recipe-ingredients li::before {
    content: "•";
    color: var(--primary-color);
    font-weight: bold;
    margin-right: 0.5rem;
  }

  .recipe-instructions {
    counter-reset: step-counter;
    list-style: none;
    padding-left: 0;
  }

  .recipe-instructions li {
    counter-increment: step-counter;
    margin-bottom: 0.75rem;
    padding-left: 2rem;
    position: relative;
    line-height: 1.6;
  }

  .recipe-instructions li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    background-color: var(--primary-color);
    color: var(--white);
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
  }

  .recipe-metadata-number {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.5rem;
    line-height: 1.2;
  }

  /* Search form styles */

}

/* Utilities layer - utility classes that can override components */
@layer utilities {
  /* Spacing utilities */
  .m-0 { margin: 0; }
  .m-1 { margin: 0.25rem; }
  .m-2 { margin: 0.5rem; }
  .m-3 { margin: 1rem; }
  .m-4 { margin: 1.5rem; }
  .m-5 { margin: 3rem; }

  .mb-0 { margin-bottom: 0; }
  .mb-1 { margin-bottom: 0.25rem; }
  .mb-2 { margin-bottom: 0.5rem; }
  .mb-3 { margin-bottom: 0.75rem; }
  .mb-4 { margin-bottom: 1rem; }
  .mb-5 { margin-bottom: 1.25rem; }

  .p-0 { padding: 0; }
  .p-1 { padding: 0.25rem; }
  .p-2 { padding: 0.5rem; }
  .p-3 { padding: 1rem; }
  .p-4 { padding: 1.5rem; }
  .p-5 { padding: 3rem; }

  /* Color utilities */
  .text-primary { color: var(--primary-color); }
  .text-secondary { color: var(--gray-600); }
  .text-success { color: var(--success-color); }
  .text-danger { color: var(--danger-color); }
  .text-muted { color: var(--gray-600); }

  /* Typography utilities */
  .fw-bold { font-weight: 700; }
  .fs-5 { font-size: 1.25rem; }

  /* Flex utilities */
  .flex-wrap { flex-wrap: wrap; }

  .bg-primary { background-color: var(--primary-color); }
  .bg-secondary { background-color: var(--gray-200); }
  .bg-light { background-color: var(--gray-100); }

  /* Display utilities */
  .d-flex { display: flex; }
  .d-block { display: block; }
  .d-inline { display: inline; }
  .d-none { display: none; }

  /* Flex utilities */
  .justify-start { justify-content: flex-start; }
  .justify-center { justify-content: center; }
  .justify-end { justify-content: flex-end; }
  .justify-between { justify-content: space-between; }
  .justify-around { justify-content: space-around; }
  .justify-content-around { justify-content: space-around; }

  .align-start { align-items: flex-start; }
  .align-center { align-items: center; }
  .align-end { align-items: flex-end; }
  .align-items-start { align-items: flex-start; }

  /* Gap utilities */
  .gap-1 { gap: 0.25rem; }
  .gap-2 { gap: 0.5rem; }
  .gap-3 { gap: 0.75rem; }
  .gap-4 { gap: 1rem; }
  .gap-5 { gap: 1.25rem; }

  /* Position utilities */
  .position-relative { position: relative; }
  .position-absolute { position: absolute; }
  .position-fixed { position: fixed; }
  .position-sticky { position: sticky; }

  /* Border radius utilities */
  .rounded { border-radius: var(--border-radius); }
  .rounded-sm { border-radius: calc(var(--border-radius) / 2); }
  .rounded-lg { border-radius: calc(var(--border-radius) * 2); }
  .rounded-circle { border-radius: 50%; }

  /* Shadow utilities */
  .shadow { box-shadow: var(--box-shadow); }
  .shadow-lg { box-shadow: var(--box-shadow-hover); }
  .shadow-none { box-shadow: none; }

  /* Responsive utilities */
  @media (max-width: 768px) {
    .d-md-none { display: none; }
    .d-md-block { display: block; }
  }

  @media (max-width: 480px) {
    .d-sm-none { display: none; }
    .d-sm-block { display: block; }
  }
}

/* Print styles */
/* General mobile responsiveness */
* {
  box-sizing: border-box;
}

/* Prevent horizontal scrolling */
html, body {
  overflow-x: hidden;
  width: 100%;
}

/* Recipe header layout - responsive */
.recipe-header-layout {
  align-items: center;
}



.recipe-image-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.recipe-image {
  width: 250px;
  height: 200px;
  object-fit: cover;
}

.recipe-info-container {
  text-align: left;
}

.recipe-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.recipe-metadata > div {
  flex: 1;
  min-width: 100px;
  background-color: var(--gray-50);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  border: 1px solid var(--gray-200);
  transition: all 0.2s ease;
  text-align: center;
}

.recipe-metadata > div:hover {
  background-color: var(--gray-100);
  transform: translateY(-1px);
  box-shadow: var(--box-shadow);
}

/* Author info positioning */
.recipe-author-info {
  display: block;
  text-align: left;
  margin-top: 0.25rem;
}

/* Metadata layout */
.recipe-metadata {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Wake lock button styling */
#wake-lock-btn {
  font-size: 0.85rem;
  padding: 0.375rem 0.75rem;
  white-space: nowrap;
}

/* Recipe layout adjustments */
.recipe-ingredients {
  margin-bottom: 1.5rem;
}

.recipe-content {
  margin-bottom: 1.5rem;
}

/* Recipe actions - desktop natural spacing */
.recipe-actions {
  width: 100%;
}

/* Delete button positioning */
.delete-button-container {
  margin-top: 2rem;
  justify-content: flex-end;
}

@media (max-width: 768px) {
  .recipe-actions {
    flex-direction: row !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .recipe-actions .btn {
    flex: 0 0 auto;
    min-width: 140px;
  }

  /* Prevent horizontal scrolling on mobile */
  body {
    overflow-x: hidden;
  }

  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Ensure form elements don't cause horizontal scroll */
  .form-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .form-row .form-group {
    flex: 1;
  }


}

@media (max-width: 480px) {
  .recipe-actions .btn {
    min-width: 130px;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
  }

  /* Ensure navigation doesn't overflow */
  .navbar-nav {
    flex-wrap: wrap;
    justify-content: center;
  }

  .navbar-brand {
    font-size: 1.1rem;
  }

  /* Make sure headers don't cause overflow */
  h1 {
    font-size: 1.75rem;
    word-break: break-word;
  }

  /* Ensure cards don't overflow */
  .card {
    margin-left: 0;
    margin-right: 0;
  }

  /* Mobile recipe header layout */
  .recipe-header-layout {
    flex-direction: column !important;
    gap: 1rem !important;
    align-items: center !important;
  }

  .recipe-image-container {
    order: -1; /* Move image above title */
  }

  .recipe-image {
    width: 200px;
    height: 200px;
  }

  .recipe-info-container {
    text-align: center;
  }

  /* Mobile: make title section column layout */
  .recipe-info-container .d-flex {
    flex-direction: column !important;
    gap: 0.25rem !important;  /* Reduced gap between title and badge */
    margin-bottom: 0 !important;  /* Remove bottom margin */
  }

  .recipe-privacy-badge {
    margin-top: 0;
  }

  /* Mobile author info */
  .recipe-author-info {
    display: block;
    text-align: center;
    margin-top: 0;
  }

  /* Mobile metadata layout */
  .recipe-metadata {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
  }

  /* Mobile delete button - center on mobile */
  .delete-button-container {
    justify-content: center !important;
    margin-top: 3rem !important;
  }

  /* Mobile spacing between ingredients and instructions */
  .recipe-ingredients {
    margin-bottom: 2rem !important;
  }

  /* Mobile top buttons full width and equal spacing */
  .recipe-actions {
    justify-content: space-between !important;
    gap: 0.5rem !important;
  }

  .recipe-actions .btn {
    flex: 1;
    text-align: center;
    min-width: 0;
  }

  /* Mobile privacy badge below title */
  .recipe-privacy-badge {
    align-self: center !important;
    margin-top: 0.5rem;
  }
}

@media print {
  .btn, .navbar {
    display: none !important;
  }

  .recipe-content {
    font-size: 12pt;
    line-height: 1.4;
  }
}
