/* ================================================
   RESPONSIVE DESIGN FOR KRISHNA ENTERPRISES
   All Device Sizes: Mobile, Tablet, Desktop
   ================================================ */

/* ===== BASE & MOBILE FIRST (320px+) ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* Container responsive padding */
.container {
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  margin: 0 auto;
}

/* Images responsive */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== TYPOGRAPHY RESPONSIVE ===== */
h1 {
  font-size: 1.75rem; /* 28px */
  line-height: 1.2;
}

h2 {
  font-size: 1.5rem; /* 24px */
  line-height: 1.3;
}

h3 {
  font-size: 1.25rem; /* 20px */
  line-height: 1.4;
}

h4 {
  font-size: 1.125rem; /* 18px */
  line-height: 1.4;
}

p {
  font-size: 0.875rem; /* 14px */
  line-height: 1.6;
}

/* ===== NAVIGATION RESPONSIVE ===== */
#navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
}

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

.navbar-brand img,
.navbar-brand .icon-wrapper {
  width: 2rem;
  height: 2rem;
}

/* Mobile menu */
#mobile-menu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

#mobile-menu.active {
  max-height: 500px;
}

/* Desktop menu - hidden on mobile */
.desktop-menu {
  display: none;
}

/* ===== HERO SECTION RESPONSIVE ===== */
.hero-section,
#home {
  position: relative;
  min-height: 500px;
  padding: 3rem 1rem;
}

/* Hero background image container */
#home .absolute.inset-0 {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

#home .absolute.inset-0 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.hero-section h1,
#home h1 {
  font-size: 1.875rem; /* 30px */
  margin-bottom: 1rem;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-section p,
#home p {
  font-size: 1rem;
  margin-bottom: 1.5rem;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.hero-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.hero-buttons a,
.hero-buttons button {
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 0.875rem;
  text-align: center;
}

/* Hero image on mobile */
#home .relative img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  border-radius: 0.5rem;
}

/* Badges responsive */
#home .absolute.top-4,
#home .absolute.bottom-4 {
  z-index: 20;
}

#home .absolute.top-4 {
  top: 1rem;
  left: 1rem;
}

#home .absolute.bottom-4 {
  bottom: 1rem;
  right: 1rem;
}

/* ===== PRODUCT CARDS RESPONSIVE ===== */
.products-grid {
  display: grid;
  grid-template-columns: 1fr; /* Single column on mobile */
  gap: 1rem;
  padding: 1rem;
}

.product-card {
  width: 100%;
  padding: 1rem;
}

.product-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 0.5rem;
}

.product-card h3 {
  font-size: 1rem;
  margin-top: 0.75rem;
}

.product-card .price {
  font-size: 1.25rem;
  margin: 0.5rem 0;
}

.product-card button {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.875rem;
}

/* ===== CATEGORY CARDS RESPONSIVE ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
  gap: 0.75rem;
  padding: 1rem;
}

.category-card {
  aspect-ratio: 1;
  padding: 1rem;
}

.category-card i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.category-card h3 {
  font-size: 0.875rem;
}

/* ===== ADMIN PORTAL RESPONSIVE ===== */
.admin-sidebar {
  position: fixed;
  left: -100%;
  top: 0;
  height: 100vh;
  width: 250px;
  background: white;
  z-index: 999;
  transition: left 0.3s ease;
  overflow-y: auto;
}

.admin-sidebar.active {
  left: 0;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 998;
}

.sidebar-overlay.active {
  display: block;
}

.admin-content {
  margin-left: 0;
  padding: 1rem;
  width: 100%;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.admin-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  min-width: 600px;
  font-size: 0.875rem;
}

/* Mobile menu toggle button */
.sidebar-toggle {
  display: block;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1001;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #F59E0B;
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ===== FORMS RESPONSIVE ===== */
.form-group {
  margin-bottom: 1rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
}

.form-button {
  width: 100%;
  padding: 0.875rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
}

/* ===== MODALS RESPONSIVE ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 0.5rem;
  padding: 1.5rem;
}

/* ===== WHATSAPP BUTTON RESPONSIVE ===== */
.whatsapp-float {
  position: fixed;
  width: 50px;
  height: 50px;
  bottom: 20px;
  right: 20px;
  font-size: 1.5rem;
  z-index: 100;
}

/* ===== TABLES RESPONSIVE ===== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  font-size: 0.875rem;
}

thead {
  display: none; /* Hide headers on mobile, show as cards */
}

tbody tr {
  display: block;
  margin-bottom: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1rem;
}

tbody td {
  display: block;
  text-align: right;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
}

tbody td:last-child {
  border-bottom: none;
}

tbody td::before {
  content: attr(data-label);
  float: left;
  font-weight: 600;
  color: #374151;
}

/* ===== BUTTONS RESPONSIVE ===== */
.btn {
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-group .btn {
  width: 100%;
}

/* ===== CARDS RESPONSIVE ===== */
.card {
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* ===== FOOTER RESPONSIVE ===== */
footer {
  padding: 2rem 1rem;
  font-size: 0.875rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* ===== SMALL MOBILE (320px - 374px) ===== */
@media (max-width: 374px) {
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.25rem;
  }
  
  .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  
  .products-grid,
  .categories-grid {
    gap: 0.5rem;
    padding: 0.5rem;
  }
  
  .whatsapp-float {
    width: 45px;
    height: 45px;
    font-size: 1.25rem;
  }
}

/* ===== MOBILE LANDSCAPE & LARGE MOBILE (375px - 639px) ===== */
@media (min-width: 375px) {
  .container {
    max-width: 100%;
  }
  
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== TABLETS & SMALL SCREENS (640px - 767px) ===== */
@media (min-width: 640px) {
  .container {
    max-width: 640px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.75rem;
  }
  
  p {
    font-size: 1rem;
  }
  
  /* Hero section improvements */
  #home {
    min-height: 550px;
    padding: 4rem 1.5rem;
  }
  
  #home h1 {
    font-size: 2.5rem;
  }
  
  #home p {
    font-size: 1.125rem;
  }
  
  #home .relative img {
    height: 300px;
  }
  
  .hero-buttons {
    flex-direction: row;
  }
  
  .hero-buttons a,
  .hero-buttons button {
    width: auto;
    padding: 1rem 2rem;
  }
  
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
  
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .hero-buttons {
    flex-direction: row;
    width: auto;
  }
  
  .hero-buttons button {
    width: auto;
  }
  
  .admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== TABLETS & MEDIUM SCREENS (768px - 1023px) ===== */
@media (min-width: 768px) {
  .container {
    max-width: 768px;
  }
  
  .desktop-menu {
    display: flex;
  }
  
  #mobile-menu-btn {
    display: none;
  }
  
  #mobile-menu {
    display: none !important;
  }
  
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
  
  .categories-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .hero-section,
  #home {
    min-height: 600px;
    padding: 5rem 2rem;
  }
  
  .hero-section h1,
  #home h1 {
    font-size: 3rem;
  }
  
  .hero-section p,
  #home p {
    font-size: 1.25rem;
  }
  
  #home .relative img {
    height: 400px;
  }
  
  /* Admin sidebar visible */
  .admin-sidebar {
    position: relative;
    left: 0;
    width: 250px;
  }
  
  .admin-content {
    margin-left: 250px;
    padding: 2rem;
  }
  
  .sidebar-toggle {
    display: none;
  }
  
  .sidebar-overlay {
    display: none !important;
  }
  
  /* Tables normal display */
  thead {
    display: table-header-group;
  }
  
  tbody tr {
    display: table-row;
    border: none;
    padding: 0;
  }
  
  tbody td {
    display: table-cell;
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
  }
  
  tbody td::before {
    content: none;
  }
  
  .btn-group {
    flex-direction: row;
  }
  
  .btn-group .btn {
    width: auto;
  }
  
  .whatsapp-float {
    width: 60px;
    height: 60px;
    font-size: 1.75rem;
    bottom: 30px;
    right: 30px;
  }
}

/* ===== DESKTOP & LARGE SCREENS (1024px - 1279px) ===== */
@media (min-width: 1024px) {
  .container {
    max-width: 1024px;
    padding-left: 2rem;
    padding-right: 2rem;
  }
  
  h1 {
    font-size: 2.5rem;
  }
  
  h2 {
    font-size: 2rem;
  }
  
  .products-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .categories-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .hero-section,
  #home {
    min-height: 650px;
    padding: 6rem 2rem;
  }
  
  .hero-section h1,
  #home h1 {
    font-size: 3.5rem;
  }
  
  #home .relative img {
    height: 480px;
  }
  
  .product-card img {
    height: 250px;
  }
  
  .admin-sidebar {
    width: 280px;
  }
  
  .admin-content {
    margin-left: 280px;
  }
  
  .admin-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .footer-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== LARGE DESKTOP (1280px - 1535px) ===== */
@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }
  
  .hero-section h1,
  #home h1 {
    font-size: 4rem;
  }
  
  .hero-section p,
  #home p {
    font-size: 1.5rem;
  }
  
  #home {
    min-height: 700px;
  }
  
  #home .relative img {
    height: 550px;
  }
}

/* ===== EXTRA LARGE DESKTOP (1536px+) ===== */
@media (min-width: 1536px) {
  .container {
    max-width: 1536px;
  }
  
  .products-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  
  .categories-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* ===== LANDSCAPE MOBILE (max-height: 500px) ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-section {
    min-height: auto;
    padding: 2rem 1rem;
  }
  
  .hero-section h1 {
    font-size: 1.5rem;
  }
  
  .modal-content {
    max-height: 80vh;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .whatsapp-float,
  #mobile-menu-btn,
  .sidebar-toggle,
  nav button {
    display: none !important;
  }
  
  .admin-sidebar {
    display: none;
  }
  
  .admin-content {
    margin-left: 0;
  }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  button,
  a {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove hover effects on touch devices */
  .card-hover:hover {
    transform: none;
  }
  
  /* Better spacing for touch */
  .products-grid,
  .categories-grid {
    gap: 1.25rem;
  }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
  /* Optional: Add dark mode styles if needed */
}

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

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
  button {
    border: 2px solid currentColor;
  }
}

/* ===== UTILITY CLASSES ===== */
.hide-mobile {
  display: none;
}

.show-mobile {
  display: block;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block;
  }
  
  .show-mobile {
    display: none;
  }
  
  .hide-desktop {
    display: none;
  }
  
  .show-desktop {
    display: block;
  }
}

/* ===== SMOOTH SCROLLING ===== */
html {
  scroll-behavior: smooth;
}

/* ===== FOCUS VISIBLE (Accessibility) ===== */
:focus-visible {
  outline: 2px solid #F59E0B;
  outline-offset: 2px;
}

/* ===== LOADING STATES ===== */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
