/* UniSmart Design System - Production Grade CSS */

:root {
  /* Colors */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  
  --secondary: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #f43f5e;
  
  --dark: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #0f172a;
  
  /* Dimensions */
  --sidebar-w: 260px;
  --header-h: 70px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--slate-700);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--dark);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   App Layout Shell
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: #cbd5e1;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1020;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  transition: transform 0.25s ease-in-out;
}

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.sidebar-brand-text {
  font-size: 1.2rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.sidebar-brand-accent {
  color: #818cf8;
}

.sidebar-role-badge-container {
  padding: 16px 20px 8px;
}

.sidebar-role-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 0.75rem;
  color: #cbd5e1;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-role-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.sidebar-nav {
  padding: 8px 16px 32px;
  flex: 1;
}

.nav-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 18px 12px 6px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 500;
  font-size: 0.88rem;
  margin-bottom: 2px;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}

.sidebar-nav-item svg {
  width: 18px;
  height: 18px;
  color: #64748b;
  flex-shrink: 0;
  transition: color 0.15s;
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.sidebar-nav-item:hover svg {
  color: #818cf8;
}

.sidebar-nav-item.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.sidebar-nav-item.active svg {
  color: #ffffff;
}

/* Header & Main Area */
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-search {
  position: relative;
  width: 320px;
}

.header-search input {
  width: 100%;
  padding: 9px 16px 9px 40px;
  background: var(--slate-100);
  border: 1px solid transparent;
  border-radius: 9999px;
  font-size: 0.85rem;
  color: var(--dark);
  outline: none;
  transition: all 0.2s;
}

.header-search input:focus {
  background: #ffffff;
  border-color: var(--primary-200);
  box-shadow: 0 0 0 3px var(--primary-50);
}

.header-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-400);
  font-size: 0.85rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tenant-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  border-radius: 9999px;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}

.user-profile-btn:hover {
  background: var(--slate-100);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.app-content {
  padding: 32px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* ==========================================================================
   Component System: Cards, Stat Widgets, Buttons, Tables
   ========================================================================== */

.card-modern {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
  overflow: hidden;
}

.card-modern-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header-modern {
  padding: 18px 24px;
  border-bottom: 1px solid var(--slate-100);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* KPI Stat Cards */
.stat-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.stat-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.1;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon-indigo { background: var(--primary-50); color: var(--primary); }
.stat-icon-emerald { background: #ecfdf5; color: var(--success); }
.stat-icon-amber { background: #fffbeb; color: var(--warning); }
.stat-icon-rose { background: #fff1f2; color: var(--danger); }
.stat-icon-blue { background: #f0f9ff; color: var(--secondary); }

/* Buttons */
.btn-primary-custom {
  background: var(--primary);
  color: #ffffff !important;
  border: 1px solid transparent;
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
  transition: all 0.15s ease-in-out;
}

.btn-primary-custom:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
  transform: translateY(-1px);
}

.btn-secondary-custom {
  background: #ffffff;
  color: var(--dark) !important;
  border: 1px solid var(--slate-300, #cbd5e1);
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.btn-secondary-custom:hover {
  background: var(--slate-100);
  border-color: var(--slate-400);
}

.btn-sm-custom {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 6px;
}

/* Badges */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.badge-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.badge-info { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-neutral { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-indigo { background: var(--primary-50); color: var(--primary); border: 1px solid var(--primary-200); }

/* Form Controls */
.form-label-custom {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--dark);
  margin-bottom: 6px;
  display: block;
}

.form-control-custom {
  width: 100%;
  padding: 9px 14px;
  background: #ffffff;
  border: 1px solid var(--slate-300, #cbd5e1);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--dark);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control-custom:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-100);
}

/* Table */
.table-container {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-modern {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
}

.table-modern th {
  background: var(--slate-50);
  color: var(--slate-500);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 20px;
  border-bottom: 1px solid var(--slate-200);
  text-align: left;
}

.table-modern td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-700);
  font-size: 0.88rem;
  vertical-align: middle;
}

.table-modern tbody tr:last-child td {
  border-bottom: none;
}

.table-modern tbody tr:hover {
  background-color: var(--slate-50);
}

/* Catalogue Grid & Cards */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.product-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
}

.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--primary-200);
}

.product-card-img-wrapper {
  height: 200px;
  background: var(--slate-100);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.product-card:hover .product-card-img {
  transform: scale(1.04);
}

.product-card-placeholder {
  font-size: 2.8rem;
  color: var(--slate-400);
}

.product-card-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-card-category {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 4px;
}

.product-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
  line-height: 1.35;
}

.product-card-price {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--dark);
}

.product-card-contract-price {
  color: var(--success);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 56px 24px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  background: var(--slate-100);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-400);
  font-size: 1.8rem;
  margin-bottom: 16px;
}

.empty-state-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 8px;
}

.empty-state-text {
  color: var(--slate-500);
  max-width: 440px;
  margin: 0 auto 20px;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Login Split Layout */
.login-container {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

.login-left {
  flex: 1;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 80px;
  position: relative;
  overflow: hidden;
}

.login-left::after {
  content: '';
  position: absolute;
  top: -20%;
  right: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, rgba(99, 102, 241, 0) 70%);
  border-radius: 50%;
}

.login-right {
  flex: 1;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
}

.login-box {
  width: 100%;
  max-width: 440px;
}

/* Responsive */
@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.show {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }

  .header-search {
    width: 200px;
  }

  .app-content {
    padding: 20px;
  }

  .login-container {
    flex-direction: column;
  }
  
  .login-left {
    padding: 40px 24px;
    min-height: auto;
  }
  
  .login-right {
    padding: 32px 20px;
  }
}