/**
 * Manage Circles Flow Styles
 * 
 * Stone & Clay theme styling for the Manage Circles modal
 * Requirements: 16.1, 16.2, 16.3, 16.4, 16.5, 17.1, 17.2, 17.3, 18.1, 18.2
 */

/* Modal Overlay */
.manage-circles-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

/* Modal Container */
.manage-circles-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Header */
.manage-circles__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.manage-circles__header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Educational Tip */
.educational-tip {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--accent-subtle);
  border-left: 4px solid var(--accent-primary);
  border-radius: 8px;
  margin-bottom: 20px;
}

.educational-tip__icon {
  font-size: 24px;
  flex-shrink: 0;
}

.educational-tip__content {
  flex: 1;
}

.educational-tip__content h4 {
  margin: 0 0 8px 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.educational-tip__content p {
  margin: 0 0 8px 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.educational-tip__content p:last-child {
  margin-bottom: 0;
}

.educational-tip__details {
  margin-top: 12px;
}

.educational-tip__details summary {
  cursor: pointer;
  color: var(--accent-primary);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.educational-tip__details summary::-webkit-details-marker {
  display: none;
}

.educational-tip__details summary::before {
  content: '▶';
  font-size: 10px;
  transition: transform 0.2s;
}

.educational-tip__details[open] summary::before {
  transform: rotate(90deg);
}

.educational-tip__details summary:hover {
  text-decoration: underline;
}

.educational-tip__expanded {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.educational-tip__expanded p {
  margin: 0 0 12px 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.educational-tip__expanded p:last-child {
  margin-bottom: 0;
}

.educational-tip__expanded strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Search Bar */
.search-bar {
  position: relative;
  margin-bottom: 20px;
}

.search-bar__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-bar__input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.search-bar__input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.search-bar__input::placeholder {
  color: var(--text-tertiary);
}

/* Progress Section */
.progress-section {
  margin-bottom: 20px;
}

.progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.progress-bar {
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-bar__fill {
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.3s ease;
  border-radius: 4px;
}

.progress-percentage {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: right;
}

/* Circle Capacities */
.circle-capacities {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.circle-capacities h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 600;
}

.circle-capacities__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.circle-capacity {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
}

.circle-capacity:not(:last-child) {
  border-bottom: 1px solid var(--border-subtle);
}

.circle-capacity__name {
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.circle-capacity__emoji {
  font-size: 16px;
}

.circle-capacity__count {
  color: var(--text-secondary);
  font-weight: 500;
  margin-right: 8px;
}

.circle-capacity__warning {
  color: var(--status-error);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Contact Grid */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  max-height: 400px;
  overflow-y: auto;
  padding: 4px;
}

.contact-grid-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Contact Card */
.contact-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.contact-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.contact-card__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
}

/* Avatar Colors - Warm Pastel Palette */
.avatar--sage { 
  background: #d1fae5; 
  color: #065f46; 
}

.avatar--sand { 
  background: #fef3c7; 
  color: #92400e; 
}

.avatar--rose { 
  background: #fce7f3; 
  color: #9d174d; 
}

.avatar--stone { 
  background: #e7e5e4; 
  color: #44403c; 
}

.contact-card__name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-card__circle-select {
  width: 100%;
  padding: 8px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s;
}

.contact-card__circle-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.contact-card__circle-select:hover {
  border-color: var(--border-hover);
}

/* AI Suggestion Badge */
.ai-suggestion {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 8px;
  background: var(--accent-subtle);
  border-radius: 4px;
  width: 100%;
  justify-content: center;
}

.ai-suggestion__label {
  color: var(--text-secondary);
}

.ai-suggestion__circle {
  color: var(--accent-primary);
  font-weight: 500;
}

.ai-suggestion__confidence {
  color: var(--text-tertiary);
}

/* Action Buttons */
.manage-circles__actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.btn-secondary,
.btn-primary {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: inherit;
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
  border: 1px solid var(--accent-primary);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.98);
}

/* Mobile Responsive Styles */
/* Requirements: 11.1, 11.2, 11.3, 11.4, 16.4 */
@media (max-width: 767px) {
  .manage-circles-overlay {
    padding: 0;
    align-items: flex-end;
  }
  
  .manage-circles-modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
    padding: 20px;
  }
  
  .manage-circles__header h2 {
    font-size: 20px;
  }
  
  .contact-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    max-height: 350px;
  }
  
  .contact-card {
    padding: 12px;
  }
  
  .contact-card__avatar {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }
  
  .contact-card__name {
    font-size: 13px;
  }
  
  .contact-card__circle-select {
    font-size: 11px;
    padding: 6px;
  }
  
  .manage-circles__actions {
    flex-direction: column;
  }
  
  .btn-secondary,
  .btn-primary {
    width: 100%;
    padding: 14px 24px;
  }
  
  .educational-tip {
    flex-direction: column;
    padding: 12px;
  }
  
  .educational-tip__icon {
    font-size: 20px;
  }
  
  .circle-capacities {
    padding: 12px;
  }
}

/* Tablet Responsive Styles */
@media (min-width: 768px) and (max-width: 1023px) {
  .manage-circles-modal {
    max-width: 700px;
  }
  
  .contact-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* Scrollbar Styling */
.contact-grid::-webkit-scrollbar,
.manage-circles-modal::-webkit-scrollbar {
  width: 8px;
}

.contact-grid::-webkit-scrollbar-track,
.manage-circles-modal::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

.contact-grid::-webkit-scrollbar-thumb,
.manage-circles-modal::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

.contact-grid::-webkit-scrollbar-thumb:hover,
.manage-circles-modal::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

/* Dark Mode Adjustments */
/* Requirements: 17.1, 17.2, 17.3 */
[data-theme="dark"] .manage-circles-overlay {
  background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .contact-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Accessibility */
.btn-close:focus-visible,
.search-bar__input:focus-visible,
.contact-card__circle-select:focus-visible,
.btn-secondary:focus-visible,
.btn-primary:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Animation for modal entrance */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.manage-circles-modal {
  animation: slideUp 0.3s ease-out;
}

/* Loading state for contact grid */
.contact-grid.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Celebration Modal */
.celebration-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn 0.3s ease-out;
}

.celebration-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  max-width: 500px;
  width: 100%;
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: slideUp 0.4s ease-out;
}

.celebration-icon {
  font-size: 64px;
  margin-bottom: 20px;
  animation: bounce 0.6s ease-out;
}

.celebration-modal h2 {
  margin: 0 0 16px 0;
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
}

.celebration-modal p {
  margin: 0 0 12px 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.celebration-modal p:last-of-type {
  margin-bottom: 28px;
}

.celebration-modal .btn-primary {
  padding: 12px 32px;
  font-size: 16px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-10px);
  }
  50% {
    transform: translateY(0);
  }
  75% {
    transform: translateY(-5px);
  }
}

/* Mobile responsive for celebration */
@media (max-width: 767px) {
  .celebration-modal {
    padding: 32px 24px;
  }
  
  .celebration-icon {
    font-size: 48px;
  }
  
  .celebration-modal h2 {
    font-size: 24px;
  }
  
  .celebration-modal p {
    font-size: 14px;
  }
}
