/* ============================================================
   Sistema Lanchonete — Global Styles
   Complementary to Tailwind CSS
   ============================================================ */

/* ------------------------------------------------------------
   Scrollbar thin for sidebar
   ------------------------------------------------------------ */
.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* ------------------------------------------------------------
   CSS Custom Properties
   ------------------------------------------------------------ */
:root {
  --primary:        #E63946;
  --primary-dark:   #c62a36;
  --primary-light:  #f9d2d5;
  --dark:           #1A1A2E;
  --dark-2:         #16213E;
  --dark-3:         #0F3460;
  --light:          #F4F4F8;
  --light-2:        #E8E8EF;
  --text-main:      #1f2937;
  --text-muted:     #6b7280;
  --border:         #e5e7eb;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #3b82f6;
  --radius:         0.5rem;
  --radius-lg:      0.75rem;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:         0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --transition:     150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ------------------------------------------------------------
   Base - Responsivo
   ------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--light);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ------------------------------------------------------------
   Touch-friendly interactive elements
   ------------------------------------------------------------ */
@media (max-width: 1023px) {
  /* Touch-friendly: apenas botoes e inputs primarios, nao spans/svgs dentro deles */
  button:not(.btn-icon-sm),
  [role="button"],
  .btn {
    min-height: 44px;
  }

  /* Prevenir zoom no iOS ao focar inputs */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .produto-card {
    min-height: 120px;
  }

  .table-base th,
  .table-base td {
    padding: 0.75rem 0.5rem;
  }
}

/* ------------------------------------------------------------
   Tipografia Responsiva (somente headings sem classe Tailwind)
   ------------------------------------------------------------ */
.heading-responsive-1 { font-size: clamp(1.5rem, 4vw, 2.25rem); font-weight: 700; }
.heading-responsive-2 { font-size: clamp(1.25rem, 3vw, 1.875rem); font-weight: 600; }
.heading-responsive-3 { font-size: clamp(1.125rem, 2.5vw, 1.5rem); font-weight: 600; }

/* Touch-friendly spacing on mobile */
@media (max-width: 640px) {
  body {
    padding-bottom: env(safe-area-inset-bottom, 1rem);
  }
  
  .p-4 { padding: 1rem; }
  .p-6 { padding: 1.25rem; }
  
  .gap-2 { gap: 0.5rem; }
  .gap-4 { gap: 1rem; }
}

/* ------------------------------------------------------------
   Scrollbar
   ------------------------------------------------------------ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
aside ::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
}
aside ::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.3);
}

/* ------------------------------------------------------------
   TOAST NOTIFICATIONS
   ------------------------------------------------------------ */
#toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom, 1rem);
  padding-right: env(safe-area-inset-right, 1rem);
}

@media (max-width: 1023px) {
  #toast-container {
    bottom: 5.5rem; /* acima do bottom nav (~80px) */
    left: 0.75rem;
    right: 0.75rem;
  }

  #toast-container .toast {
    min-width: 100%;
    max-width: 100%;
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  min-width: 220px;
  max-width: 360px;
  opacity: 0;
  transform: translateX(120%);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast.toast-hide {
  opacity: 0;
  transform: translateX(120%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-success {
  background-color: var(--success);
}
.toast-error {
  background-color: var(--danger);
}
.toast-warning {
  background-color: var(--warning);
  color: #1f2937;
}
.toast-info {
  background-color: var(--info);
}

.toast-icon {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 1rem;
}

/* ------------------------------------------------------------
   MODAL
   ------------------------------------------------------------ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background-color: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Mobile modal - slide from bottom */
@media (max-width: 575px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  
  .modal-box {
    max-width: 100%;
    width: 100%;
    max-height: 85vh;
    border-radius: 1rem 1rem 0 0;
    margin: 0;
  }
  
  .modal-body {
    padding: 1rem;
  }
  
  .modal-footer {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }
  
  .modal-footer .btn {
    flex: 1;
    min-height: 44px;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

/* ------------------------------------------------------------
   LOADING SPINNER
   ------------------------------------------------------------ */
.spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

.spinner-lg {
  width: 3rem;
  height: 3rem;
  border-width: 4px;
}

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

/* ------------------------------------------------------------
   SIDEBAR
   ------------------------------------------------------------ */
.sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* Active nav link */
.nav-ativo,
.nav-link.nav-ativo {
  background-color: rgba(230, 57, 70, 0.25) !important;
  color: #fff !important;
  border-left: 3px solid var(--primary);
}

.bottom-nav-link.nav-ativo {
  color: var(--primary) !important;
}

.nav-link {
  border-left: 3px solid transparent;
  transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

/* ------------------------------------------------------------
   CARD
   ------------------------------------------------------------ */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ------------------------------------------------------------
   BADGES
   ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.025em;
}

.badge-success {
  background-color: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.badge-info {
  background-color: #dbeafe;
  color: #1e40af;
}

.badge-gray {
  background-color: #f3f4f6;
  color: #374151;
}

.badge-primary {
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

/* ------------------------------------------------------------
   TABLES
   ------------------------------------------------------------ */
.table-base {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-base th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background-color: var(--light);
  border-bottom: 1px solid var(--border);
}

.table-base td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.table-base tbody tr {
  transition: background-color var(--transition);
}

.table-base tbody tr:hover {
  background-color: #fafafa;
}

.table-base tbody tr:last-child td {
  border-bottom: none;
}

/* ------------------------------------------------------------
   FORM ELEMENTS
   ------------------------------------------------------------ */
.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-main);
  background-color: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.375rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 0.25rem;
}

/* ------------------------------------------------------------
   BUTTONS
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  outline: none;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(230,57,70,0.3);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
  box-shadow: 0 4px 8px rgba(230,57,70,0.35);
}

.btn-secondary {
  background-color: var(--light);
  color: var(--text-main);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--light-2);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
}

.btn-success {
  background-color: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  background-color: #059669;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
}

/* ------------------------------------------------------------
   PAGE TRANSITIONS
   ------------------------------------------------------------ */
.page-enter {
  animation: pageEnter 0.25s ease forwards;
}

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

/* ------------------------------------------------------------
   STAT CARDS (Dashboard)
   ------------------------------------------------------------ */
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ------------------------------------------------------------
   PDV
   ------------------------------------------------------------ */
.produto-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.produto-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.produto-card:active {
  transform: scale(0.97);
}

.produto-card.sem-estoque {
  opacity: 0.45;
  cursor: not-allowed;
}

.carrinho-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
}

.carrinho-item:last-child {
  border-bottom: none;
}

/* ------------------------------------------------------------
   CUPOM / RECEIPT
   ------------------------------------------------------------ */
.cupom-preview {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8125rem;
  background: #fff;
  border: 1px dashed #ccc;
  border-radius: var(--radius);
  padding: 1rem;
  max-width: 300px;
  margin: 0 auto;
}

/* ------------------------------------------------------------
   RESPONSIVE HELPERS - Media Queries
   ------------------------------------------------------------ */

/* Mobile First: Base styles + Desktop overrides */

/* Small devices (phones, 576px and up) */
@media (min-width: 576px) {
  .sm\:hidden { display: none; }
  .sm\:flex { display: flex; }
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
  .md\:hidden { display: none; }
  .md\:flex { display: flex; }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Large devices (desktops, 1024px and up) */
@media (min-width: 1024px) {
  .lg\:hidden { display: none; }
  .lg\:flex { display: flex; }
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Extra large devices (large desktops, 1280px and up) */
@media (min-width: 1280px) {
  .xl\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .xl\:grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Max-width breakpoints for specific overrides */
@media (max-width: 575px) {
  .hide-on-mobile { display: none !important; }
  .padding-mobile { padding: 0.75rem; }
  .text-mobile-sm { font-size: 0.75rem; }
  
  .produto-card {
    padding: 0.5rem;
  }
  
  .modal-box {
    max-width: 100%;
    margin: 0;
    border-radius: 1rem 1rem 0 0;
    max-height: 85vh;
  }
}

@media (max-width: 767px) {
  .hide-on-tablet { display: none !important; }
  .padding-tablet { padding: 1rem; }
  
  .table-base {
    display: block;
  }
  
  .table-base thead {
    display: none;
  }
  
  .table-base tbody,
  .table-base tr,
  .table-base td {
    display: block;
    width: 100%;
  }
  
  .table-base tr {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
  }
  
  .table-base td {
    padding: 0.25rem 0.75rem;
    border: none;
    text-align: left;
  }
  
  .table-base td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
  }
}

@media (max-width: 1023px) {
  #app-body {
    flex-direction: column;
  }
  .sidebar-desktop {
    display: none !important;
  }
}

/* Prevent sidebar from being shown at mobile via Tailwind hidden class */
@media (max-width: 1023px) {
  .sidebar-desktop {
    display: none !important;
  }
}

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

/* Truncate text */
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------------------------------------
   Imagens Responsivas
   ------------------------------------------------------------ */
img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

.img-cover {
  object-fit: cover;
  width: 100%;
  height: 100%;
}

.img-contain {
  object-fit: contain;
  width: 100%;
  height: 100%;
}

/* ------------------------------------------------------------
   ANIMATIONS
   ------------------------------------------------------------ */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

.animate-pulse-soft {
  animation: pulse-soft 2s ease infinite;
}

@keyframes bounce-in {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.animate-bounce-in {
  animation: bounce-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Reduced motion support */
@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;
  }
}

/* ------------------------------------------------------------
   ACCESSIBILITY - Focus states
   ------------------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white: normal;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: white;
  padding: 8px 16px;
  z-index: 1000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* ------------------------------------------------------------
   RESPONSIVE CONTAINERS
   ------------------------------------------------------------ */
.container-responsive {
  width: 100%;
  max-width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 576px) {
  .container-responsive {
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 768px) {
  .container-responsive {
    max-width: 720px;
  }
}

@media (min-width: 1024px) {
  .container-responsive {
    max-width: 960px;
  }
}

@media (min-width: 1280px) {
  .container-responsive {
    max-width: 1200px;
  }
}

/* ------------------------------------------------------------
   RESPONSIVE FLEX UTILITIES
   ------------------------------------------------------------ */
.flex-col-mobile {
  flex-direction: column;
}

@media (min-width: 768px) {
  .flex-col-mobile {
    flex-direction: row;
  }
}

.flex-wrap-mobile {
  flex-wrap: wrap;
}

@media (min-width: 576px) {
  .flex-wrap-mobile {
    flex-wrap: nowrap;
  }
}

/* ------------------------------------------------------------
   RESPONSIVE SPACING
   ------------------------------------------------------------ */
.m-mobile-0 { margin: 0; }
.p-mobile-0 { padding: 0; }

@media (min-width: 768px) {
  .m-desktop-4 { margin: 1rem; }
  .p-desktop-4 { padding: 1rem; }
}

/* ------------------------------------------------------------
   TOUCH OPTIMIZATIONS
   ------------------------------------------------------------ */
@media (hover: none) and (pointer: coarse) {
  .hover\:bg-white\/10:hover {
    background-color: transparent;
  }
  
  .produto-card:active {
    transform: scale(0.96);
  }
  
  button, 
  .btn {
    padding: 0.75rem 1rem;
    min-height: 44px;
  }
  
  input, 
  select {
    padding: 0.75rem;
    min-height: 44px;
  }
  
  .table-base td {
    padding: 0.5rem;
  }
  
  .bottom-nav-link {
    min-height: 60px;
  }
}

/* Safe area padding for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .bottom-nav-link {
    padding-top: max(0.5rem, env(safe-area-inset-top, 0));
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0));
  }
}

/* ------------------------------------------------------------
   PRINT — hide everything by default (print.css handles rest)
   ------------------------------------------------------------ */
@media print {
  body > *:not(.cupom-print) {
    display: none !important;
  }
  .cupom-print {
    display: block !important;
  }
}
