@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
  /* Premium Glass Theme Variables */
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.05);

  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.5);

  --accent: #10b981;
  /* Emerald Green */
  --accent-glow: rgba(16, 185, 129, 0.4);

  --danger: #ef4444;
  --warning: #f59e0b;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;

  --border-color: rgba(148, 163, 184, 0.1);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);

  --sidebar-width: 240px;
  --header-height: 60px;
  
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --primary-blue: #3b82f6;
  --topbar-bg: #ffffff;
  --body-bg: #f8fafc;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--body-bg);
  color: #1e293b;
  overflow-x: hidden;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1000;
  overflow-y: auto;
  color: white;
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.brand {
  background: #0f172a;
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
  min-width: 0; /* Important for ellipsis inside flex */
}

.brand .branch-name-display {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  display: block;
}

.nav-section-title {
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.05em;
}

.nav-link {
  color: #cbd5e1;
  padding: 0.4rem 1.25rem;
  display: flex;
  align-items: center;
  text-decoration: none;
  font-size: 0.8125rem;
  transition: all 0.2s;
  gap: 0.5rem;
}

.nav-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

.nav-link:hover, .nav-link.active {
  background: var(--sidebar-hover);
  color: white;
}

.nav-link.active {
  border-left: 4px solid var(--primary-blue);
  background: rgba(59, 130, 246, 0.1);
}

/* Main Content */
.main-content {
  flex: 1;
  background: var(--body-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.top-bar { 
    background: var(--topbar-bg); 
    height: 56px; 
    padding: 0 1.5rem; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    width: 100%;
}

.shadow-xs {
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-light:hover {
    background-color: #f1f5f9;
    transform: translateY(-1px);
    transition: all 0.2s;
}

.branch-pill { 
    background: #f1f5f9; 
    border: 1px solid #e2e8f0; 
    border-radius: 50rem; 
    padding: 0.2rem 0.75rem; 
    font-size: 0.75rem; 
    font-weight: 600; 
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.select-compact {
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    background: transparent;
    padding-right: 1.5rem;
    cursor: pointer;
    color: #1e293b;
    outline: none;
}

/* FORCE SELECT2 TO BE BIG AND BEAUTIFUL */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 42px !important;
    padding: 0.4rem 0.5rem !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.5rem !important;
    font-size: 0.9rem !important;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 24px !important;
    color: #1e293b !important;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 40px !important;
}
/* Hide original to prevent double dropdown */
.select2-hidden-accessible {
    display: none !important;
}

/* Checker Focus Mode */
.checker-focus-mode .main-content {
    margin-left: 0 !important;
    width: 100%;
}

/* Glass Card - Updated for Light Theme */
.card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.25rem;
}

.glass-card {
  background: white !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

/* Table Enhancements */
.table thead th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.bg-glass-header {
  background: #f8fafc !important;
}

/* Typography Overrides for Light Theme */
h1, h2, h3, .h1, .h2, .h3 {
  color: #0f172a;
}

.text-muted {
  color: #64748b !important;
}

/* Mobile Responsiveness */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.6);
        z-index: 999;
        backdrop-filter: blur(2px);
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* Mobile Responsive Tables (Card View) */
@media screen and (max-width: 768px) {
  .mobile-table thead {
    display: none;
  }

  .mobile-table, .mobile-table tbody, .mobile-table tr, .mobile-table td {
    display: block;
    width: 100%;
  }

  .mobile-table tr {
    margin-bottom: 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  }

  .mobile-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    padding: 0.5rem 0.25rem;
    border-bottom: 1px solid #f1f5f9;
    min-height: 40px;
  }

  .mobile-table td:last-child {
    border-bottom: 0;
    justify-content: flex-end; /* For remove button */
  }

  /* Label pseudo-element */
  .mobile-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    margin-right: 1rem;
    text-align: left;
    flex-shrink: 0; /* Prevent label from shrinking */
  }

  /* Adjust inputs inside mobile table */
  .mobile-table .form-control, 
  .mobile-table .form-select,
  .mobile-table .select2-container {
    width: auto !important;
    flex-grow: 1;
    max-width: 60%; /* Ensure label has space */
  }
  
  .mobile-table .select2-container {
    text-align: left;
  }

  /* Specific tweaks for small numeric inputs */
  .mobile-table .qty-input, .mobile-table .rate-input {
    text-align: right;
  }
}