/* ==========================================================================
   MISA AMIS Ecosystem - Modern Enterprise Dashboard Styles
   ========================================================================== */

:root {
  --primary: #0073e6;
  --primary-hover: #005bb5;
  --primary-active: #00438a;
  --primary-light: #e8f3ff;
  --primary-border: #bfdbfe;
  
  --secondary: #00b074;
  --secondary-light: #e6f9f3;
  --accent-orange: #ff8c00;
  --accent-purple: #7c3aed;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  
  --bg-main: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;
  --bg-active: #f1f5f9;
  
  --text-main: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-light: #e2e8f0;
  --border-focus: #3b82f6;
  
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.07), 0 2px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 14px 28px -4px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 12px 24px -4px rgba(0, 115, 230, 0.12), 0 4px 8px -2px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #1e293b;
  --bg-hover: #293548;
  --bg-active: #334155;
  
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  --border-light: #334155;
  --primary-light: rgba(0, 115, 230, 0.2);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 12px 24px rgba(0, 115, 230, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Offline Banner */
.offline-banner {
  display: none;
  background: #f59e0b;
  color: #ffffff;
  padding: 8px 16px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 1000;
}
.offline-banner.visible {
  display: block;
}

/* Header */
.app-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(8px);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  gap: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  padding: 6px 10px;
  margin: -6px -10px;
  border-radius: var(--radius-lg);
  transition: var(--transition);
  position: relative;
  user-select: none;
}

.header-brand:hover {
  background: var(--bg-hover);
}

.header-brand:focus-visible {
  outline: 2px solid var(--primary);
}

.brand-edit-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  opacity: 0;
  transform: scale(0.85);
  transition: var(--transition);
  margin-left: 2px;
}

.header-brand:hover .brand-edit-hint {
  opacity: 1;
  transform: scale(1);
}

.brand-preview-card {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.header-brand.preview-mode {
  padding: 0;
  margin: 0;
  pointer-events: none;
}
.header-brand.preview-mode:hover {
  background: transparent;
}

.brand-logo-wrap {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0073e6 0%, #004bb5 100%);
  box-shadow: 0 4px 10px rgba(0, 115, 230, 0.35);
  flex-shrink: 0;
  overflow: hidden;
}

.brand-logo-wrap img,
.brand-logo-wrap svg {
  width: 32px;
  height: 32px;
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.brand-workspace {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Header Search */
.header-search-wrap {
  flex: 1;
  max-width: 520px;
  position: relative;
}

.search-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  transition: var(--transition);
  position: relative;
}

.search-input-box:focus-within {
  background: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 115, 230, 0.15);
}

.search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  margin-right: 10px;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.9375rem;
  color: var(--text-main);
  font-family: inherit;
}

.search-input::placeholder {
  color: var(--text-light);
}

.search-shortcut {
  font-size: 0.72rem;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-weight: 600;
  letter-spacing: 0.3px;
  pointer-events: none;
  white-space: nowrap;
}

.search-clear-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  margin-left: 6px;
}
.search-clear-btn.visible {
  display: flex;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  user-select: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 115, 230, 0.2);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(0, 115, 230, 0.3);
}

.btn-outline {
  background: var(--bg-surface);
  border-color: var(--border-light);
  color: var(--text-secondary);
}
.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--text-muted);
}

.btn-outline.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-icon-only {
  padding: 8px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

.btn-icon-only:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.btn-install {
  background: linear-gradient(135deg, #00b074 0%, #00875a 100%);
  color: #ffffff;
  display: none; /* Shown dynamically via PWA trigger */
}
.btn-install:hover {
  opacity: 0.92;
}

/* Dropdown Menu */
.dropdown-wrap {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 200;
  animation: fadeInDown 0.15s ease-out;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

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

.dropdown-item.danger {
  color: var(--danger);
}
.dropdown-item.danger:hover {
  background: var(--danger-light);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 6px 0;
}

/* Main Container */
.main-content {
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 60px;
}

/* Category & Controls Bar */
.ecosystem-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.category-pills-list {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.category-pills-list::-webkit-scrollbar {
  display: none;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

.category-pill:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: #cbd5e1;
}

.category-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 115, 230, 0.25);
  font-weight: 600;
}

.category-count {
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.category-pill.active .category-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-mode-group {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 2px;
}

.view-btn {
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* Drag Reorder Notice Banner */
.reorder-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}
.reorder-banner.active {
  display: flex;
}

/* App Grid Container */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  transition: all 0.3s ease;
}

/* Card Mode (Default) */
.app-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: #cbd5e1;
}

.app-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.app-icon-wrap {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.app-card:hover .app-icon-wrap {
  transform: scale(1.05);
}

.app-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.app-icon-svg {
  width: 32px;
  height: 32px;
}

.app-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.app-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.app-badge-new {
  background: #dcfce7;
  color: #15803d;
}

.app-badge-hot {
  background: #fee2e2;
  color: #b91c1c;
}

.app-badge-local {
  background: #e0f2fe;
  color: #0369a1;
}

.app-drag-handle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  cursor: grab;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  opacity: 0.4;
}

.app-card:hover .app-drag-handle,
.reorder-mode .app-drag-handle {
  opacity: 1;
  color: var(--text-secondary);
}

.app-drag-handle:active {
  cursor: grabbing;
}

.app-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.app-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.app-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
  line-height: 1.3;
}

.app-category-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
  display: inline-block;
}

.app-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 14px;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
  margin-top: auto;
}

.app-launch-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-light);
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-btn-action {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.app-btn-action:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.app-btn-action.starred {
  color: #f59e0b;
}

.app-btn-action.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Dragging Animations & Visuals */
.app-card.dragging {
  opacity: 0.45;
  transform: scale(1.02) rotate(1.5deg);
  border: 2px dashed var(--primary);
  box-shadow: var(--shadow-lg);
  cursor: grabbing !important;
}

.app-card.drag-over {
  border: 2px solid var(--primary);
  transform: scale(1.03);
  box-shadow: 0 0 18px rgba(0, 115, 230, 0.3);
}

/* Compact Launcher View Mode (Launchpad Style) */
.apps-grid.view-compact {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 20px;
}

.apps-grid.view-compact .app-card {
  padding: 16px 10px;
  align-items: center;
  text-align: center;
}

.apps-grid.view-compact .app-card-header {
  flex-direction: column;
  align-items: center;
  margin-bottom: 8px;
}

.apps-grid.view-compact .app-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 20px;
}

.apps-grid.view-compact .app-card-badges,
.apps-grid.view-compact .app-category-tag,
.apps-grid.view-compact .app-desc,
.apps-grid.view-compact .app-footer {
  display: none;
}

.apps-grid.view-compact .app-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
}

/* List View Mode (Equal Column Widths & Perfectly Aligned Text) */
.apps-grid.view-list {
  grid-template-columns: 1fr;
  gap: 10px;
}

.apps-grid.view-list .app-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 12px 20px;
  gap: 16px;
}

.apps-grid.view-list .app-card-header {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  width: 175px; /* Cố định độ rộng để cột tên web luôn thẳng hàng */
}

.apps-grid.view-list .app-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
}

.apps-grid.view-list .app-icon-svg {
  width: 24px;
  height: 24px;
}

.apps-grid.view-list .app-card-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.app-badge-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.apps-grid.view-list .app-badge-slot {
  width: 82px; /* Độ rộng cố định cho khung huy hiệu */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.apps-grid.view-list .app-badge {
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 3px 6px;
  font-size: 0.6875rem;
}

.apps-grid.view-list .app-drag-handle {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.apps-grid.view-list .app-info {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex: 1;
  gap: 24px;
  min-width: 0;
}

.apps-grid.view-list .app-title-row {
  margin-bottom: 0;
  flex: 1;
  min-width: 220px;
}

.apps-grid.view-list .app-title {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.apps-grid.view-list .app-category-tag {
  margin-bottom: 0;
  width: 180px; /* Cố định độ rộng cột phân hệ danh mục */
  flex-shrink: 0;
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.apps-grid.view-list .app-desc {
  display: none;
}

.apps-grid.view-list .app-footer {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
  gap: 16px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

.apps-grid.view-list .app-launch-meta {
  width: 105px;
  flex-shrink: 0;
  font-size: 0.75rem;
}

.apps-grid.view-list .app-actions {
  flex-shrink: 0;
}

/* Empty State */
.empty-state {
  display: none;
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-xl);
  max-width: 500px;
  margin: 40px auto;
}
.empty-state.visible {
  display: block;
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.empty-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ==========================================================================
   Modals (Add / Edit App, Backup/Restore, Icon Picker)
   ========================================================================== */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.modal-backdrop.active {
  display: flex;
}

.modal-container {
  background: var(--bg-surface);
  width: 100%;
  max-width: 640px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-title {
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
}
.modal-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-hover);
}

/* Live Preview Card in Modal */
.modal-preview-box {
  background: var(--bg-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.preview-badge-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.preview-icon-wrap {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  flex-shrink: 0;
}

.preview-text {
  flex: 1;
}
.preview-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}
.preview-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: normal;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  background: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 115, 230, 0.15);
}

.input-with-action {
  display: flex;
  gap: 8px;
}

.input-action-btn {
  padding: 8px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}
.input-action-btn:hover {
  background: var(--primary);
  color: #ffffff;
}

/* Icon Customizer Tabs */
.icon-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
  margin-bottom: 14px;
}

.icon-tab-btn,
.brand-tab-btn {
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.icon-tab-btn.active,
.brand-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Preset Icons Grid */
.icon-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-hover);
}

.icon-preset-item {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.icon-preset-item:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.icon-preset-item.selected {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 115, 230, 0.3);
}

.icon-preset-item svg {
  width: 22px;
  height: 22px;
}

/* Color Presets Grid */
.color-swatch-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-xs);
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.selected {
  border-color: #ffffff;
  outline: 2px solid var(--primary);
  transform: scale(1.15);
}

.color-swatch.swatch-transparent {
  background: repeating-conic-gradient(#cbd5e1 0% 25%, #ffffff 0% 50%) 50% / 10px 10px !important;
  border: 1px solid #cbd5e1;
}

.color-swatch.swatch-white {
  background: #ffffff !important;
  border: 1px solid #cbd5e1;
}

/* Border Selector Styles */
.border-swatch-grid {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.border-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.border-swatch:hover {
  transform: scale(1.15);
}

.border-swatch.selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  transform: scale(1.15);
}

.border-swatch-inner {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.border-width-group {
  display: inline-flex;
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.btn-width-pill {
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-width-pill.active {
  background: var(--primary);
  color: #ffffff;
}

/* File Upload Zone */
.file-upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-hover);
  transition: var(--transition);
}

.file-upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-upload-icon {
  width: 36px;
  height: 36px;
  color: var(--primary);
  margin-bottom: 8px;
}

/* In-App Workspace Iframe Viewer */
.inapp-workspace {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: 2000;
  flex-direction: column;
}

.inapp-workspace.active {
  display: flex;
}

.inapp-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  gap: 12px;
}

.inapp-nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inapp-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.inapp-back-btn:hover {
  background: var(--primary);
  color: #ffffff;
}

.inapp-app-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inapp-app-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inapp-app-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
}

.inapp-app-url {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.inapp-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inapp-frame-wrap {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  background: #ffffff;
}

.inapp-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.inapp-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
}

.inapp-blocked-warning {
  display: none;
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  z-index: 20;
  text-align: center;
  max-width: 600px;
}

/* CSP Protection Shield Overlay */
.inapp-csp-shield {
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  z-index: 15;
}

.inapp-csp-icon {
  width: 80px;
  height: 80px;
  border-radius: 24px;
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.2);
}

.inapp-csp-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  max-width: 580px;
}

.inapp-csp-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 560px;
  margin-bottom: 28px;
}

.inapp-csp-desc code {
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  color: #ef4444;
  font-size: 0.875rem;
  border: 1px solid var(--border-light);
}

.inapp-csp-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1e293b;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  animation: toastIn 0.25s ease-out;
  max-width: 380px;
}

.toast.success {
  background: #065f46;
}

.toast.info {
  background: #0369a1;
}

.toast.error {
  background: #991b1b;
}

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

/* Google / Gmail Authentication Styles */
.btn-google-login {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 7px 14px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: var(--transition);
}

.btn-google-login:hover {
  background: var(--bg-hover);
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(66, 133, 244, 0.15);
  transform: translateY(-1px);
}

.btn-user-profile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 4px 10px 4px 5px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-main);
}

.btn-user-profile:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.user-avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--primary);
  flex-shrink: 0;
}

.user-header-text {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.user-header-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-main);
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-header-email {
  font-size: 0.6875rem;
  color: var(--text-muted);
  max-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* User Dropdown */
.user-dropdown-menu {
  width: 270px;
  right: 0;
  left: auto;
}

.user-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.user-dropdown-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  flex-shrink: 0;
}

.user-dropdown-details {
  overflow: hidden;
}

.user-dropdown-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.badge-google-verified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e8f0fe;
  color: #1a73e8;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
}

/* Login Modal */
.login-modal-container {
  max-width: 480px;
}

.login-tab-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.login-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.login-tab-pane {
  display: none;
}

.login-tab-pane.active {
  display: block;
}

/* Saved Accounts List */
.saved-accounts-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.saved-account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-hover);
  transition: var(--transition);
}

.saved-account-card:hover {
  background: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.saved-account-card.active {
  border-color: var(--secondary);
  background: rgba(0, 176, 116, 0.06);
}

.saved-account-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.saved-account-info {
  flex: 1;
  overflow: hidden;
}

.saved-account-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
}

.saved-account-email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.current-badge {
  color: var(--secondary);
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 4px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* Demo account pills */
.demo-account-pill {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: 5px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.demo-account-pill:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 768px) {
  .header-top {
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  
  .header-search-wrap {
    order: 3;
    max-width: 100%;
    width: 100%;
    margin-top: 4px;
  }
  
  .main-content {
    padding: 16px 16px 40px;
  }
  
  .apps-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .brand-workspace {
    display: none;
  }

  .btn-text-hide {
    display: none;
  }
}
