/* Apps Editor Modal - Unified Overlay Styles */
#apps-editor-modal {
  visibility: hidden;
  opacity: 0;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: visibility 0s 0.3s, opacity 0.3s ease, z-index 0s 0.3s;
}

#apps-editor-modal.visible {
  visibility: visible;
  opacity: 1;
  z-index: 1000;
  transition: visibility 0s, opacity 0.3s ease;
}

.apps-editor-content {
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 30px;
  position: relative;
  animation: fadeIn 0.4s ease;
}

.drag-area-container {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 20px !important;
  margin: 30px 0 !important;
  width: 100% !important;
}

.app-zone {
  background: #fff !important;
  padding: 20px !important;
  border-radius: 12px !important;
  border: 2px solid #e5e7eb !important;
  flex: 1 !important;
  min-width: 0 !important;
}

.apps-zone-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mobile-helper-text {
  display: none;
  font-size: 0.85rem;
  color: #667eea;
  text-align: center;
  font-weight: 500;
  padding: 10px;
}

.apps-list,
.allowed-apps {
  border: 2px dashed #c7d2fe;
  background: #f8fafc;
  padding: 15px;
  min-height: 200px;
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
}

.applications-list .col,
.app-list .col {
  padding: 8px;
  margin-bottom: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
}

.applications-list .col:hover,
.app-list .col:hover {
  transform: translateY(-5px) scale(1.02);
  border-color: #667eea;
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.2);
}

.applications-list .myapp-item,
.app-list .myapp-item {
  margin: 0;
  border-radius: 12px;
  transition: all 0.3s ease;
  width: 100%;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  position: relative;
  background: rgb(255, 255, 255);
}

.myapp-item .card-content {
  padding: 12px 20px;
  position: relative;
  z-index: 1;
}

.myapp-item .card-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #091c3a;
  margin-bottom: 6px;
  line-height: 1.2;
}

.myapp-item .card-content p {
  font-size: 0.9rem;
  color: #64748b;
  line-height: 1.4;
  margin-bottom: 8px;
}

@media screen and (max-width: 768px) {
  .applications-list .col,
  .app-list .col {
    padding: 6px;
    margin-bottom: 12px;
  }

  .myapp-item .card-content {
    padding: 10px 15px;
  }

  .myapp-item .card-content h3 {
    font-size: 1rem;
  }

  .myapp-item .card-content p {
    font-size: 0.85rem;
  }
}

.button-group {
  display: flex;
  gap: 15px;
  margin-top: 30px;
  position: sticky;
  bottom: 0;
  background: white;
  padding: 15px 0;
  border-top: 1px solid #e5e7eb;
}

/* Mobile Styles */
@media screen and (max-width: 768px) {
  body.overlay-open {
    position: fixed;
    width: 100%;
    height: 100%;
  }

  #apps-editor-modal {
    padding: 0;
    height: 100%;
    display: flex !important;
    flex-direction: column;
    background: #fff;
  }

  #apps-editor-modal .apps-editor-content {
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: 0 !important;
    margin: 0;
    display: flex;
    flex-direction: column;
    box-shadow: none;
  }

  #apps-editor-modal .apps-editor-content h2 {
    position: sticky;
    top: 0;
    background: white;
    margin: 0;
    padding: 15px;
    z-index: 10;
    font-size: 1.3rem;
    border-bottom: 1px solid #e5e7eb;
  }

  #apps-editor-modal .apps-editor-content > p {
    padding: 15px;
    margin: 0;
    font-size: 0.9rem;
  }

  #apps-editor-modal .drag-area-container {
    grid-template-columns: 1fr !important;
    flex: 1;
    overflow-y: auto;
    margin: 0;
    padding: 15px;
    padding-bottom: 100px;
  }

  #apps-editor-modal .app-zone {
    margin-bottom: 20px;
    padding: 15px;
  }

  #apps-editor-modal .app-zone h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
  }

  #apps-editor-modal .mobile-helper-text {
    display: block;
  }

  #apps-editor-modal .apps-list,
  #apps-editor-modal .allowed-apps {
    min-height: 150px;
    padding: 12px;
  }

  #apps-editor-modal .button-group {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 12px;
    background: white;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    margin: 0;
    z-index: 100;
    display: flex;
    gap: 10px;
  }

  #apps-editor-modal .button-group .save-btn {
    margin: 0;
    padding: 14px 28px !important;
    height: 48px;
    font-size: 0.95rem;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    white-space: nowrap;
    flex: 1;
  }

  #apps-editor-modal .button-group .btn.red {
    margin: 0;
    padding: 10px 20px !important;
    height: 40px;
    font-size: 0.9rem;
    border-radius: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    white-space: nowrap;
  }

  /* Adjust scrollbar for better mobile experience */
  #apps-editor-modal .drag-area-container::-webkit-scrollbar {
    width: 4px;
  }

  #apps-editor-modal .drag-area-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
  }

  /* Optimize touch targets */
  #apps-editor-modal .app-item {
    padding: 10px 15px;
    margin: 4px;
    font-size: 0.9rem;
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   SCOPE SELECTOR MODAL STYLES
   ============================================ */

#scope-selector-modal {
  visibility: hidden;
  opacity: 0;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: visibility 0s 0.3s, opacity 0.3s ease, z-index 0s 0.3s;
}

#scope-selector-modal.visible {
  visibility: visible;
  opacity: 1;
  z-index: 1100;
  transition: visibility 0s, opacity 0.3s ease;
}

.scope-selector-content {
  max-width: 500px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
  padding: 0;
  position: relative;
  animation: fadeIn 0.3s ease;
}

.scope-selector-header {
  background: linear-gradient(135deg, #091c3a 0%, #1a3a5c 100%);
  color: white;
  padding: 24px;
  border-radius: 16px 16px 0 0;
}

.scope-selector-header h3 {
  margin: 0 0 8px 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.scope-selector-header p {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.85;
}

.scope-selector-body {
  padding: 24px;
}

.scope-selector-body h4 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #091c3a;
}

.scope-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 8px;
}

.scope-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scope-checkbox-item:hover:not(.checked) {
  border-color: #94a3b8;
  background: #f1f5f9;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.scope-checkbox-item.checked {
  border-color: #667eea;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.scope-checkbox-item.checked .scope-name {
  color: white;
}

.scope-checkbox-item.checked .scope-description {
  color: rgba(255, 255, 255, 0.85);
}

.scope-checkbox-item.checked input[type="checkbox"] {
  accent-color: white;
}

.scope-checkbox-item.checked:hover {
  background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.scope-checkbox-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  cursor: pointer;
  accent-color: #667eea;
  flex-shrink: 0;
}

.scope-checkbox-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.scope-checkbox-label .scope-name {
  font-weight: 600;
  color: #091c3a;
  font-size: 0.95rem;
}

.scope-checkbox-label .scope-description {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.4;
}

.scope-hint {
  margin-top: 16px;
  font-size: 0.85rem;
  color: #64748b;
  font-style: italic;
}

.scope-selector-actions {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 0 0 16px 16px;
  flex-wrap: wrap;
}

.scope-selector-actions .save-btn,
.scope-selector-actions .btn {
  flex: 1;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.scope-selector-actions .remove-access-btn {
  flex-basis: 100%;
  margin-top: 8px;
}

/* Scope badges on app items */
.app-item .scope-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.app-item .scope-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  background: rgba(102, 126, 234, 0.15);
  color: #667eea;
  border-radius: 12px;
  font-weight: 500;
}

.app-item:hover .scope-badge {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

/* No scopes message */
.no-scopes-message {
  text-align: center;
  padding: 30px 20px;
  color: #64748b;
}

.no-scopes-message i {
  font-size: 48px;
  color: #c7d2fe;
  margin-bottom: 12px;
}

.no-scopes-message p {
  margin: 0;
  font-size: 0.95rem;
}

/* Mobile Styles for Scope Selector */
@media screen and (max-width: 768px) {
  #scope-selector-modal {
    padding: 0;
    align-items: flex-end;
  }

  .scope-selector-content {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    animation: slideUp 0.3s ease;
  }

  .scope-selector-header {
    padding: 20px;
    border-radius: 20px 20px 0 0;
  }

  .scope-selector-header h3 {
    font-size: 1.2rem;
  }

  .scope-selector-body {
    padding: 20px;
  }

  .scope-checkboxes {
    max-height: 40vh;
  }

  .scope-checkbox-item {
    padding: 12px 14px;
  }

  .scope-selector-actions {
    padding: 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .scope-selector-actions .save-btn,
  .scope-selector-actions .btn {
    padding: 14px 20px !important;
    font-size: 0.9rem;
  }
}

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

/* Override interface-styles.css media query to maintain 2-column layout */
@media screen and (max-width: 992px) {
  #apps-editor-modal .drag-area-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}
