/* ==========================================================================
   MODAL SYSTEM
   Modal components for NANAJUNG Community
   ========================================================================== */

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Modal Container */
.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
}

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

/* Modal Body */
.modal-body {
  padding: var(--space-lg);
  max-height: 60vh;
  overflow-y: auto;
}

/* Modal Footer */
.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

/* ==========================================================================
   CREATE POST MODAL
   ========================================================================== */

/* Author Section */
.create-post-author {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.create-post-author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.create-post-author-info {
  flex: 1;
}

.create-post-author-name {
  font-weight: 600;
  color: var(--text-primary);
}

.create-post-privacy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: var(--space-xs);
  transition: all 0.2s;
}

.create-post-privacy:hover {
  background: var(--bg-tertiary);
}

/* Project Selector */
.project-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  cursor: pointer;
  transition: all 0.2s;
}

.project-selector:hover {
  border-color: var(--theme-primary);
}

.project-selector-icon {
  font-size: 1.2rem;
}

.project-selector-text {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.project-selector-arrow {
  color: var(--text-muted);
}

.project-selector.selected {
  background: var(--theme-primary-light);
  border-color: var(--theme-primary);
}

.project-selector.selected .project-selector-text {
  color: var(--theme-primary-dark);
  font-weight: 500;
}

/* Project Dropdown */
.project-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  margin-top: var(--space-xs);
  z-index: 10;
  display: none;
}

.project-dropdown.open {
  display: block;
}

.project-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  cursor: pointer;
  transition: background 0.2s;
}

.project-dropdown-item:hover {
  background: var(--bg-secondary);
}

.project-dropdown-item.active {
  background: var(--theme-primary-light);
}

/* Text Input Area */
.create-post-textarea {
  width: 100%;
  min-height: 150px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 1.1rem;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.6;
}

.create-post-textarea::placeholder {
  color: var(--text-muted);
}

/* Media Preview */
.media-preview {
  margin-top: var(--space-lg);
  position: relative;
}

.media-preview-grid {
  display: grid;
  gap: var(--space-sm);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.media-preview-grid.single {
  grid-template-columns: 1fr;
}

.media-preview-grid.double {
  grid-template-columns: 1fr 1fr;
}

.media-preview-grid.triple {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.media-preview-grid.triple .media-item:first-child {
  grid-row: span 2;
}

.media-preview-grid.quad {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.media-item {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--bg-secondary);
}

.media-item img,
.media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-item-remove {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.media-item-remove:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

/* Link Preview */
.link-preview {
  margin-top: var(--space-lg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.link-preview-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--bg-secondary);
}

.link-preview-content {
  padding: var(--space-md);
}

.link-preview-domain {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.link-preview-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-remove {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  cursor: pointer;
}

/* Poll Creator */
.poll-creator {
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}

.poll-creator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.poll-creator-title {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.poll-creator-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.poll-option-input {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.poll-option-input input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s;
}

.poll-option-input input:focus {
  outline: none;
  border-color: var(--theme-primary);
}

.poll-option-input input::placeholder {
  color: var(--text-muted);
}

.poll-option-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.poll-option-remove:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.poll-add-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  margin-top: var(--space-sm);
  transition: all 0.2s;
  width: 100%;
}

.poll-add-option:hover {
  border-color: var(--theme-primary);
  color: var(--theme-primary);
}

.poll-settings {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
}

.poll-setting {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.poll-setting select {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
}

/* Action Buttons */
.create-post-media-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.media-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.media-action-btn:hover {
  background: var(--bg-secondary);
}

.media-action-btn.active {
  background: var(--theme-primary-light);
  color: var(--theme-primary);
}

.media-action-btn .icon {
  font-size: 1.1rem;
}

/* Photo Action */
.media-action-btn.photo:hover {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

/* Video Action */
.media-action-btn.video:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Link Action */
.media-action-btn.link:hover {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

/* Poll Action */
.media-action-btn.poll:hover {
  background: rgba(251, 191, 36, 0.1);
  color: #f59e0b;
}

/* Submit Button */
.create-post-submit {
  padding: var(--space-sm) var(--space-xl);
  background: var(--theme-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.create-post-submit:hover {
  background: var(--theme-primary-dark);
}

.create-post-submit:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* File Input Hidden */
.file-input-hidden {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Link Input */
.link-input-container {
  margin-top: var(--space-lg);
  display: flex;
  gap: var(--space-sm);
}

.link-input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all 0.2s;
}

.link-input:focus {
  outline: none;
  border-color: var(--theme-primary);
}

.link-input-submit {
  padding: var(--space-sm) var(--space-md);
  background: var(--theme-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.link-input-submit:hover {
  background: var(--theme-primary-dark);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 600px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  
  .modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  
  .modal-header {
    padding: var(--space-sm) var(--space-md);
  }
  
  .modal-title {
    font-size: 1.1rem;
  }
  
  .modal-body {
    max-height: calc(95vh - 120px);
    padding: var(--space-md);
  }
  
  .modal-footer {
    padding: var(--space-sm) var(--space-md);
    padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
  }
  
  /* Create Post Modal */
  .create-post-author {
    padding: var(--space-sm) 0;
  }
  
  .create-post-author-avatar {
    width: 40px;
    height: 40px;
  }
  
  .create-post-textarea {
    min-height: 100px;
    font-size: 1rem;
  }
  
  .create-post-media-actions {
    justify-content: space-around;
  }
  
  .media-action-btn span:not(.icon) {
    display: none;
  }
  
  .media-action-btn {
    padding: var(--space-sm);
    min-width: 50px;
  }
  
  .media-action-btn .icon {
    font-size: 1.3rem;
  }
  
  /* Project Selector */
  .project-selector {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.85rem;
  }
  
  .project-dropdown {
    font-size: 0.9rem;
  }
  
  /* Link Preview */
  .link-preview-result {
    flex-direction: column;
  }
  
  .link-preview-result img {
    width: 100%;
    height: 120px;
  }
  
  /* Media Preview */
  .media-preview {
    gap: var(--space-xs);
  }
  
  .media-preview-item {
    width: 80px;
    height: 80px;
  }
  
  /* Poll Creator */
  .poll-option-input input {
    font-size: 0.9rem;
    padding: var(--space-sm);
  }
  
  /* Submit Button */
  .modal-footer .btn-submit {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
  }
}

/* Extra small screens */
@media (max-width: 380px) {
  .modal-body {
    padding: var(--space-sm);
  }
  
  .create-post-author-name {
    font-size: 0.9rem;
  }
  
  .create-post-privacy {
    font-size: 0.75rem;
  }
}
