/* ERP System - Premium Professional Light Mode Stylesheet */

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

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Color Palette */
  --bg-app: #f8fafc;        /* Slate 50 */
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-hover: #f1f5f9;       /* Slate 100 */
  
  --primary: #2563eb;        /* Cobalt Blue 600 */
  --primary-hover: #1d4ed8;  /* Cobalt Blue 700 */
  --primary-light: #eff6ff;
  
  --success: #10b981;        /* Emerald Green 500 */
  --success-light: #ecfdf5;
  --warning: #f59e0b;        /* Amber 500 */
  --warning-light: #fef3c7;
  --danger: #ef4444;         /* Red 500 */
  --danger-light: #fef2f2;
  
  --border: #e2e8f0;         /* Slate 200 */
  --border-focus: #3b82f6;   /* Blue 500 */
  
  --text-main: #0f172a;      /* Slate 900 */
  --text-muted: #64748b;     /* Slate 500 */
  --text-light: #94a3b8;     /* Slate 400 */
  --text-white: #ffffff;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);

  /* Dimensions */
  --sidebar-width: 250px;
  --header-height: 64px;
  --border-radius: 8px;
  --transition-speed: 0.2s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Utility Classes */
.d-none { display: none !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-right { text-align: right; }
.cursor-pointer { cursor: pointer; }

/* Main views wrapper */
#app {
  width: 100%;
  height: 100vh;
  position: relative;
}

/* ==========================================================================
   1. LOGIN VIEW
   ========================================================================== */
#login-view {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1000;
}

.login-card {
  background: var(--bg-card);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  animation: slideUp 0.4s ease-out;
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  background-color: #fff;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed);
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--border-radius);
  border: none;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-speed);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--text-white);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--bg-hover);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: #e2e8f0;
}

.btn-danger {
  background-color: var(--danger);
  color: var(--text-white);
}

.btn-danger:hover {
  background-color: #dc2626;
}

.login-error {
  background-color: var(--danger-light);
  color: var(--danger);
  padding: 10px;
  border-radius: var(--border-radius);
  font-size: 13px;
  margin-bottom: 20px;
  border: 1px solid rgba(239, 68, 68, 0.15);
  display: none;
}

/* ==========================================================================
   2. ERP SYSTEM LAYOUT
   ========================================================================== */
#erp-view {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* Sidebar styling */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 20px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-profile-bar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background-color: #fafbfd;
}

.user-profile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.user-profile-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--border-radius);
  margin-bottom: 2px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-main);
}

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

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

/* Main Container Area */
.main-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.navbar {
  height: var(--header-height);
  background-color: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.breadcrumb {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Content Body */
#content-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ==========================================================================
   3. COMPONENTS & VIEWS
   ========================================================================== */

/* Cards Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card-info h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-card-info p {
  font-size: 24px;
  font-weight: 700;
  margin-top: 8px;
  color: var(--text-main);
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card-icon.primary { background-color: var(--primary-light); color: var(--primary); }
.stat-card-icon.success { background-color: var(--success-light); color: var(--success); }
.stat-card-icon.warning { background-color: var(--warning-light); color: var(--warning); }
.stat-card-icon.danger { background-color: var(--danger-light); color: var(--danger); }

/* Dashboard layout sections */
.dashboard-section-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .dashboard-section-layout {
    grid-template-columns: 1fr;
  }
}

/* Card layout wrapper */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* Data Tables */
.table-wrapper {
  overflow-x: auto;
  width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background-color: var(--bg-hover);
  color: var(--text-muted);
  font-weight: 500;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

.data-table tbody tr:hover {
  background-color: #fafbfc;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 9999px;
}

.badge-inbound { background-color: var(--success-light); color: var(--success); }
.badge-outbound { background-color: var(--primary-light); color: var(--primary); }
.badge-return_in { background-color: var(--warning-light); color: var(--warning); }
.badge-return_out { background-color: var(--danger-light); color: var(--danger); }

.badge-income { background-color: var(--success-light); color: var(--success); }
.badge-expense { background-color: var(--danger-light); color: var(--danger); }

/* Forms Layout */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* Action Controls Header (Search & Add Button) */
.action-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.search-input-group {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.search-input {
  padding-left: 36px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  width: 16px;
  height: 16px;
}

/* Order Item Form Table */
.order-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.order-items-table th, .order-items-table td {
  padding: 8px;
  border: 1px solid var(--border);
}

.order-items-table th {
  background-color: var(--bg-hover);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

/* Modals Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  animation: scaleUp 0.2s ease-out;
}

.modal-content.wide {
  max-width: 800px;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Permissions checkboxes grid */
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  background-color: var(--bg-hover);
  padding: 16px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
}

.perm-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.perm-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
}

.perm-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Simple Chart Bar */
.trend-chart-container {
  height: 250px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 0 20px 0;
  border-bottom: 1px solid var(--border);
  gap: 6px;
}

.chart-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-grow: 1;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.chart-bar-group:hover .chart-tooltip {
  display: block;
}

.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  width: 100%;
  height: 85%;
  justify-content: center;
}

.chart-bar {
  width: 12px;
  border-radius: 2px 2px 0 0;
  transition: height 0.3s ease;
}

.chart-bar.sales {
  background-color: #93c5fd; /* Light Blue */
}

.chart-bar.profit {
  background-color: #34d399; /* Emerald Green */
}

.chart-label {
  font-size: 9px;
  color: var(--text-light);
  margin-top: 6px;
  transform: rotate(-30deg);
  white-space: nowrap;
}

.chart-tooltip {
  position: absolute;
  bottom: 100%;
  background: var(--text-main);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 50;
  box-shadow: var(--shadow-md);
  display: none;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 14px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.finance-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.finance-card {
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: var(--border-radius);
  background-color: #fafbfc;
}

.finance-card h4 {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.finance-card p {
  font-size: 18px;
  font-weight: 700;
  margin-top: 6px;
}
