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

:root {
  --bg-color: #0b0f19;
  --surface: #111827;
  --surface-hover: #1f2937;
  --border: rgba(255, 255, 255, 0.07);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-primary: #3b82f6; /* Vibrant Blue */
  --accent-glow: rgba(59, 130, 246, 0.25);
  --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 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.light-theme {
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow-card: 0 10px 30px -10px rgba(148, 163, 184, 0.3);
}

.light-theme .desktop-sidebar {
    background: #ffffff;
    border-right: 1px solid rgba(0,0,0,0.06);
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
}
.light-theme .desktop-sidebar .sidebar-item {
    color: #475569;
}
.light-theme .desktop-sidebar .sidebar-item.active {
    background: var(--accent-primary) !important;
    color: #ffffff !important;
}
.light-theme .desktop-sidebar .sidebar-item:hover:not(.active) {
    background: #f1f5f9;
    color: #0f172a;
}

* {
  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: 1400px; /* Enhanced max-width for desktop feel */
  background-color: var(--bg-color);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  box-shadow: var(--shadow-card);
}

/* Premium Desktop Sidebar and Topbar */
.desktop-sidebar {
    display: none;
}
.desktop-only {
    display: none !important;
}

/* Custom Scrollbar matching tipmerkezi-ai admin */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Pulse Dot Animation for Server Indicator */
.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-success);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-green 1.6s infinite;
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@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-only {
        display: flex !important;
    }

    .desktop-sidebar {
        display: flex;
        flex-direction: column;
        width: 280px;
        min-width: 280px;
        height: 100vh;
        border-right: 1px solid var(--border);
        padding: 2rem 1.25rem;
        background: var(--surface);
        position: sticky;
        top: 0;
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1), background var(--transition-speed, 0.3s);
    }

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

    .sidebar-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 0.85rem 1rem;
        border-radius: var(--radius-md);
        color: var(--text-secondary);
        text-decoration: none;
        font-weight: 500;
        font-size: 0.9rem;
        transition: all 0.25s ease;
        border: 1px solid transparent;
    }

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

    .sidebar-item.active {
        background: var(--surface-hover);
        color: var(--accent-primary);
        font-weight: 600;
        border-color: rgba(59, 130, 246, 0.2);
        box-shadow: inset 4px 0 0 var(--accent-primary), var(--shadow-glow);
    }

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

    main {
        flex: 1;
        padding: 2rem 3rem;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

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

    .view {
        display: none !important;
        animation: fadeIn 0.35s ease forwards;
    }
    
    .view.active {
        display: block !important;
    }
    
    /* Elegant transition glow on card hover */
    .card {
        transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    }
    .card:hover {
        transform: translateY(-3px);
        border-color: var(--accent-primary);
        box-shadow: var(--shadow-glow), var(--shadow-card);
    }
    
    .product-item, .cart-item {
        transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
        cursor: pointer;
    }
    .product-item:hover, .cart-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

@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: 30000;
  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;
}

/* Sidebar Collapse Mode */
.desktop-sidebar.sidebar-collapsed {
    width: 80px;
    min-width: 80px;
    padding: 1.5rem 0.5rem;
}
.desktop-sidebar.sidebar-collapsed .brand-name,
.desktop-sidebar.sidebar-collapsed .sidebar-item span,
.desktop-sidebar.sidebar-collapsed .admin-info,
.desktop-sidebar.sidebar-collapsed #sidebar-firm-id,
.desktop-sidebar.sidebar-collapsed #btn-toggle-theme {
    display: none !important;
}
.desktop-sidebar.sidebar-collapsed .brand-logo {
    margin: 0 auto;
}
.desktop-sidebar.sidebar-collapsed .sidebar-brand {
    flex-direction: column;
    justify-content: center;
    padding-bottom: 1rem;
    gap: 0.5rem;
}
.desktop-sidebar.sidebar-collapsed #btn-toggle-sidebar {
    margin: 0 auto;
}
.desktop-sidebar.sidebar-collapsed .sidebar-item {
    justify-content: center;
    padding: 0.75rem 0;
}
.desktop-sidebar.sidebar-collapsed .sidebar-item i {
    margin-right: 0;
    font-size: 1.2rem;
}
.desktop-sidebar.sidebar-collapsed .admin-profile {
    justify-content: center;
}
.desktop-sidebar.sidebar-collapsed #desktop-logout-btn {
    display: none;
}

.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;
}

/* Toast Notification Style */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card), var(--shadow-glow);
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    font-weight: 600;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Premium Glassmorphic Ambient Glow Login Page */
#view-company-login {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(5, 7, 12, 0.4) !important; /* Translucent deep space dark */
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    z-index: 99999 !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Moving ambient glow circles in the background */
#view-company-login::before,
#view-company-login::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(100px);
    z-index: 1;
    opacity: 0.35;
    pointer-events: none;
    animation: floatGlow 15s infinite alternate ease-in-out;
}

#view-company-login::before {
    background: radial-gradient(circle, var(--accent-primary) 0%, rgba(59, 130, 246, 0) 70%);
    top: -50px;
    left: -50px;
}

#view-company-login::after {
    background: radial-gradient(circle, #8b5cf6 0%, rgba(139, 92, 246, 0) 70%);
    bottom: -50px;
    right: -50px;
    animation-delay: -7.5s;
}

@keyframes floatGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(100px, 60px) scale(1.25);
    }
}

/* Glassmorphic Login Card */
#view-company-login .card {
    position: relative;
    z-index: 10;
    width: 90%;
    max-width: 400px;
    background: rgba(17, 24, 39, 0.6) !important;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    padding: 2.5rem 2rem !important;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#view-company-login .card:hover {
    border-color: rgba(59, 130, 246, 0.25) !important;
    box-shadow: 0 25px 60px rgba(59, 130, 246, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Premium Light Theme Support for Login Page */
.light-theme #view-company-login {
    background-color: rgba(241, 245, 249, 0.4) !important;
}
.light-theme #view-company-login::before {
    background: radial-gradient(circle, rgba(59, 130, 246, 0.25) 0%, rgba(59, 130, 246, 0) 70%);
}
.light-theme #view-company-login::after {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.25) 0%, rgba(139, 92, 246, 0) 70%);
}
.light-theme #view-company-login .card {
    background: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: 0 20px 40px rgba(148, 163, 184, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
