/* General & Utility Styles */
.d-none { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.w-100 { width: 100%; }

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-border-hover);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal-content {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 500px;
  padding: 32px;
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}
.modal-overlay.active .modal-content {
  transform: translateY(0);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-main);
}
.modal-close {
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}
.modal-close:hover {
  color: var(--color-text-main);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  text-decoration: none;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 12px rgba(92, 84, 241, 0.25);
}
.btn-secondary {
  background: var(--color-bg-app);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-border);
  border-color: var(--color-border-hover);
}
.btn-danger {
  background: var(--color-danger);
  color: white;
}
.btn-danger:hover {
  background: var(--color-danger-hover);
}
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}
.btn-icon:hover {
  background: var(--color-border);
  color: var(--color-text-main);
}

/* INPUTS */
.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.form-group label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.form-control {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
  color: var(--color-text-main);
}
.form-control:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(92, 84, 241, 0.15);
}

/* --- LOGIN SCREEN --- */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: #fafafa;
}
.login-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  padding: 48px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
}
.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-bottom: 32px;
  font-weight: 800;
  font-size: 1.5rem;
  color: #000000;
}
.logo-badge {
  background: var(--color-primary);
  color: white;
  padding: 2px 10px;
  border-radius: 8px;
  font-size: 1.3rem;
}
.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--color-text-main);
}
.login-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 32px;
}
.login-error {
  background: #fee2e2;
  color: var(--color-danger);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 20px;
  font-weight: 500;
  border-left: 4px solid var(--color-danger);
}

/* --- DASHBOARD SCREEN --- */
.dashboard-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--color-bg-sidebar);
  border-right: 1px solid var(--color-border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 1.25rem;
  color: #000;
}
.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}
.sidebar-link:hover, .sidebar-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 8px;
  border-top: 1px solid var(--color-border);
  margin-top: 24px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.user-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-main);
}
.user-role {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.btn-logout {
  color: var(--color-text-muted);
  cursor: pointer;
}
.btn-logout:hover {
  color: var(--color-danger);
}

/* MAIN CONTENT */
.main-content {
  padding: 48px;
  overflow-y: auto;
  max-height: 100vh;
}
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}
.dashboard-title h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--color-text-main);
  margin-bottom: 4px;
}
.dashboard-title p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}
.toolbar {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  align-items: center;
}
.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}
.search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  font-size: 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  outline: none;
  transition: all var(--transition-fast);
}
.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(92, 84, 241, 0.1);
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}
.sort-select {
  padding: 10px 16px;
  font-size: 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  outline: none;
  cursor: pointer;
}

/* GRID CARDS */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 32px;
}
.template-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
}
.template-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-border-hover);
}
.template-preview {
  height: 200px;
  background: #051630;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}
.template-preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  transform: scale(0.6);
  transform-origin: center top;
  pointer-events: none;
  margin-top: 10px;
}
.template-preview-placeholder {
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.template-preview-placeholder svg {
  opacity: 0.5;
}
.template-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: opacity var(--transition-fast);
}
.template-preview:hover .template-card-overlay {
  opacity: 1;
}
.template-info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.template-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 24px;
}
.template-date {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.template-actions-btn {
  position: absolute;
  right: 16px;
  top: 18px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
}
.template-actions-btn:hover {
  background: var(--color-bg-app);
  color: var(--color-text-main);
}
.template-actions-menu {
  position: absolute;
  right: 20px;
  top: 45px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  list-style: none;
  z-index: 10;
  width: 140px;
  overflow: hidden;
  display: none;
}
.template-actions-menu.active {
  display: block;
}
.template-action-item {
  padding: 10px 16px;
  font-size: 0.85rem;
  color: var(--color-text-main);
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}
.template-action-item:hover {
  background: var(--color-bg-app);
}
.template-action-item.delete {
  color: var(--color-danger);
}
.template-action-item.delete:hover {
  background: #fee2e2;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-card);
  text-align: center;
}
.empty-state-icon {
  color: var(--color-text-light);
  margin-bottom: 20px;
}
.empty-state-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--color-text-main);
}
.empty-state-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  max-width: 320px;
  margin-bottom: 24px;
}

/* --- TEAMSPACES SECTION --- */
.teamspaces-section {
  margin-top: 24px;
  border-top: 1px solid var(--color-border);
  padding-top: 20px;
}
.teamspaces-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  margin-bottom: 12px;
}
.teamspaces-header span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}
.btn-new-teamspace {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: color var(--transition-fast);
}
.btn-new-teamspace:hover {
  color: var(--color-primary);
}
.teamspace-item {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}
.teamspace-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast);
}
.teamspace-header-row:hover {
  background: var(--color-bg-app);
}
.teamspace-chevron {
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-normal);
  cursor: pointer;
}
.teamspace-item.collapsed .teamspace-chevron {
  transform: rotate(-90deg);
}
.teamspace-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: #1e70e6; /* Blue avatar from print */
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
  text-transform: uppercase;
}
.teamspace-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-main);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.teamspace-actions-btn {
  color: var(--color-text-muted);
  opacity: 0;
  transition: opacity var(--transition-fast);
  padding: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.teamspace-header-row:hover .teamspace-actions-btn {
  opacity: 1;
}
.teamspace-actions-btn:hover {
  background: var(--color-border);
  color: var(--color-text-main);
}
.teamspace-folders {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  padding-left: 20px;
}
.teamspace-item.collapsed .teamspace-folders {
  display: none;
}
.folder-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}
.folder-link:hover {
  background: var(--color-bg-app);
  color: var(--color-text-main);
}
.folder-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}
.folder-actions {
  position: absolute;
  right: 4px;
  display: none;
  gap: 4px;
}
.folder-link:hover .folder-actions {
  display: flex;
}
.btn-folder-action {
  color: var(--color-text-muted);
  padding: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-folder-action:hover {
  background: var(--color-border);
  color: var(--color-text-main);
}
.btn-folder-action.delete:hover {
  color: var(--color-danger);
  background: #fee2e2;
}

/* Teamspace Popover Dropdown */
.teamspace-dropdown-menu {
  position: absolute;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  list-style: none;
  z-index: 1000;
  width: 180px;
  display: none;
}
.teamspace-dropdown-menu.active {
  display: block;
}
.teamspace-dropdown-item {
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--color-text-main);
  cursor: pointer;
  transition: background var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.teamspace-dropdown-item:hover {
  background: var(--color-bg-app);
}
.teamspace-dropdown-item.delete {
  color: var(--color-danger);
}
.teamspace-dropdown-item.delete:hover {
  background: #fee2e2;
}

/* --- ORG SELECTOR TOP BAR --- */
.org-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 24px;
}
.org-selector:hover {
  background: #fafafa;
  border-color: var(--color-border-hover);
}
.org-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1e70e6; /* Vibrant blue like print */
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  text-transform: uppercase;
}
.org-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-main);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- OVERRIDES FOR SIDEBAR LINKS TO MATCH PRINT --- */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #4b5563 !important; /* Muted gray text for inactive items */
  text-decoration: none;
  border-radius: 8px;
  transition: all var(--transition-fast);
}
.sidebar-link i {
  color: #4b5563;
}
.sidebar-link:hover {
  background: #f3f4f6;
  color: #111827 !important;
}
.sidebar-link:hover i {
  color: #111827;
}
.sidebar-link.active {
  background: #f3f4f6 !important; /* Light-gray active background */
  color: #111827 !important; /* Dark active text */
  font-weight: 600 !important;
}
.sidebar-link.active i {
  color: #111827 !important;
}

/* Sidebar structure */
.sidebar {
  justify-content: flex-start !important;
  gap: 20px;
  background: #ffffff !important;
  padding: 24px 16px !important;
}

/* Icons styling for solid folders to match print exactly */
.teamspace-folders svg[data-lucide="layout-grid"],
.teamspace-folders svg[data-lucide="folder"],
.teamspace-folders svg[data-lucide="archive"],
.teamspace-folders svg[data-lucide="folder-plus"] {
  fill: #4b5563;
  stroke: #4b5563;
  stroke-width: 1.5;
}
.folder-link.active svg {
  fill: var(--color-primary) !important;
  stroke: var(--color-primary) !important;
}
/* For Lucide plus sign in folder-plus, keep outline white so it is visible */
.teamspace-folders svg[data-lucide="folder-plus"] line {
  stroke: #ffffff !important;
  stroke-width: 2.5px !important;
}
.teamspace-chevron i {
  color: #4b5563;
}


