/* ============================================
   RESPONSIVE BASE STYLES
   ============================================ */

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
  scroll-behavior: smooth;
}

/* Mobile: phone screens */
@media (max-width: 575.98px) {
  html {
    font-size: 13px;
  }
  
  body {
    margin-bottom: 80px;
    padding-top: 70px;
  }
}

/* Tablet: 576px and up */
@media (min-width: 576px) and (max-width: 767.98px) {
  html {
    font-size: 14px;
  }
  
  body {
    margin-bottom: 70px;
    padding-top: 65px;
  }
}

/* Medium devices and up */
@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
  
  body {
    margin-bottom: 60px;
    padding-top: 60px;
  }
}

/* ============================================
   BUTTON & FORM FOCUS STATES
   ============================================ */

.btn:focus, 
.btn:active:focus, 
.btn-link.nav-link:focus, 
.form-control:focus, 
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
  outline: none;
}

/* ============================================
   BODY RESPONSIVE
   ============================================ */

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f8fafc;
  color: #2D3748;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-x: hidden;
}

/* ============================================
   CONTAINER RESPONSIVE PADDING
   ============================================ */

.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl,
.container-fluid {
  padding-right: 1rem;
  padding-left: 1rem;
}

@media (max-width: 575.98px) {
  .container,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl,
  .container-xxl,
  .container-fluid {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }
}

@media (min-width: 1200px) {
  .container,
  .container-sm,
  .container-md,
  .container-lg,
  .container-xl,
  .container-xxl {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
  }
}

/* ============================================
   IMAGES RESPONSIVE
   ============================================ */

img {
  max-width: 100%;
  height: auto;
  display: block;
}

img.img-fluid {
  max-width: 100%;
  height: auto;
}

img.img-thumbnail {
  max-width: 100%;
  height: auto;
}

/* Product images */
.product-image,
.item-image {
  max-width: 100%;
  height: auto;
  object-fit: cover;
  aspect-ratio: 1 / 1;
}

@media (max-width: 767.98px) {
  .product-image,
  .item-image {
    aspect-ratio: auto;
  }
}

/* ============================================
   TYPOGRAPHY RESPONSIVE
   ============================================ */

h1, .h1 {
  font-size: clamp(1.5rem, 5vw, 3rem);
  margin-bottom: 1rem;
  line-height: 1.2;
}

h2, .h2 {
  font-size: clamp(1.25rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
  line-height: 1.3;
}

h3, .h3 {
  font-size: clamp(1rem, 3vw, 2rem);
  margin-bottom: 1rem;
}

h4, .h4 {
  font-size: clamp(0.95rem, 2.5vw, 1.75rem);
  margin-bottom: 0.75rem;
}

h5, .h5 {
  font-size: clamp(0.9rem, 2vw, 1.5rem);
  margin-bottom: 0.75rem;
}

h6, .h6 {
  font-size: clamp(0.85rem, 1.5vw, 1.25rem);
  margin-bottom: 0.75rem;
}

p {
  margin-bottom: 1rem;
  word-break: break-word;
}

/* ============================================
   TABLES RESPONSIVE
   ============================================ */

.table-container,
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  -ms-overflow-style: -ms-autohiding-scrollbar;
}

.table {
  margin-bottom: 0;
  font-size: clamp(0.75rem, 1vw, 0.95rem);
}

.table thead th {
  border-bottom: 2px solid #dee2e6;
  padding: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.75rem;
  white-space: nowrap;
}

/* Stacked table on mobile */
@media (max-width: 767.98px) {
  .table.table-stacked thead {
    display: none;
  }

  .table.table-stacked,
  .table.table-stacked tbody,
  .table.table-stacked tr,
  .table.table-stacked td {
    display: block;
    width: 100%;
  }

  .table.table-stacked tr {
    margin-bottom: 1.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
  }

  .table.table-stacked td {
    text-align: right;
    padding-left: 50%;
    position: relative;
    border: none;
    padding: 0.75rem;
    border-bottom: 1px solid #f5f5f5;
  }

  .table.table-stacked td:last-child {
    border-bottom: none;
  }

  .table.table-stacked td::before {
    content: attr(data-label);
    position: absolute;
    left: 0.75rem;
    font-weight: 700;
    text-align: left;
  }
}

/* ============================================
   FORM RESPONSIVE
   ============================================ */

.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  margin-bottom: 0.5rem;
  font-weight: 500;
  display: block;
}

.form-control,
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: clamp(0.875rem, 1vw, 1rem);
  border: 2px solid #E2E8F0;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: #0F4C97;
  box-shadow: 0 0 0 3px rgba(15, 76, 151, 0.1);
  outline: none;
}

.input-group {
  display: flex;
  width: 100%;
}

.input-group > .form-control {
  flex: 1;
}

.input-group-text {
  padding: 0.5rem 0.75rem;
}

/* ============================================
   CARD RESPONSIVE
   ============================================ */

.card {
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  margin-bottom: 1rem;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.card-body {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.card-title {
  font-size: clamp(1rem, 2vw, 1.25rem);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.card-text {
  font-size: clamp(0.875rem, 1.5vw, 1rem);
  margin-bottom: 0.5rem;
}

/* ============================================
   BUTTON RESPONSIVE
   ============================================ */

.btn {
  padding: 0.5rem 1rem;
  font-size: clamp(0.875rem, 1vw, 1rem);
  border-radius: 0.375rem;
  transition: all 0.3s ease;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 500;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
  min-height: 44px;
}

/* Touch targets */
@media (hover: none) and (pointer: coarse) {
  .btn,
  a,
  button,
  .nav-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ============================================
   NAVBAR RESPONSIVE
   ============================================ */

.navbar {
  padding: 0.5rem 0;
  box-shadow: 0 2px 10px rgba(15, 76, 151, 0.15);
  min-height: 60px;
}

.navbar-brand {
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 700;
  padding: 0.5rem 0;
  white-space: nowrap;
}

.navbar-brand i {
  margin-right: 0.5rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem;
  border-radius: 0.5rem;
}

.nav-link {
  padding: 0.5rem 1rem !important;
  font-size: clamp(0.875rem, 1.5vw, 1rem);
  margin: 0 2px;
  border-radius: 0.375rem;
  transition: all 0.3s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile menu */
@media (max-width: 991.98px) {
  .navbar-collapse {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .navbar-nav {
    text-align: center;
  }

  .nav-link {
    padding: 0.75rem 0 !important;
    margin: 0.25rem 0;
  }

  .dropdown-menu {
    text-align: center;
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
  }

  .dropdown-item {
    padding: 0.5rem 1rem;
  }
}

/* ============================================
   MODAL RESPONSIVE
   ============================================ */

.modal-dialog {
  max-width: clamp(280px, 95vw, 500px);
  margin: auto;
}

.modal-content {
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal-body {
  padding: clamp(1rem, 3vw, 2rem);
}

.modal-header,
.modal-footer {
  padding: clamp(1rem, 2vw, 1.5rem);
}

/* ============================================
   GRID RESPONSIVE
   ============================================ */

.grid-responsive {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 576px) {
  .grid-responsive {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

@media (min-width: 768px) {
  .grid-responsive {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1200px) {
  .grid-responsive {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Hide/Show responsive */
.hide-mobile {
  display: none !important;
}

@media (min-width: 768px) {
  .hide-mobile {
    display: block !important;
  }

  .hide-desktop {
    display: none !important;
  }
}

/* Text utilities */
.text-clamp-1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   FOOTER RESPONSIVE
   ============================================ */

.footer {
  padding: clamp(1.5rem, 3vw, 2.5rem) 0;
  margin-top: 3rem;
}

@media (max-width: 575.98px) {
  .footer {
    padding: 1.5rem 0;
    text-align: center;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  body {
    background: white;
    padding: 0;
    margin: 0;
  }

  .navbar,
  .footer,
  .no-print {
    display: none !important;
  }

  a {
    text-decoration: underline;
  }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

@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: more) {
  .btn,
  .form-control,
  .card {
    border-width: 2px;
  }
}