/* ==========================================================================
   CodeTec KeyGenerator Modern Design System
   Modern SaaS Theme (Option 1)
   ========================================================================== */

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

:root,
[data-bs-theme="light"] {
  --app-font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Color Palette */
  --app-bg: #f8fafc;
  --app-surface: #ffffff;
  
  /* Sidebar Tokens (Light Theme Default) */
  --app-sidebar-bg: #ffffff;
  --app-sidebar-surface: #f8fafc;
  --app-sidebar-text: #475569;
  --app-sidebar-text-hover: #0f172a;
  --app-sidebar-hover-bg: #f1f5f9;
  --app-sidebar-active-bg: #4f46e5;
  --app-sidebar-active-text: #ffffff;
  --app-sidebar-border: #e2e8f0;
  --app-sidebar-header-border: #f1f5f9;
  --app-sidebar-footer-bg: #f8fafc;
  --app-sidebar-footer-border: #e2e8f0;
  --app-sidebar-brand-title: #0f172a;
  --app-sidebar-brand-subtitle: #64748b;
  --app-sidebar-section-title: #94a3b8;
  --app-sidebar-user-name: #0f172a;
  --app-sidebar-user-role: #64748b;
  --app-sidebar-avatar-bg: #e0e7ff;
  --app-sidebar-avatar-color: #4338ca;
  --app-sidebar-avatar-border: #c7d2fe;
  --app-sidebar-scrollbar-thumb: #cbd5e1;
  --app-sidebar-width: 260px;
  
  /* Brand Tokens */
  --app-primary: #4f46e5;
  --app-primary-hover: #4338ca;
  --app-primary-light: #eef2ff;
  --app-primary-border: #c7d2fe;
  
  /* UI Borders & Text */
  --app-border: #e2e8f0;
  --app-border-subtle: #f1f5f9;
  --app-text-main: #0f172a;
  --app-text-muted: #64748b;
  
  /* Radius & Shadows */
  --app-radius-sm: 6px;
  --app-radius-md: 10px;
  --app-radius-lg: 14px;
  --app-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --app-shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.07);
  --app-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.07);
  --app-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   Base & Typography
   ========================================================================== */
html {
  font-size: 15px;
  height: 100%;
}

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

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  font-weight: 700;
  color: var(--app-text-main);
  letter-spacing: -0.02em;
}

a {
  color: var(--app-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

/* ==========================================================================
   Layout Shell: Sidebar + Content
   ========================================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar Backdrop for Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 1030;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Left Sidebar */
.app-sidebar {
  width: var(--app-sidebar-width);
  background-color: var(--app-sidebar-bg);
  border-right: 1px solid var(--app-sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1035;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s ease, border-color 0.2s ease;
}

.app-sidebar::-webkit-scrollbar {
  width: 5px;
}
.app-sidebar::-webkit-scrollbar-thumb {
  background: var(--app-sidebar-scrollbar-thumb);
  border-radius: 4px;
}

/* Sidebar Brand */
.sidebar-header {
  padding: 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--app-sidebar-header-border);
  transition: border-color 0.2s ease;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.15rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
}

.brand-title-group {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--app-sidebar-brand-title);
  letter-spacing: -0.01em;
  line-height: 1.2;
  transition: color 0.2s ease;
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--app-sidebar-brand-subtitle);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color 0.2s ease;
}

.sidebar-close-btn {
  color: var(--app-sidebar-text);
  transition: color 0.15s ease;
}

.sidebar-close-btn:hover {
  color: var(--app-sidebar-text-hover);
}

/* Sidebar Navigation Items */
.sidebar-nav {
  padding: 1.25rem 0.85rem;
  flex-grow: 1;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--app-sidebar-section-title);
  padding: 0.75rem 0.75rem 0.35rem 0.75rem;
  transition: color 0.2s ease;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem 0;
}

.sidebar-menu-item {
  margin-bottom: 2px;
}

.sidebar-menu-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  color: var(--app-sidebar-text);
  font-weight: 500;
  font-size: 0.88rem;
  border-radius: var(--app-radius-md);
  text-decoration: none;
  transition: all 0.15s ease;
}

.sidebar-menu-link i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  transition: color 0.15s ease;
}

.sidebar-menu-link:hover {
  color: var(--app-sidebar-text-hover);
  background-color: var(--app-sidebar-hover-bg);
}

.sidebar-menu-link:hover i {
  color: var(--app-primary);
}

.sidebar-menu-link.active {
  background-color: var(--app-sidebar-active-bg);
  color: var(--app-sidebar-active-text);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.sidebar-menu-link.active i {
  color: #ffffff;
}

/* Sidebar Footer (User info & Logout) */
.sidebar-footer {
  padding: 1rem 0.85rem;
  border-top: 1px solid var(--app-sidebar-footer-border);
  background: var(--app-sidebar-footer-bg);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  border-radius: var(--app-radius-md);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.user-avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--app-sidebar-avatar-bg);
  color: var(--app-sidebar-avatar-color);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--app-sidebar-avatar-border);
  transition: all 0.2s ease;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  color: var(--app-sidebar-user-name);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.user-role {
  color: var(--app-sidebar-user-role);
  font-size: 0.68rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.sidebar-logout-link {
  color: var(--app-sidebar-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--app-radius-sm);
  transition: color 0.15s ease;
}

.sidebar-logout-link:hover {
  color: #ef4444;
}

/* Main Content Wrapper */
.app-content-wrapper {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Modern Topbar */
.app-topbar {
  height: 64px;
  background-color: var(--app-surface);
  border-bottom: 1px solid var(--app-border);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: var(--app-shadow-xs);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle-btn {
  background: transparent;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-sm);
  padding: 0.35rem 0.55rem;
  color: var(--app-text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
}

/* Main Content Area */
.app-main-content {
  flex-grow: 1;
}

/* Footer */
.app-footer {
  background-color: var(--app-surface);
  border-top: 1px solid var(--app-border);
}

/* ==========================================================================
   Responsive Sidebar Behavior
   ========================================================================== */
@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--app-shadow-lg);
  }

  .app-sidebar.show {
    transform: translateX(0);
  }

  .app-topbar {
    padding: 0 1rem;
  }
}

/* ==========================================================================
   Bootstrap Component Modernization & Overrides
   ========================================================================== */

/* Modern Cards */
.card {
  border: 1px solid var(--app-border) !important;
  border-radius: var(--app-radius-lg) !important;
  box-shadow: var(--app-shadow-sm) !important;
  background-color: var(--app-surface) !important;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card-header {
  background-color: var(--app-surface) !important;
  border-bottom: 1px solid var(--app-border) !important;
  font-weight: 600;
  color: var(--app-text-main);
  padding: 1rem 1.25rem !important;
  border-top-left-radius: var(--app-radius-lg) !important;
  border-top-right-radius: var(--app-radius-lg) !important;
}

/* Elevated hover for quick action cards */
.card-hover:hover {
  box-shadow: var(--app-shadow-md) !important;
  transform: translateY(-1px);
}

/* Modern Tables */
.table {
  color: var(--app-text-main);
  margin-bottom: 0;
}

.table thead th {
  background-color: #f8fafc !important;
  color: #475569 !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  border-top: none !important;
  border-bottom: 1px solid var(--app-border) !important;
  padding: 0.85rem 1.15rem !important;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.85rem 1.15rem !important;
  vertical-align: middle !important;
  border-bottom: 1px solid var(--app-border-subtle) !important;
  font-size: 0.9rem;
}

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

/* Buttons */
.btn {
  font-family: var(--app-font-family);
  font-weight: 600;
  border-radius: var(--app-radius-md);
  padding: 0.45rem 0.95rem;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-primary {
  background-color: var(--app-primary) !important;
  border-color: var(--app-primary) !important;
  color: #ffffff !important;
  box-shadow: var(--app-shadow-xs);
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--app-primary-hover) !important;
  border-color: var(--app-primary-hover) !important;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.28) !important;
}

.btn-outline-primary {
  color: var(--app-primary) !important;
  border-color: var(--app-primary-border) !important;
  background-color: transparent;
}

.btn-outline-primary:hover {
  background-color: var(--app-primary) !important;
  border-color: var(--app-primary) !important;
  color: #ffffff !important;
}

.btn-dark {
  background-color: #0f172a !important;
  border-color: #0f172a !important;
}

.btn-dark:hover {
  background-color: #1e293b !important;
  border-color: #1e293b !important;
}

/* Form Controls */
.form-control, .form-select {
  border-radius: var(--app-radius-md);
  border: 1px solid var(--app-border);
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  color: var(--app-text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  outline: none;
}

/* Badges */
.badge {
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: var(--app-radius-sm);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* Modern Auth Page Layout */
.auth-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 50% 20%, #eef2ff 0%, #f8fafc 60%, #ffffff 100%);
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-lg);
  box-shadow: var(--app-shadow-lg);
  padding: 2.25rem;
}

/* ==========================================================================
   Dark Theme (data-bs-theme="dark")
   ========================================================================== */
[data-bs-theme="dark"] {
  --app-bg: #090d16;
  --app-surface: #111827;
  
  --app-sidebar-bg: #0b0f19;
  --app-sidebar-surface: #131b2e;
  --app-sidebar-text: #94a3b8;
  --app-sidebar-text-hover: #ffffff;
  --app-sidebar-hover-bg: rgba(255, 255, 255, 0.06);
  --app-sidebar-active-bg: #4f46e5;
  --app-sidebar-active-text: #ffffff;
  --app-sidebar-border: #1e293b;
  --app-sidebar-header-border: #1e293b;
  --app-sidebar-footer-bg: rgba(0, 0, 0, 0.25);
  --app-sidebar-footer-border: #1e293b;
  --app-sidebar-brand-title: #f8fafc;
  --app-sidebar-brand-subtitle: #94a3b8;
  --app-sidebar-section-title: #64748b;
  --app-sidebar-user-name: #f8fafc;
  --app-sidebar-user-role: #94a3b8;
  --app-sidebar-avatar-bg: #1e293b;
  --app-sidebar-avatar-color: #cbd5e1;
  --app-sidebar-avatar-border: #334155;
  --app-sidebar-scrollbar-thumb: #334155;
  
  --app-border: #1f2937;
  --app-border-subtle: #192231;
  --app-text-main: #f8fafc;
  --app-text-muted: #94a3b8;
  
  --app-shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --app-shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px -1px rgba(0, 0, 0, 0.4);
  --app-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --app-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .table thead th {
  background-color: #131b2e !important;
  color: #cbd5e1 !important;
  border-bottom: 1px solid var(--app-border) !important;
}

[data-bs-theme="dark"] .table tbody td {
  color: #f1f5f9 !important;
  border-bottom: 1px solid var(--app-border) !important;
}

[data-bs-theme="dark"] .table-hover tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.04) !important;
}

[data-bs-theme="dark"] .dropdown-menu {
  background-color: #111827 !important;
  border: 1px solid #1f2937 !important;
}

[data-bs-theme="dark"] .dropdown-item {
  color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .dropdown-item:hover {
  background-color: #1e293b !important;
  color: #ffffff !important;
}

[data-bs-theme="dark"] .dropdown-divider {
  border-color: #1f2937 !important;
}

[data-bs-theme="dark"] .form-control, 
[data-bs-theme="dark"] .form-select {
  background-color: #111827 !important;
  color: #f8fafc !important;
  border-color: #1f2937 !important;
}

[data-bs-theme="dark"] .form-control:focus, 
[data-bs-theme="dark"] .form-select:focus {
  background-color: #111827 !important;
  color: #f8fafc !important;
  border-color: #6366f1 !important;
}

[data-bs-theme="dark"] .bg-light {
  background-color: #131b2e !important;
}

[data-bs-theme="dark"] .bg-white {
  background-color: #111827 !important;
}

[data-bs-theme="dark"] .auth-layout {
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #090d16 60%, #030712 100%) !important;
}

[data-bs-theme="dark"] .auth-card {
  background-color: #111827 !important;
  border-color: #1f2937 !important;
}

/* ==========================================================================
   Compact Tables & Leading Kebab Action Menus
   ========================================================================== */
.table-compact th,
.table-compact td {
  padding: 0.45rem 0.7rem !important;
  font-size: 0.86rem;
  vertical-align: middle;
}

.table-compact thead th {
  padding: 0.55rem 0.7rem !important;
  font-size: 0.72rem !important;
}

.table-action-col {
  width: 44px;
  min-width: 44px;
  text-align: center;
  padding-left: 0.35rem !important;
  padding-right: 0.35rem !important;
}

.btn-kebab {
  width: 28px;
  height: 28px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--app-radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--app-text-muted);
  transition: all 0.15s ease;
}

.btn-kebab:hover,
.btn-kebab:focus,
.show > .btn-kebab {
  background: var(--app-border-subtle);
  border-color: var(--app-border);
  color: var(--app-text-main);
}

[data-bs-theme="dark"] .btn-kebab:hover,
[data-bs-theme="dark"] .btn-kebab:focus,
[data-bs-theme="dark"] .show > .btn-kebab {
  background: #1e293b;
  border-color: #334155;
  color: #ffffff;
}

/* Topbar theme toggle button */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--app-radius-md);
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  color: var(--app-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-toggle-btn:hover {
  color: var(--app-primary);
  border-color: var(--app-primary);
  background: var(--app-primary-light);
}

[data-bs-theme="dark"] .theme-toggle-btn:hover {
  background: #1e1b4b;
  color: #818cf8;
  border-color: #4f46e5;
}

/* ==========================================================================
   Mobile Friendliness & Responsive System
   ========================================================================== */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    width: 280px;
    max-width: 85vw;
  }
}

@media (max-width: 767.98px) {
  /* Prevent iOS Safari 16px threshold auto-zoom on focused form inputs */
  .form-control,
  .form-select,
  .form-control:focus,
  .form-select:focus {
    font-size: 16px !important;
    min-height: 42px;
  }

  /* Touch-friendly button sizes */
  .btn {
    min-height: 38px;
  }

  .btn-sm {
    min-height: 32px;
  }

  /* Sticky first column for tables on mobile screens */
  .table thead th.table-action-col,
  .table tbody td.table-action-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: var(--app-surface) !important;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.05);
  }

  .table thead th.table-action-col {
    background-color: #f8fafc !important;
  }

  [data-bs-theme="dark"] .table thead th.table-action-col {
    background-color: #131b2e !important;
  }

  [data-bs-theme="dark"] .table tbody td.table-action-col {
    background-color: #111827 !important;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.4);
  }

  /* Comfortable tap targets for kebab action menus */
  .btn-kebab {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.15rem;
  }

  .table-action-col {
    width: 48px !important;
    min-width: 48px !important;
  }

  /* Mobile Topbar compact adjustments */
  .app-topbar {
    height: 56px;
    padding: 0 0.85rem;
  }

  .topbar-breadcrumb {
    font-size: 0.8rem;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Responsive typography scale on mobile */
  h1, .h1 { font-size: 1.45rem !important; }
  h2, .h2 { font-size: 1.25rem !important; }
  h3, .h3 { font-size: 1.15rem !important; }

  /* Card padding reduction to conserve screen real estate */
  .card-body {
    padding: 0.95rem !important;
  }

  /* Modal responsiveness on mobile screens */
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }

  /* Pagination touch friendliness */
  .pagination .page-link {
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.65rem;
  }
}