/* ============================================
   Modal de Criação de Post — Rede Social
   ============================================ */

/* Backdrop */
.cpm-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  z-index: 10000;
  overflow-y: auto;
  animation: cpmFadeIn 0.2s ease;
}

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

/* Container */
.cpm-container {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  margin: 20px;
  animation: cpmSlideUp 0.25s ease;
}

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

/* Header */
.cpm-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 16px 20px;
  border-bottom: 1px solid #e4e6eb;
}

.cpm-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #050505;
  margin: 0;
}

.cpm-close-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #e4e6eb;
  color: #606770;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.cpm-close-btn:hover {
  background: #d8dadf;
}

/* User Row */
.cpm-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 4px;
}

.cpm-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, #667eea, #764ba2);
}

.cpm-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cpm-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}

.cpm-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cpm-user-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: #050505;
}

.cpm-privacy-select {
  font-size: 0.75rem;
  padding: 2px 6px;
  border: 1px solid #ccd0d5;
  border-radius: 4px;
  background: #e4e6eb;
  color: #65676b;
  cursor: pointer;
  width: fit-content;
}

/* Feeling Badge */
.cpm-feeling-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 16px;
  padding: 6px 12px;
  background: #e7f3ff;
  border-radius: 20px;
  font-size: 0.8125rem;
  color: #1877f2;
  font-weight: 500;
}

.cpm-feeling-remove {
  background: none;
  border: none;
  color: #65676b;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* Textarea */
.cpm-textarea-wrapper {
  padding: 4px 16px 8px;
  position: relative;
}

.cpm-textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: 1.5rem;
  font-family: inherit;
  color: #050505;
  min-height: 100px;
  line-height: 1.4;
  box-sizing: border-box;
  background: transparent;
}

.cpm-textarea::placeholder {
  color: #8a8d91;
}

/* Background style applied to textarea wrapper */
.cpm-textarea-wrapper.cpm-bg-ocean { background: linear-gradient(135deg, #0077b6, #023e8a); }
.cpm-textarea-wrapper.cpm-bg-forest { background: linear-gradient(135deg, #2d6a4f, #1b4332); }
.cpm-textarea-wrapper.cpm-bg-tropical { background: linear-gradient(135deg, #0096c7, #00b4d8); }
.cpm-textarea-wrapper.cpm-bg-coral { background: linear-gradient(135deg, #f77f00, #e63946); }
.cpm-textarea-wrapper.cpm-bg-sand { background: linear-gradient(135deg, #dda15e, #bc6c25); }
.cpm-textarea-wrapper.cpm-bg-night { background: linear-gradient(135deg, #1d3557, #0d1b2a); }
.cpm-textarea-wrapper.cpm-bg-dawn { background: linear-gradient(135deg, #ffd166, #ef476f); }
.cpm-textarea-wrapper.cpm-bg-deep { background: linear-gradient(135deg, #03045e, #0077b6); }

.cpm-textarea-wrapper[class*="cpm-bg-"] .cpm-textarea {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  min-height: 160px;
  display: flex;
  align-items: center;
  transition: font-size 0.15s ease, font-weight 0.15s ease;
}

.cpm-textarea-wrapper[class*="cpm-bg-"] .cpm-textarea::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.cpm-textarea-wrapper[class*="cpm-bg-"] .cpm-char-count {
  color: rgba(255, 255, 255, 0.6);
}

.cpm-char-count {
  text-align: right;
  font-size: 0.75rem;
  color: #8a8d91;
  padding-top: 4px;
}

/* Background Selector */
.cpm-bg-selector {
  display: flex;
  gap: 6px;
  padding: 4px 16px 8px;
  flex-wrap: wrap;
}

.cpm-bg-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.cpm-bg-none {
  background: #e4e6eb;
  position: relative;
}

.cpm-bg-none::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  height: 2px;
  background: #65676b;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.cpm-bg-option:hover {
  transform: scale(1.15);
}

.cpm-bg-option.cpm-bg-active {
  border-color: #1877f2;
  box-shadow: 0 0 0 2px rgba(24, 119, 242, 0.3);
}

/* Media Preview */
.cpm-media-preview {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
}

.cpm-media-thumb {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid #e4e6eb;
}

.cpm-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cpm-media-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Panels */
.cpm-panel {
  border-top: 1px solid #e4e6eb;
  padding: 12px 16px;
  overflow: visible;
}

.cpm-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 0.875rem;
  color: #050505;
}

.cpm-panel-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #65676b;
  cursor: pointer;
}

.cpm-panel-divider {
  height: 1px;
  background: #e4e6eb;
  margin: 12px 0;
}

/* Feeling/Activity Grid */
.cpm-feeling-grid,
.cpm-activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
}

.cpm-feeling-item,
.cpm-activity-item {
  padding: 8px 10px;
  border: 1px solid #e4e6eb;
  border-radius: 8px;
  background: #f0f2f5;
  cursor: pointer;
  font-size: 0.8125rem;
  transition: all 0.15s;
  text-align: left;
}

.cpm-feeling-item:hover,
.cpm-activity-item:hover {
  background: #e7f3ff;
  border-color: #1877f2;
}

/* Search Input */
.cpm-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccd0d5;
  border-radius: 20px;
  font-size: 0.875rem;
  outline: none;
  background: #f0f2f5;
  box-sizing: border-box;
  margin-bottom: 8px;
}

.cpm-search-input:focus {
  border-color: #1877f2;
  background: #fff;
}

/* Search Results */
.cpm-search-results {
  max-height: 150px;
  overflow-y: auto;
}

.cpm-search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.cpm-search-result-item:hover {
  background: #f0f2f5;
}

.cpm-search-result-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: #050505;
}

.cpm-search-result-sci {
  font-size: 0.75rem;
  color: #65676b;
  font-style: italic;
}

.cpm-search-result-thumb {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 6px;
  overflow: hidden;
  background: #f0f2f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.cpm-search-result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cpm-search-result-thumb-round {
  border-radius: 50%;
}

/* Mention badge (Seguindo) */
.cpm-mention-badge {
  font-size: 0.6875rem;
  color: #0096c7;
  background: #e3f2fd;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* Inline @mention autocomplete */
.cpm-mention-autocomplete {
  margin: 0 16px;
  background: #fff;
  border: 1px solid #dddfe2;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
}

.cpm-mention-ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.12s;
}

.cpm-mention-ac-item:hover,
.cpm-mention-ac-item.cpm-mention-ac-active {
  background: #f0f2f5;
}

.cpm-mention-ac-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: #e4e6eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.cpm-mention-ac-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cpm-mention-ac-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #050505;
}

/* Hashtag Suggestions */
.cpm-hashtag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

.cpm-hashtag-pill {
  padding: 4px 10px;
  background: #e7f3ff;
  color: #1877f2;
  border-radius: 12px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
}

.cpm-hashtag-pill:hover {
  background: #d0e8ff;
}

/* Action Bar */
.cpm-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #e4e6eb;
  border-bottom: 1px solid #e4e6eb;
}

.cpm-action-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #050505;
  white-space: nowrap;
}

.cpm-action-buttons {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.cpm-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.cpm-action-btn:hover {
  background: #f0f2f5;
}

.cpm-action-icon {
  font-size: 1.25rem;
}

/* Submit */
.cpm-submit-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px 16px;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: #1877f2;
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.cpm-submit-btn:hover:not(:disabled) {
  background: #166fe5;
}

.cpm-submit-btn:disabled {
  background: #e4e6eb;
  color: #bcc0c4;
  cursor: not-allowed;
}

.cpm-submit-btn.cpm-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* ============================================
   Upload Progress Overlay
   ============================================ */

/* Thumb in uploading state */
.cpm-media-thumb--uploading {
  /* Allow cancel button clicks */
}

/* Cancel button on uploading thumbs */
.cpm-upload-cancel {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  transition: background 0.15s, transform 0.15s;
  line-height: 1;
}

.cpm-upload-cancel:hover {
  background: #e74c3c;
  transform: scale(1.15);
}

.cpm-media-thumb--done .cpm-upload-overlay {
  animation: cpmOverlayFadeOut 0.4s ease forwards;
}

.cpm-media-thumb--error {
  border-color: #e74c3c !important;
}

/* Overlay on top of thumbnail */
.cpm-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
  border-radius: 7px;
  backdrop-filter: blur(2px);
  transition: opacity 0.3s ease;
}

/* Circular progress ring */
.cpm-progress-ring {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}

.cpm-progress-ring__bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 3;
}

.cpm-progress-ring__fill {
  fill: none;
  stroke: #4ade80;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 113;
  transition: stroke-dashoffset 0.15s ease;
}

/* Processing state — pulsing ring */
.cpm-upload-overlay--processing .cpm-progress-ring__fill {
  stroke: #60a5fa;
  animation: cpmRingPulse 1.2s ease-in-out infinite;
}

/* Error state */
.cpm-upload-overlay--error .cpm-progress-ring__fill {
  stroke: #f87171;
  stroke-dashoffset: 0;
}

/* Status label below ring */
.cpm-upload-status {
  color: #fff;
  font-size: 0.625rem;
  font-weight: 600;
  margin-top: 3px;
  text-align: center;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Percentage inside ring */
.cpm-upload-percent {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 6px));
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* Checkmark on completion */
.cpm-upload-check {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 6px)) scale(0);
  width: 20px;
  height: 20px;
  color: #4ade80;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  animation: cpmCheckPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Error icon */
.cpm-upload-error-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 6px)) scale(0);
  color: #f87171;
  font-size: 1.125rem;
  font-weight: 700;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  animation: cpmCheckPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Retry button on error */
.cpm-upload-retry {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(231, 76, 60, 0.85);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.5625rem;
  padding: 2px 6px;
  cursor: pointer;
  font-weight: 600;
  z-index: 3;
  transition: background 0.15s;
}

.cpm-upload-retry:hover {
  background: rgba(231, 76, 60, 1);
}

/* Batch progress bar (below media preview) */
.cpm-batch-progress {
  display: none;
  padding: 0 16px 6px;
  gap: 8px;
  align-items: center;
}

.cpm-batch-progress--active {
  display: flex;
}

.cpm-batch-bar-wrap {
  flex: 1;
  height: 4px;
  background: #e4e6eb;
  border-radius: 2px;
  overflow: hidden;
}

.cpm-batch-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1877f2, #4ade80);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.cpm-batch-label {
  font-size: 0.6875rem;
  color: #65676b;
  white-space: nowrap;
  font-weight: 500;
}

/* Animations */
@keyframes cpmOverlayFadeOut {
  0% { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

@keyframes cpmRingPulse {
  0%, 100% { stroke-dashoffset: 28; opacity: 1; }
  50% { stroke-dashoffset: 14; opacity: 0.7; }
}

@keyframes cpmCheckPop {
  0% { transform: translate(-50%, calc(-50% - 6px)) scale(0); }
  100% { transform: translate(-50%, calc(-50% - 6px)) scale(1); }
}

/* Drag-and-drop zone */
.cpm-container--dragover {
  outline: 3px dashed #1877f2;
  outline-offset: -3px;
}

.cpm-dropzone-hint {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(24, 119, 242, 0.08);
  z-index: 5;
  border-radius: 12px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.cpm-container--dragover .cpm-dropzone-hint {
  display: flex;
}

.cpm-dropzone-icon {
  font-size: 2.5rem;
  opacity: 0.8;
  animation: cpmDropBounce 0.6s ease infinite alternate;
}

.cpm-dropzone-text {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #1877f2;
}

@keyframes cpmDropBounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px); }
}

/* Thumbnail enter animation */
.cpm-media-thumb--enter {
  animation: cpmThumbEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cpmThumbEnter {
  0% { opacity: 0; transform: scale(0.7); }
  100% { opacity: 1; transform: scale(1); }
}

/* Responsive */
@media (max-width: 540px) {
  .cpm-container {
    max-width: 100%;
    margin: 10px;
    border-radius: 10px;
  }

  .cpm-textarea {
    font-size: 1.125rem;
  }

  .cpm-feeling-grid,
  .cpm-activity-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .cpm-action-label {
    display: none;
  }
}
