/* ============================================
   FACEBOOK-STYLE CREATE STORY MODAL
   Clean, spacious design
   ============================================ */

/* Overlay */
.story-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

/* Container */
.story-modal-container {
  position: relative;
  width: 95%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--bg-primary, #0f0f0f);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.2s ease-out;
}

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

/* Header */
.story-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #2a2a2a);
}

.story-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary, #fff);
}

.story-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-tertiary, #2a2a2a);
  border-radius: 50%;
  color: var(--text-muted, #888);
  cursor: pointer;
  transition: all 0.2s;
}

.story-close-btn:hover {
  background: var(--bg-secondary, #1a1a1a);
  color: var(--text-primary, #fff);
}

/* Body - Two Column Layout */
.story-modal-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  padding: 24px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Editor Panel */
.story-editor-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Type Selector */
.story-type-selector {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: var(--bg-tertiary, #1a1a1a);
  border-radius: 12px;
}

.story-type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-muted, #888);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.story-type-btn:hover {
  color: var(--text-primary, #fff);
}

.story-type-btn.active {
  background: var(--accent, #0891b2);
  color: #fff;
}

.story-type-btn svg {
  opacity: 0.8;
}

.story-type-btn.active svg {
  opacity: 1;
}

/* Content Editor */
.story-content-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.story-content-editor.hidden {
  display: none;
}

/* Text Input Wrapper */
.story-text-input-wrapper {
  border-radius: 16px;
  padding: 24px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

#story-text-input {
  width: 100%;
  min-height: 150px;
  background: transparent;
  border: none;
  text-align: center;
  resize: none;
  outline: none;
  font-weight: 600;
  line-height: 1.4;
}

#story-text-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

/* Text Controls */
.story-text-controls {
  display: flex;
  gap: 20px;
  padding: 16px;
  background: var(--bg-secondary, #1a1a1a);
  border-radius: 12px;
}

.control-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.story-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-tertiary, #2a2a2a);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.story-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent, #0891b2);
  cursor: pointer;
  transition: transform 0.2s;
}

.story-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.story-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent, #0891b2);
  border: none;
  cursor: pointer;
}

/* Color Options */
.color-options {
  display: flex;
  gap: 8px;
}

.color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn.active {
  border-color: var(--accent, #0891b2);
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.3);
}

/* Background Picker */
.story-bg-picker {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-bg-picker label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bg-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bg-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.bg-btn:hover {
  transform: scale(1.1);
}

.bg-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--accent, #0891b2);
}

/* Upload Area */
.story-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  border: 2px dashed var(--border, #2a2a2a);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-secondary, #1a1a1a);
}

.story-upload-area:hover {
  border-color: var(--accent, #0891b2);
  background: rgba(8, 145, 178, 0.05);
}

.story-upload-area svg {
  color: var(--accent, #0891b2);
  margin-bottom: 16px;
}

.story-upload-area p {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary, #fff);
}

.story-upload-area span {
  font-size: 13px;
  color: var(--text-muted, #888);
}

.story-upload-area.hidden {
  display: none;
}

/* Photo Preview */
.story-photo-preview {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg-tertiary, #1a1a1a);
}

.story-photo-preview.hidden {
  display: none;
}

.story-photo-container {
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.story-photo-preview img,
.story-photo-preview video {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  display: block;
  transition: transform 0.1s ease-out;
  transform-origin: center center;
}

.story-photo-preview video {
  background: #000;
}

.change-photo-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.7);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.change-photo-btn:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* Zoom Controls */
.story-zoom-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary, #1a1a1a);
  border-radius: 12px;
}

.story-zoom-controls.hidden {
  display: none;
}

.story-zoom-controls label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.zoom-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: linear-gradient(135deg, #0891b2 0%, #10b981 100%);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.zoom-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.3);
}

.zoom-btn:active {
  transform: scale(0.95);
}

.zoom-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted, #888);
  font-style: italic;
}

/* Filters */
.story-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-filters.hidden {
  display: none;
}

.story-filters label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-options {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 2px solid transparent;
  background: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--border, #2a2a2a);
}

.filter-btn.active {
  border-color: var(--accent, #0891b2);
}

.filter-preview {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
}

.filter-btn span {
  font-size: 11px;
  color: var(--text-muted, #888);
}

.filter-btn.active span {
  color: var(--accent, #0891b2);
}

/* Extras (Stickers) - Collapsed by default */
.story-extras {
  border-top: 1px solid var(--border, #2a2a2a);
  padding-top: 16px;
}

.extras-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-secondary, #1a1a1a);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 12px;
  color: var(--text-primary, #fff);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.extras-toggle:hover {
  background: var(--bg-tertiary, #2a2a2a);
}

.extras-toggle svg {
  transition: transform 0.2s;
  color: var(--text-muted, #888);
}

.sticker-panel {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-secondary, #1a1a1a);
  border-radius: 12px;
  animation: slideDown 0.2s ease-out;
}

.sticker-panel.hidden {
  display: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.sticker-item {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--bg-tertiary, #2a2a2a);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.sticker-item:hover {
  background: var(--bg-primary, #0f0f0f);
  transform: scale(1.15);
}

/* Duration */
.story-duration {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #2a2a2a);
}

.story-duration label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.story-duration label span {
  color: var(--accent, #0891b2);
}

/* Preview Panel */
.story-preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  align-self: flex-start;
}

/* Simple Preview Frame (no phone mockup) */
.simple-preview-frame {
  position: relative;
  width: 100%;
  max-width: 240px;
  aspect-ratio: 9/16;
  background: var(--bg-tertiary, #1a1a1a);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.preview-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  transition: background 0.3s ease;
}

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

.preview-text {
  word-break: break-word;
  line-height: 1.3;
  font-weight: 600;
}

.preview-hint {
  font-size: 12px;
  color: var(--text-muted, #888);
  text-align: center;
  margin: 0;
}

/* Footer */
.story-modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border, #2a2a2a);
  background: var(--bg-secondary, #1a1a1a);
}

.story-cancel-btn {
  padding: 12px 24px;
  background: var(--bg-tertiary, #2a2a2a);
  border: none;
  border-radius: 8px;
  color: var(--text-primary, #fff);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.story-cancel-btn:hover {
  background: var(--border, #333);
}

.story-share-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--accent, #0891b2), #10b981);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.story-share-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(8, 145, 178, 0.4);
}

.story-share-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Progress Overlay */
.story-progress-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.story-progress-overlay.hidden {
  display: none;
}

.progress-content {
  text-align: center;
  padding: 32px;
}

.progress-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--bg-tertiary, #2a2a2a);
  border-top-color: var(--accent, #0891b2);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

.progress-content p {
  margin: 0 0 16px 0;
  font-size: 16px;
  color: var(--text-primary, #fff);
}

.progress-bar {
  width: 200px;
  height: 6px;
  background: var(--bg-tertiary, #2a2a2a);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent, #0891b2), #10b981);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Responsive */
@media (max-width: 768px) {
  .story-modal-container {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .story-modal-body {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .story-preview-panel {
    order: -1;
  }

  .simple-preview-frame {
    max-width: 160px;
  }

  .story-text-controls {
    flex-direction: column;
    gap: 12px;
  }

  .sticker-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .filter-options {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .story-modal-header {
    padding: 12px 16px;
  }

  .story-modal-header h2 {
    font-size: 18px;
  }

  .bg-options {
    justify-content: center;
  }

  .bg-btn {
    width: 36px;
    height: 36px;
  }
}
