/* Central Design System for Çanta POS & Admin Application */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #334155;
  --bg-glass: rgba(30, 41, 59, 0.75);
  --bg-glass-border: rgba(255, 255, 255, 0.1);
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #8b5cf6; /* Purple */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --accent-glow: 0 0 20px rgba(99, 102, 241, 0.35);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --status-success: #10b981;
  --status-success-bg: rgba(16, 185, 129, 0.15);
  --status-warning: #f59e0b;
  --status-warning-bg: rgba(245, 158, 11, 0.15);
  --status-danger: #ef4444;
  --status-danger-bg: rgba(239, 68, 68, 0.15);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.4);

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Glassmorphism Container */
.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Header & Navbar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bg-glass-border);
  padding: 0.75rem 1.25rem;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: var(--accent-glow);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.role-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.role-admin {
  background: rgba(139, 92, 246, 0.2);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.role-seller {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.btn-logout {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
}

/* Layout Main Wrapper */
.main-wrapper {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  flex: 1;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-info h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-heading);
}

.kpi-icon-box {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Controls & Search Bar */
.section-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}

.filter-select {
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  cursor: pointer;
}

/* Primary & Secondary Buttons */
.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--accent-glow);
  transition: transform 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--bg-glass-border);
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: #475569;
}

/* Product Grid Layout */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

/* Product Card */
.product-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.product-image-wrap {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 Aspect Ratio */
  background: #090d16;
  overflow: hidden;
}

.product-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card:hover .product-image {
  transform: scale(1.05);
}

.product-code-tag {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  letter-spacing: 0.05em;
}

.stock-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-stock-in {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-stock-low {
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-stock-out {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.product-content {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.product-color {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.product-prices {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-top: 1px dashed var(--bg-glass-border);
  border-bottom: 1px dashed var(--bg-glass-border);
  margin-bottom: 1rem;
}

.price-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sale-price {
  font-size: 1.25rem;
  font-weight: 800;
  color: #38bdf8;
  font-family: var(--font-heading);
}

.cost-price {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: line-through;
}

.product-actions {
  margin-top: auto;
  display: flex;
  gap: 0.5rem;
}

.btn-sell-quick {
  flex: 1;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.btn-sell-quick:hover:not(:disabled) {
  background: rgba(16, 185, 129, 0.35);
  color: #ffffff;
}

.btn-sell-quick:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-delete-prod {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

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

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* Image Upload & Canvas Preview */
.upload-dropzone {
  border: 2px dashed var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.2s ease;
  background: rgba(15, 23, 42, 0.4);
}

.upload-dropzone:hover {
  border-color: var(--accent-primary);
}

.upload-dropzone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 2.2rem;
  margin-bottom: 0.4rem;
}

.upload-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.compression-status {
  display: none;
  font-size: 0.82rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.compression-status-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.image-preview-container {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.image-preview {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--bg-glass-border);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--bg-glass-border);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  animation: slideInRight 0.3s ease;
  max-width: 360px;
}

.toast-success {
  border-left: 4px solid var(--status-success);
}

.toast-danger {
  border-left: 4px solid var(--status-danger);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Category Management Drawer / Section */
.categories-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.category-chip {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--bg-glass-border);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-chip-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-chip-delete:hover {
  color: #f87171;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

/* Responsive Mobile Rules for Smartphones & Tablets */
@media (max-width: 768px) {
  .app-header {
    padding: 0.5rem 0.75rem;
  }

  .header-container {
    gap: 0.5rem;
    flex-wrap: nowrap;
  }

  .brand-logo span {
    font-size: 1rem;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .user-profile {
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .role-badge {
    padding: 0.2rem 0.5rem;
    font-size: 0.68rem;
  }

  #userInfo {
    display: none !important; /* Hide long name text on mobile to avoid overflow */
  }

  .btn-logout {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
  }

  .main-wrapper {
    padding: 1rem 0.75rem;
  }

  .section-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .search-box {
    width: 100%;
    min-width: 100%;
  }

  .filter-select {
    width: 100%;
    min-width: 100%;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 0.75rem;
  }

  .product-content {
    padding: 0.85rem;
  }

  .product-title {
    font-size: 0.95rem;
  }

  .sale-price {
    font-size: 1.1rem;
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .kpi-card {
    padding: 0.85rem;
  }

  .kpi-value {
    font-size: 1.15rem;
  }

  .kpi-icon-box {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
}
