/* =====================================================
   Global App Styles - Infosistemas ERP Web PDV
   Colors: #114368 (Deep Blue), #2DB2E8 (Light Blue)
   Fonts: Audiowide, Montserrat
   ===================================================== */

:root {
  --color-primary: #114368;
  --color-primary-dark: #0b2e49;
  --color-secondary: #2DB2E8;
  --color-secondary-light: #6bcbf2;
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-text-main: #1f2937;
  --color-text-light: #6b7280;
  --color-border: #e5e7eb;
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;

  --font-brand: 'Audiowide', cursive;
  --font-body: 'Montserrat', sans-serif;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  --header-height: 70px;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text-main);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

ul {
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin-bottom: 0.5em;
  font-weight: 700;
  color: var(--color-primary);
}

.font-brand {
  font-family: var(--font-brand);
}

/* Layout Structure */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--color-bg);
}

.app-header {
  height: var(--header-height);
  background: linear-gradient(to right, var(--color-primary), var(--color-secondary));
  color: white;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 50;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-brand);
  font-size: 1.4rem;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-brand img {
  height: 38px;
  width: auto;
}

.app-company-info {
  display: flex;
  flex-direction: column;
  margin-left: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.2;
}

.app-company-name {
  font-weight: 600;
}

.app-company-cnpj {
  font-weight: 400;
  opacity: 0.8;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  transition: all 0.2s;
  font-size: 0.95rem;
  position: relative;
  padding: 0.5rem 0;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-secondary);
  transition: width 0.3s;
}

.nav-link:hover {
  color: #ffffff;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

.nav-link.active {
  color: #ffffff;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  padding: 0.6rem 1.25rem;
  border-radius: 50px;
  /* Pill shape */
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.app-company-info-right {
  align-items: flex-end;
  text-align: right;
}

.app-fullscreen-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.app-fullscreen-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.7);
  transform: translateY(-1px);
}

.app-shortcuts-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.app-shortcuts-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.7);
  transform: translateY(-1px);
}

.shortcuts-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.shortcut-key {
  min-width: 60px;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(17, 67, 104, 0.08);
  color: var(--color-primary);
  font-weight: 600;
  text-align: center;
  border: 1px solid rgba(17, 67, 104, 0.2);
}

.shortcut-description {
  color: var(--color-text-main);
}

.user-menu:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.app-main {
  flex: 1;
  padding: 1.5rem;
  width: 100%;
  max-width: 100%;
  /* Use full width for PDV */
}

/* PDV Specific Layout */
.pdv-container {
  display: flex;
  gap: 1.5rem;
  height: calc(100vh - var(--header-height) - 3rem);
  /* Full height minus header and padding */
}

.pdv-left-panel {
  flex: 0 0 40%;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pdv-right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pdv-left-top {
  height: 30%;
  width: 100%;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  /* Center vertically */
  justify-content: center;
}

/* Search Box Container */
.pdv-search-box {
  width: 100%;
  /* Removed max-width to allow full width usage within the 40% panel */
  background: var(--color-surface);
  /* Restored white background */
  padding: 1.5rem;
  /* Restored padding */
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

.search-label {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-brand);
}

/* Custom PDV Input */
.pdv-input-wrapper {
  position: relative;
  width: 100%;
}

.pdv-input {
  width: 100%;
  height: 65px;
  padding: 0 1.5rem;
  font-size: 1.5rem;
  /* Large font size requested */
  font-weight: 600;
  color: var(--color-primary);
  background: #ffffff;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
  outline: none;
  font-family: var(--font-body);
}

.pdv-input:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 4px rgba(45, 178, 232, 0.25);
}

.pdv-input::placeholder {
  color: #cbd5e1;
  font-weight: 400;
  font-size: 1.1rem;
}

/* Search Results Dropdown */
.pdv-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
}

.pdv-search-results.hidden {
  display: none;
}

.pdv-result-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s;
}

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

.pdv-result-item:hover,
.pdv-result-item.selected {
  background-color: #e0f2fe;
}

.pdv-result-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text-main);
  margin-bottom: 0.25rem;
}

.pdv-result-details {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: #64748b;
}

.pdv-result-code {
  font-family: monospace;
  background: #f1f5f9;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.pdv-result-stock {
  font-weight: 500;
}

.pdv-result-price {
  margin-left: auto;
  font-weight: 700;
  color: var(--color-success);
  font-size: 1.2rem;
}

.pdv-no-results {
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-light);
  font-style: italic;
}

/* Custom Scrollbar for results */
.pdv-search-results::-webkit-scrollbar {
  width: 6px;
}

.pdv-search-results::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.pdv-search-results::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.pdv-left-bottom {
  height: 70%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.pdv-logo-large {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* Optional: drop shadow or filter if needed for visibility */
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

/* Right Panel: Current Sale */
.current-sale-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.sale-header {
  background: linear-gradient(to right, var(--color-primary), var(--color-secondary));
  color: white;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sale-header h3 {
  margin: 0;
  color: white;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.current-qty-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
}

.current-qty-value {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

.sale-id {
  background: rgba(255, 255, 255, 0.15);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: monospace;
}

.product-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Scrollbar styling */
.product-list-container::-webkit-scrollbar {
  width: 6px;
}

.product-list-container::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.product-list-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.product-list-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Product Grid Fix */
.product-item {
  display: flex;
  align-items: flex-start;
  padding: 0.85rem;
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  /* Prevents shrinking */
}

.product-item-canceled {
  opacity: 0.8;
}

.product-item-canceled .product-name,
.product-item-canceled .product-pricing,
.product-item-canceled .product-total {
  color: var(--color-danger);
  text-decoration: line-through;
}

/* ... existing hover styles ... */
.product-item:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.product-sequence {
  font-family: var(--font-brand);
  color: var(--color-text-light);
  font-size: 1.1rem;
  font-weight: 600;
  margin-right: 1rem;
  min-width: 1.5rem;
  text-align: right;
  opacity: 0.5;
  padding-top: 0.1rem;
}

.product-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.product-name {
  font-weight: 600;
  color: var(--color-text-main);
  font-size: 1rem;
  line-height: 1.3;
}

.product-codes {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
}

.code-badge {
  background: rgba(17, 67, 104, 0.1);
  color: var(--color-primary);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  font-family: monospace;
}

.ean-text {
  color: var(--color-text-light);
  font-family: monospace;
}

.product-pricing {
  font-size: 0.9rem;
  color: var(--color-primary);
  font-weight: 500;
  margin-top: 0.2rem;
}

.product-pricing .qty {
  color: var(--color-text-main);
  font-weight: 700;
  margin-right: 0.25rem;
}

.product-total {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary);
  margin-left: 1rem;
  white-space: nowrap;
  align-self: center;
}

.sale-footer {
  background: #ffffff;
  padding: 0;
  border-top: none;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.total-row.total-highlight {
  margin: 0;
  padding: 1.5rem;
  background: linear-gradient(to right, var(--color-primary), var(--color-secondary));
  color: white;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  /* Rounded bottom corners */
  border-top: none;
}

.total-row.total-highlight .total-label {
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
  font-family: var(--font-brand);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.total-row.total-highlight .total-value {
  font-size: 2.2rem;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Utilities */
.text-center {
  text-align: center;
}

.mb-1 {
  margin-bottom: 0.25rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 0.75rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mt-4 {
  margin-top: 1rem;
}

/* Responsive */
@media (max-width: 900px) {
  .pdv-container {
    flex-direction: column;
    height: auto;
  }

  .pdv-left-panel {
    display: none;
    /* Hide empty left panel on mobile for now */
  }

  .current-sale-card {
    height: 600px;
    /* Fixed height for mobile scroll */
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 1rem;
  }

  .app-main {
    padding: 1rem;
  }

  .nav-link {
    display: none;
  }
}