/**
 * POS Application - Main Stylesheet
 * Modern, attractive design with gradient accents
 */

:root {
  --primary-color: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #6366f1;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #3b82f6;
  --dark-color: #1f2937;
  --light-color: #f9fafb;
  --border-color: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
}

/* Navbar */
.navbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 1rem 0;
}

.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.nav-brand h2 {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.5rem;
  font-weight: 700;
}

.nav-menu {
  display: flex;
  gap: 1rem;
  flex: 1;
  justify-content: center;
}

.nav-link {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 0.3s ease;
  position: relative;
}

.nav-link:hover {
  color: var(--primary-color);
  background: rgba(79, 70, 229, 0.1);
}

.nav-link.active {
  color: var(--primary-color);
  background: rgba(79, 70, 229, 0.1);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 1rem;
  right: 1rem;
  height: 2px;
  background: var(--primary-color);
  border-radius: 2px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.user-name {
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  padding: 0.25rem 0.75rem;
  background: var(--primary-color);
  color: white;
  border-radius: 20px;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 600;
}

.btn-logout {
  padding: 0.5rem 1rem;
  background: var(--danger-color);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 500;
  transition: all 0.3s ease;
}

.btn-logout:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Main Content */
.main-content {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 2rem;
}

.breadcrumb {
  margin-bottom: 1.5rem;
  color: white;
  font-size: 0.9rem;
}

.breadcrumb a {
  color: white;
  text-decoration: none;
  opacity: 0.8;
}

.breadcrumb a:hover {
  opacity: 1;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 1.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  font-size: 0.9rem;
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-success:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--text-secondary);
  color: white;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-icon {
  padding: 0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-select {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  background: white;
  cursor: pointer;
}

/* Tables */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
}

.table-container::-webkit-scrollbar {
  height: 8px;
}

.table-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
}

.table thead {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
  color: white;
}

.table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.table tbody tr {
  transition: background 0.2s ease;
}

.table tbody tr:hover {
  background: rgba(79, 70, 229, 0.05);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Statistics Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--primary-color),
    var(--primary-light)
  );
}

.stat-card:hover {
  transform: translateY(-4px);
}

.stat-card.success::before {
  background: linear-gradient(90deg, var(--success-color), #34d399);
}

.stat-card.warning::before {
  background: linear-gradient(90deg, var(--warning-color), #fbbf24);
}

.stat-card.danger::before {
  background: linear-gradient(90deg, var(--danger-color), #f87171);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.stat-change {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-change.positive {
  color: var(--success-color);
}

.stat-change.negative {
  color: var(--danger-color);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
}

.badge-info {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info-color);
}

/* Alerts */
.alert {
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border-left: 4px solid;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success-color);
  color: #065f46;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger-color);
  color: #991b1b;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--warning-color);
  color: #92400e;
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--info-color);
  color: #1e40af;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 3rem;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--primary-light)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-secondary);
}

/* Grid System */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Responsive Tables - Card View on Mobile */
@media (max-width: 768px) {
  /* Table becomes card-based on mobile */
  .table-container {
    overflow-x: visible;
  }

  .table-responsive-mobile .table thead {
    display: none;
  }

  .table-responsive-mobile .table tbody tr {
    display: block;
    margin-bottom: 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
  }

  .table-responsive-mobile .table tbody td {
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
  }

  .table-responsive-mobile .table tbody td:before {
    content: attr(data-label);
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
  }

  .table-responsive-mobile .table tbody td:last-child {
    border-bottom: none;
    padding-top: 1rem;
  }

  /* Action buttons in tables */
  .table-responsive-mobile .actions-cell .actions-wrapper {
    display: none;
  }

  .table-responsive-mobile .actions-cell .actions-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .table-responsive-mobile .actions-mobile .btn {
    flex: 1;
    min-width: calc(50% - 0.25rem);
  }
}

/* Mobile Menu Toggle (Hamburger) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 1001;
  gap: 5px;
}

.nav-toggle span {
  width: 100%;
  height: 3px;
  background: var(--primary-color);
  border-radius: 3px;
  transition: all 0.3s ease;
}

.nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(8px, 8px);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(8px, -8px);
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

/* Tablet Navigation */
@media (max-width: 1024px) and (min-width: 769px) {
  .nav-menu {
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .user-name {
    font-size: 0.875rem;
  }

  .user-role {
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
  }

  .btn-logout {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
  }
}

@media (max-width: 768px) {
  .nav-container {
    padding: 0.75rem 1rem;
    position: relative;
  }

  .nav-brand {
    flex: 1;
  }

  .nav-brand h2 {
    font-size: 1.125rem;
  }

  .nav-brand img {
    max-height: 32px !important;
    max-width: 100px !important;
  }

  /* Show hamburger menu */
  .nav-toggle {
    display: flex;
    order: 2;
  }

  /* Hide menu by default on mobile */
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    width: 100%;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-top: 2px solid var(--border-color);
    margin-top: 0.5rem;
    gap: 0;
    z-index: 1000;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }

  /* Show menu when active */
  .nav-menu.active {
    display: flex;
  }

  .nav-link {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: block;
    text-align: left;
  }

  .nav-link:last-child {
    border-bottom: none;
  }

  .nav-user {
    order: 3;
    width: 100%;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
  }

  .user-dropdown {
    width: 100%;
  }

  .user-dropdown-toggle {
    width: 100%;
    padding: 1rem;
    justify-content: space-between;
  }

  .user-info {
    align-items: flex-start;
  }

  .user-name {
    font-size: 1rem;
    font-weight: 600;
  }

  .user-role {
    font-size: 0.875rem;
    padding: 0.35rem 0.75rem;
  }

  .user-dropdown-menu {
    position: static !important;
    width: 100% !important;
    margin-top: 0.5rem !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
  }

  .user-dropdown-item {
    width: 100%;
  }

  /* Dropdown menus in nav */
  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-toggle {
    width: 100%;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .nav-dropdown-menu {
    position: static !important;
    display: none !important;
    box-shadow: none !important;
    background: var(--light-color) !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
    border-radius: 0;
  }

  .nav-dropdown.active .nav-dropdown-menu {
    display: block !important;
  }

  .nav-dropdown-item {
    padding: 0.875rem 1rem 0.875rem 2rem !important;
    border-bottom: 1px solid var(--border-color);
    display: block;
    width: 100%;
  }

  .nav-dropdown-item:last-child {
    border-bottom: none;
  }
}

@media (max-width: 480px) {
  .nav-brand h2 {
    font-size: 1rem;
  }

  .nav-menu {
    padding: 0.75rem;
  }

  .nav-link {
    padding: 0.875rem;
    font-size: 0.95rem;
  }
}

/* Prevent body scroll when menu is open on mobile */
@media (max-width: 768px) {
  body.nav-open {
    overflow: hidden;
  }
}

/* Main Content Responsive */
@media (max-width: 768px) {
  .main-content {
    padding: 0 1rem;
    margin: 1rem auto;
  }

  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 1rem;
  }

  .card-title {
    font-size: 1.125rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Forms Responsive */
@media (max-width: 768px) {
  .form-group {
    margin-bottom: 1rem;
  }

  .form-control,
  .form-select {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .btn {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
  }

  .btn-sm {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
  }

  .action-buttons {
    flex-direction: column;
    width: 100%;
  }

  .action-buttons .btn {
    width: 100%;
  }
}

/* Buttons Responsive */
@media (max-width: 768px) {
  /* Button groups stack on mobile */
  .btn-group {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .btn-group .btn:last-child {
    margin-bottom: 0;
  }
}

/* Search Bar Responsive */
@media (max-width: 768px) {
  .search-bar {
    margin-bottom: 1rem;
  }

  .search-bar input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Modal/Dialog Responsive */
@media (max-width: 768px) {
  .modal-overlay {
    padding: 0.5rem;
    align-items: flex-start;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 1rem;
    max-height: calc(100vh - 1rem);
    border-radius: var(--radius);
  }

  .modal-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

/* Login Page Responsive */
@media (max-width: 768px) {
  .login-container {
    padding: 1rem;
  }

  .login-card {
    padding: 2rem 1.5rem;
  }

  .login-header h1 {
    font-size: 1.75rem;
  }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
  .nav-brand h2 {
    font-size: 1.125rem;
  }

  .nav-menu {
    gap: 0.25rem;
  }

  .nav-link {
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
  }

  .card {
    padding: 0.75rem;
  }

  .card-title {
    font-size: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .table-responsive-mobile .table tbody td {
    font-size: 0.875rem;
  }

  .btn {
    padding: 0.75rem;
    font-size: 0.875rem;
  }

  .breadcrumb {
    font-size: 0.8rem;
  }
}

/* Large Screens */
@media (min-width: 1200px) {
  .main-content {
    max-width: 1600px;
  }

  .nav-container {
    max-width: 1600px;
  }
}

/* Print Styles */
@media print {
  .navbar,
  .breadcrumb,
  .btn,
  .action-buttons,
  .search-bar,
  .card-header .btn {
    display: none !important;
  }

  .main-content {
    margin: 0;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* POS Layout Responsive */
@media (max-width: 768px) {
  .pos-layout.grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Touch-friendly Elements */
@media (hover: none) and (pointer: coarse) {
  /* Touch devices */
  .btn,
  .nav-link,
  .form-control,
  .form-select {
    min-height: 44px; /* Minimum touch target size */
  }

  .btn-sm {
    min-height: 36px;
  }

  /* Remove hover effects on touch devices */
  .card:hover {
    transform: none;
  }

  .btn:hover {
    transform: none;
  }
}

/* Loading Spinner */
.spinner {
  border: 3px solid rgba(79, 70, 229, 0.1);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  min-width: fit-content;
}

.action-buttons .btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Search Bar */
.search-bar {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-bar input {
  padding-left: 2.5rem;
}

.search-bar::before {
  content: "🔍";
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
}
