@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-color: #0d1117;
  --surface: #161b22;
  --surface-hover: #21262d;
  --border: #30363d;
  --text-primary: #f0f6fc;
  --text-secondary: #8b949e;
  
  --accent-primary: #3b82f6; /* Vibrant Blue */
  --accent-glow: rgba(59, 130, 246, 0.5);
  --accent-success: #10b981; /* Emerald */
  --accent-danger: #ef4444; /* Rose */
  --accent-warning: #f59e0b; /* Amber */
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.light-theme {
    --bg-color: #f0f2f5;
    --surface: #ffffff;
    --surface-hover: #f7f9fc;
    --border: #dce0e5;
    --text-primary: #1c1e21;
    --text-secondary: #606770;
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color); /* Main body backdrop for desktop */
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Base App Wrapper to emulate and calibrate any phone screen */
#app-wrapper {
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  max-width: 100%; /* Flexible by default */
  background-color: var(--bg-color);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  box-shadow: var(--shadow-card);
}

.desktop-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    #app-wrapper {
        display: flex !important;
        flex-direction: row;
        max-width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
        border: none;
    }
    
    .mobile-only {
        display: none !important;
    }

    .desktop-sidebar {
        display: flex;
        flex-direction: column;
        width: 280px;
        min-width: 280px;
        height: 100vh;
        border-right: 1px solid var(--border);
        padding: 2rem 1.5rem;
        background: var(--surface);
        position: sticky;
        top: 0;
        z-index: 200;
    }

    .sidebar-nav {
        margin-top: 2rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        flex: 1;
    }

    .sidebar-item {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 0.85rem 1rem;
        border-radius: var(--radius-md);
        color: var(--text-secondary);
        text-decoration: none;
        font-weight: 500;
        transition: all 0.2s;
    }

    .sidebar-item i {
        width: 20px;
        height: 20px;
    }

    .sidebar-item:hover {
        background: var(--surface-hover);
        color: var(--text-primary);
    }

    .sidebar-item.active {
        background: var(--accent-primary);
        color: white;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    }

    .sidebar-footer {
        padding-top: 1rem;
        border-top: 1px solid var(--border);
    }

    main {
        flex: 1;
        padding: 2.5rem 4rem;
        overflow-y: auto;
    }

    #stock-list, #service-list, #sales-history-list {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
    }

    .view {
        display: none !important;
    }
    
    .view.active {
        display: block !important;
    }
}

@media (min-width: 1400px) {
    #stock-list, #service-list {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (min-width: 1800px) {
    #stock-list, #service-list {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Header & Nav */
header {
  padding: clamp(0.75rem, 2vw, 1.2rem) clamp(1rem, 3vw, 1.5rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: var(--bg-color);
}

/* Glassmorphism utility */
.glass {
  background: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 700;
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kur-badge {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  background: var(--surface-hover);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.kur-badge:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

/* Main Content Area */
main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  padding-bottom: 6rem; /* Space for bottom nav */
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}

.view.active {
  display: block;
}

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

/* Cards & Lists */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  margin-bottom: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-item, .cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  transition: border-color 0.2s ease;
}

.product-item:hover, .cart-item:hover {
  border-color: var(--accent-primary);
}

.product-info h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.product-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  gap: 1rem;
}

.price-tag {
  font-weight: 700;
  color: var(--accent-success);
  font-size: 1.1rem;
}

/* Layout Utilities */
.flex-row { display: flex; align-items: center; gap: 0.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: transparent;
  color: var(--accent-danger);
  border: 1px solid var(--accent-danger);
}

.btn-icon {
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-icon:hover {
  background: var(--border);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.input-control {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s ease;
}

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

/* Bottom Navigation */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-around;
  padding: 0.75rem 0.5rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  z-index: 50;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  transition: color 0.2s;
  cursor: pointer;
}

.nav-item.active {
  color: var(--accent-primary);
}

.nav-item i {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item.active i {
  transform: scale(1.15);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#view-company-login, #view-root-admin {
    z-index: 20000 !important;
}

.desktop-sidebar, .bottom-nav {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

body.overlay-active .desktop-sidebar {
    display: none !important;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 400px;
  padding: 1.5rem;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Scanner Container */
#reader {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px dashed var(--border);
  background: #000;
}

/* Checkout Summary */
.checkout-summary {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Utilities for QR Component */
#reader__dashboard_section_csr span { color: var(--text-primary) !important; }
#reader button { 
  background: var(--surface-hover); 
  color: var(--text-primary); 
  border: 1px solid var(--border); 
  padding: 0.5rem 1rem; 
  border-radius: var(--radius-sm); 
  cursor: pointer;
}
