/* ==========================================================================
   APP HUB - MODERN COMPACT CRM DESIGN SYSTEM
   Clean, Compact, Fast, Premium UI
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  
  --secondary: #64748b;
  --secondary-light: #f8fafc;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;
  
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;
  
  --info: #06b6d4;
  --info-light: #ecfeff;
  --info-border: #a5f3fc;
  
  --dark: #0f172a;
  --dark-surface: #1e293b;
  --sidebar-bg: #0b1329;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  
  --body-bg: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --border-color-light: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sub: #475569;
  
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  
  --sidebar-width: 250px;
  --navbar-height: 56px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--body-bg);
  color: var(--text-main);
  font-size: 0.875rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
}

/* Custom Scrollbars */
::-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;
}

/* ==========================================================================
   LAYOUT: SIDEBAR + MAIN WRAPPER
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  transition: transform 0.25s ease-in-out, width 0.25s ease-in-out;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.sidebar-brand img {
  height: 28px;
  max-width: 140px;
  object-fit: contain;
}

.sidebar-brand-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
}

.sidebar-nav {
  padding: 0.75rem 0.6rem;
  flex: 1;
  overflow-y: auto;
}

.nav-category {
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #475569;
  padding: 0.75rem 0.75rem 0.35rem 0.75rem;
  margin-top: 0.25rem;
}

.nav-link-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  color: var(--sidebar-text);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.835rem;
  transition: var(--transition);
  margin-bottom: 2px;
}

.nav-link-item i {
  font-size: 0.95rem;
  width: 18px;
  text-align: center;
  color: #64748b;
  transition: var(--transition);
}

.nav-link-item:hover {
  background: var(--sidebar-hover);
  color: #f1f5f9;
}

.nav-link-item:hover i {
  color: var(--primary-light);
}

.nav-link-item.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.nav-link-item.active i {
  color: #ffffff;
}

.nav-link-item .badge {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 0.2em 0.55em;
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease-in-out;
}

/* ==========================================================================
   TOP NAVBAR
   ========================================================================== */

.app-navbar {
  height: var(--navbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.navbar-left, .navbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-sidebar-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-sub);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-sidebar-toggle:hover {
  background: var(--secondary-light);
  color: var(--text-main);
}

.page-breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.page-breadcrumb .current {
  color: var(--text-main);
  font-weight: 600;
}

/* User Menu Dropdown */
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  transition: var(--transition);
}

.user-menu-btn:hover {
  background: var(--secondary-light);
  border-color: var(--border-color);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--primary);
  border: 1px solid var(--border-color);
  object-fit: cover;
}

.user-info {
  text-align: left;
  line-height: 1.2;
}

.user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.user-role {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* ==========================================================================
   PAGE CONTENT & COMPACT CRM CARDS
   ========================================================================== */

.page-content {
  padding: 1.25rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin: 0;
}

.page-subtitle {
  font-size: 0.785rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Card Design */
.card-crm {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}

.card-crm:hover {
  box-shadow: var(--shadow-sm);
}

.card-crm-header {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-color-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.card-crm-title {
  font-size: 0.925rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-crm-body {
  padding: 1.15rem;
}

/* Metric / Stat KPI Cards */
.stat-card {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-lg);
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
}

.stat-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  margin-top: 0.2rem;
  letter-spacing: -0.03em;
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.stat-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

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

/* ==========================================================================
   TABLES & COMPACT DATA PRESENTATION
   ========================================================================== */

.table-crm-wrapper {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.table-crm {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
  font-size: 0.835rem;
}

.table-crm thead th {
  background-color: #f8fafc;
  color: #475569;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table-crm tbody td {
  padding: 0.65rem 0.9rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color-light);
  color: var(--text-sub);
}

.table-crm tbody tr:last-child td {
  border-bottom: none;
}

.table-crm tbody tr:hover {
  background-color: #f8fafc;
}

/* Software Table Thumb */
.software-thumb {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--primary);
}

/* Badges */
.badge-subtle {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25em 0.6em;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.badge-subtle-success { background: var(--success-light); color: #065f46; border: 1px solid var(--success-border); }
.badge-subtle-danger  { background: var(--danger-light); color: #991b1b; border: 1px solid var(--danger-border); }
.badge-subtle-warning { background: var(--warning-light); color: #92400e; border: 1px solid var(--warning-border); }
.badge-subtle-primary { background: var(--primary-light); color: #1e40af; border: 1px solid var(--primary-border); }
.badge-subtle-info    { background: var(--info-light); color: #155e75; border: 1px solid var(--info-border); }
.badge-subtle-dark    { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }

/* Status Dot Indicator */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot-active { background-color: var(--success); box-shadow: 0 0 0 2px var(--success-light); }
.status-dot-inactive { background-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-light); }

/* Buttons */
.btn-crm {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.42rem 0.85rem;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-crm-sm {
  padding: 0.28rem 0.6rem;
  font-size: 0.75rem;
}

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

.btn-crm-outline {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-sub);
}
.btn-crm-outline:hover {
  background: var(--secondary-light);
  border-color: #cbd5e1;
  color: var(--text-main);
}

.btn-crm-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-crm-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* ==========================================================================
   FORMS & INPUTS
   ========================================================================== */

.form-label-crm {
  font-size: 0.785rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.35rem;
  display: block;
}

.form-control-crm, .form-select-crm {
  font-size: 0.835rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  color: var(--text-main);
  transition: var(--transition);
  width: 100%;
}

.form-control-crm:focus, .form-select-crm:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Image preview container */
.img-preview-box {
  width: 72px;
  height: 72px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  overflow: hidden;
  position: relative;
}

.img-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ==========================================================================
   AUTH PAGES (LOGIN, REGISTER, FORGOT, RESET)
   ========================================================================== */

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, #1e293b, #0b1329);
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.auth-header {
  padding: 1.75rem 2rem 1.25rem 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color-light);
}

.auth-body {
  padding: 1.75rem 2rem;
}

.auth-footer {
  padding: 1rem 2rem;
  background: #f8fafc;
  border-top: 1px solid var(--border-color-light);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ==========================================================================
   TOAST NOTIFICATION CONTAINER
   ========================================================================== */

.toast-container-custom {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast-custom {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.toast-custom.toast-success { border-left-color: var(--success); }
.toast-custom.toast-danger { border-left-color: var(--danger); }
.toast-custom.toast-warning { border-left-color: var(--warning); }
.toast-custom.toast-info { border-left-color: var(--info); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE DESIGN RULES
   ========================================================================== */

@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .app-sidebar.show {
    transform: translateX(0);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  }
  .app-main {
    margin-left: 0;
  }
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(2px);
    z-index: 1030;
    animation: fadeIn 0.2s ease;
  }
}

@media (max-width: 768px) {
  .page-content {
    padding: 1rem 0.75rem;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }
  .page-header > div:last-child {
    width: 100%;
    display: flex;
    gap: 0.5rem;
  }
  .page-header > div:last-child > * {
    flex: 1;
    justify-content: center;
  }
  .card-crm-body {
    padding: 0.85rem;
  }
  .stat-card {
    padding: 0.85rem 1rem;
  }
  .stat-value {
    font-size: 1.4rem;
  }
  .table-crm thead th, .table-crm tbody td {
    padding: 0.55rem 0.65rem;
    font-size: 0.785rem;
  }
}

@media (max-width: 576px) {
  .app-navbar {
    padding: 0 0.75rem;
  }
  .page-title {
    font-size: 1.1rem;
  }
  .auth-wrapper {
    padding: 0.75rem;
  }
  .auth-header {
    padding: 1.25rem 1rem 0.85rem 1rem;
  }
  .auth-body {
    padding: 1rem;
  }
  .auth-footer {
    padding: 0.75rem 1rem;
  }
  .modal-dialog {
    margin: 0.5rem;
  }
  .modal-body {
    padding: 1rem !important;
  }
  .modal-header, .modal-footer {
    padding: 0.75rem 1rem !important;
  }
  .toast-container-custom {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
  }
  .toast-custom {
    min-width: 100%;
    max-width: 100%;
  }
}
