/* ============================================================
   RESPONSIVE DESIGN UTILITIES & MOBILE-FIRST STYLES
   Untuk semua halaman Go Honey
   ============================================================ */

:root {
  --honey-dark: #1a1006;
  --honey-amber: #c8761a;
  --honey-gold: #e8a020;
  --honey-cream: #fdf7ee;
  --honey-warm: #f9f0dc;
  --honey-light: #f5e6c8;
  --text-primary: #1a1006;
  --text-secondary: #5c4a28;
  --text-muted: #9a7f58;
  --border: rgba(200, 118, 26, 0.15);
  --shadow-soft: 0 2px 24px rgba(26, 16, 6, 0.07);
  --shadow-card: 0 8px 40px rgba(26, 16, 6, 0.12);
  --radius-lg: 16px;
  --radius-md: 10px;
  --transition-speed: 0.3s;
}

/* ============ GLOBAL RESPONSIVE SETTINGS ============ */

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ============ RESPONSIVE CONTAINER ============ */

.container-fluid,
.container {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

/* ============ RESPONSIVE TYPOGRAPHY ============ */

h1,
h2,
h3,
h4,
h5,
h6 {
  word-break: break-word;
  hyphens: auto;
}

/* Font scaling */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  body {
    font-size: 0.9rem;
  }

  h1 {
    font-size: 1.75rem !important;
  }

  h2 {
    font-size: 1.5rem !important;
  }

  h3 {
    font-size: 1.25rem !important;
  }

  h4 {
    font-size: 1.1rem !important;
  }

  h5 {
    font-size: 1rem !important;
  }

  h6 {
    font-size: 0.9rem !important;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  html {
    font-size: 15px;
  }

  h1 {
    font-size: 2.2rem !important;
  }

  h2 {
    font-size: 1.8rem !important;
  }

  h3 {
    font-size: 1.5rem !important;
  }
}

/* ============ RESPONSIVE SPACING ============ */

/* Margin helpers */
@media (max-width: 576px) {
  .m-lg {
    margin: 0.5rem !important;
  }

  .p-lg {
    padding: 0.5rem !important;
  }

  .mx-lg {
    margin-left: 0.5rem !important;
    margin-right: 0.5rem !important;
  }

  .px-lg {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  .my-lg {
    margin-top: 0.5rem !important;
    margin-bottom: 0.5rem !important;
  }

  .py-lg {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }
}

/* ============ RESPONSIVE FLEX & GRID ============ */

.d-flex,
.d-grid {
  gap: clamp(0.5rem, 2vw, 2rem);
}

@media (max-width: 576px) {
  .flex-column-mobile {
    flex-direction: column !important;
  }

  .grid-1-mobile {
    grid-template-columns: 1fr !important;
  }

  .gap-mobile-0 {
    gap: 0 !important;
  }

  .gap-mobile-1 {
    gap: 0.5rem !important;
  }

  .gap-mobile-2 {
    gap: 1rem !important;
  }
}

/* ============ RESPONSIVE NAVBAR ============ */

.navbar {
  padding: 0.75rem 1rem !important;
}

@media (max-width: 576px) {
  .navbar {
    padding: 0.5rem 0.75rem !important;
  }

  .navbar-brand {
    font-size: 1.2rem !important;
  }

  .navbar-nav {
    gap: 0.25rem;
  }

  .navbar-nav .nav-link {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.9rem;
  }

  .navbar-toggler {
    padding: 0.25rem 0.5rem;
    font-size: 1.1rem;
  }

  .navbar-collapse {
    padding: 1rem 0;
  }
}

@media (max-width: 992px) {
  .navbar-nav {
    padding: 0.5rem 0;
  }
}

/* ============ RESPONSIVE SIDEBAR ============ */

.sidebar {
  width: 100%;
  height: auto;
  position: relative;
  max-width: 100%;
}

@media (min-width: 769px) {
  .sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
  }

  .admin-content,
  .sidebar-content {
    margin-left: 260px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    transition: left 0.3s;
    z-index: 999;
    height: 100vh;
    width: 75vw;
    max-width: 260px;
    background: var(--honey-dark);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-toggle {
    display: block;
  }

  .admin-content,
  .sidebar-content {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 85vw;
  }
}

/* ============ RESPONSIVE FORMS ============ */

.form-control,
.form-select,
textarea {
  min-height: 44px;
  font-size: 16px !important;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

@media (max-width: 576px) {
  .form-control,
  .form-select,
  textarea {
    font-size: 16px !important;
    padding: 0.7rem 0.9rem;
  }

  .form-label {
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row .col {
    width: 100%;
    margin-bottom: 1rem;
  }
}

/* ============ RESPONSIVE BUTTONS ============ */

.btn {
  min-height: 44px;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition-speed) ease;
  white-space: nowrap;
}

@media (max-width: 576px) {
  .btn {
    min-height: 42px;
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    width: 100%;
  }

  .btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn-group-mobile .btn {
    width: 100%;
  }

  .btn-icon {
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ============ RESPONSIVE CARDS ============ */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: all var(--transition-speed) ease;
}

@media (max-width: 576px) {
  .card {
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
  }

  .card-body {
    padding: 1rem;
  }

  .card-header {
    padding: 0.75rem 1rem;
  }
}

/* ============ RESPONSIVE TABLES ============ */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .table {
    font-size: 0.85rem;
  }

  .table thead {
    font-size: 0.8rem;
  }

  .table td,
  .table th {
    padding: 0.5rem;
  }

  /* Stacked table on mobile */
  .table-stack {
    display: block;
    width: 100%;
  }

  .table-stack thead,
  .table-stack tbody,
  .table-stack th,
  .table-stack td,
  .table-stack tr {
    display: block;
    width: 100%;
  }

  .table-stack tbody tr {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
  }

  .table-stack td {
    position: relative;
    padding-left: 50%;
  }

  .table-stack td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 45%;
    padding-right: 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
  }
}

/* ============ RESPONSIVE MODALS ============ */

@media (max-width: 576px) {
  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-content {
    border-radius: var(--radius-md);
  }

  .modal-body {
    padding: 1rem;
  }

  .modal-header {
    padding: 1rem;
  }
}

/* ============ RESPONSIVE ALERTS ============ */

.alert {
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 576px) {
  .alert {
    padding: 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
  }

  .alert .btn-close {
    padding: 0.25rem;
  }
}

/* ============ RESPONSIVE PAGINATION ============ */

@media (max-width: 576px) {
  .pagination {
    gap: 0.25rem;
  }

  .page-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }

  .page-item:not(:last-child) .page-link {
    margin-right: 0;
  }
}

/* ============ RESPONSIVE IMAGES ============ */

.img-fluid,
.img-responsive {
  max-width: 100%;
  height: auto;
}

.img-thumbnail {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* Responsive image containers */
.img-container {
  position: relative;
  width: 100%;
  padding-bottom: 75%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.img-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============ RESPONSIVE HERO SECTION ============ */

.hero,
.hero-section {
  padding: 2rem 1rem !important;
  min-height: auto;
}

@media (min-width: 768px) {
  .hero,
  .hero-section {
    padding: 4rem 2rem !important;
    min-height: 60vh;
  }
}

@media (min-width: 1200px) {
  .hero,
  .hero-section {
    padding: 5rem 2rem !important;
    min-height: 88vh;
  }
}

/* ============ RESPONSIVE GRID LAYOUTS ============ */

/* Auto-responsive grid */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

@media (max-width: 576px) {
  .grid-auto {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .product-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* ============ RESPONSIVE VISIBILITY ============ */

.hide-mobile {
  display: none;
}

@media (min-width: 769px) {
  .hide-mobile {
    display: block;
  }

  .hide-desktop {
    display: none;
  }
}

/* ============ RESPONSIVE DRAWER/OFFCANVAS ============ */

.drawer {
  position: fixed;
  top: 0;
  left: -100%;
  width: 75vw;
  max-width: 300px;
  height: 100vh;
  background: white;
  transition: left 0.3s ease;
  z-index: 999;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer.open {
  left: 0;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 998;
}

.drawer.open + .drawer-overlay,
.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ============ RESPONSIVE FOOTER ============ */

footer {
  padding: 2rem 1rem;
}

@media (max-width: 768px) {
  footer {
    padding: 1.5rem 1rem;
  }

  footer .row {
    flex-direction: column;
  }

  footer .col {
    margin-bottom: 1.5rem;
  }

  footer .col:last-child {
    margin-bottom: 0;
  }
}

/* ============ TOUCH DEVICE OPTIMIZATION ============ */

@media (hover: none) and (pointer: coarse) {
  /* Increase touch targets */
  a,
  button,
  .btn,
  input[type="checkbox"],
  input[type="radio"],
  .nav-link {
    min-height: 44px;
    min-width: 44px;
  }

  /* Better spacing for touch */
  .list-group-item {
    padding: 1rem 0.75rem;
  }

  /* Active states for touch */
  .btn:active,
  .nav-link:active,
  a:active {
    opacity: 0.8;
    transform: scale(0.98);
  }

  /* Remove hover effects that don't work on touch */
  .btn:hover {
    transform: none;
  }

  /* Better focus states */
  input:focus,
  textarea:focus,
  select:focus {
    outline: 2px solid var(--honey-gold);
    outline-offset: 2px;
  }
}

/* ============ LANDSCAPE MODE OPTIMIZATION ============ */

@media (orientation: landscape) and (max-height: 600px) {
  .navbar {
    padding: 0.35rem 1rem;
  }

  .navbar-brand {
    font-size: 1rem;
  }

  .hero,
  .hero-section {
    min-height: auto;
    padding: 1.5rem 1rem;
  }

  h1 {
    font-size: 1.5rem !important;
  }

  .container-fluid {
    padding: 1rem;
  }
}

/* ============ DARK MODE SUPPORT ============ */

@media (prefers-color-scheme: dark) {
  :root {
    --honey-cream: #2a1f15;
    --text-primary: #f5e6c8;
    --text-secondary: #c9a876;
    --border: rgba(200, 118, 26, 0.25);
  }

  body {
    background: #1a1006;
    color: var(--text-primary);
  }

  .card {
    background: #2a1f15;
    color: var(--text-primary);
  }

  .form-control,
  .form-select {
    background: #1a1006;
    color: var(--text-primary);
    border-color: var(--border);
  }
}

/* ============ REDUCED MOTION ============ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ HIGH CONTRAST MODE ============ */

@media (prefers-contrast: more) {
  .card,
  .btn {
    border-width: 2px;
  }

  .form-control {
    border-width: 2px;
  }

  a {
    text-decoration: underline;
  }
}

/* ============ UTILITY CLASSES ============ */

/* Responsive text alignment */
@media (max-width: 576px) {
  .text-center-mobile {
    text-align: center;
  }

  .text-start-mobile {
    text-align: left;
  }

  .text-end-mobile {
    text-align: right;
  }
}

/* Responsive display */
.d-none-mobile {
  display: none;
}

@media (min-width: 769px) {
  .d-none-desktop {
    display: none;
  }

  .d-block-desktop {
    display: block;
  }

  .d-none-mobile {
    display: block;
  }
}

/* Responsive width */
.w-mobile-100 {
  width: 100%;
}

@media (min-width: 769px) {
  .w-mobile-100 {
    width: auto;
  }
}

/* ============ SCROLLBAR STYLING ============ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--honey-cream);
}

::-webkit-scrollbar-thumb {
  background: var(--honey-amber);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--honey-gold);
}

/* ============ SAFE AREA PADDING ============ */

@supports (padding: max(0px)) {
  body {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .navbar {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
}
