/**
 * StoryCreator Component Styles
 * Frontend form for creating stories with audio and image capture
 */

/* ============================================
   Flash Messages
   ============================================ */
.flash-message {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: flashSlide 0.3s ease;
}

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

.flash-message--success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.flash-message--error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.flash-message--warning {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

/* ============================================
   Base Container
   ============================================ */
.story-creator {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.story-creator__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e8e8e8;
}

.story-creator__title svg {
    color: #4CAF50;
}

/* ============================================
   Form Sections
   ============================================ */
.form-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e8e8e8;
}

.form-section__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
}

.form-section__title svg {
    color: #666;
}

.form-section--submit {
    background: transparent;
    box-shadow: none;
    border: none;
    text-align: center;
    padding: 0;
}

/* ============================================
   Form Controls
   ============================================ */
.form-label {
    display: block;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    margin-bottom: 16px;
}

.form-control:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.form-control::placeholder {
    color: #999;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 0.85rem;
    color: #666;
    margin-top: -8px;
    margin-bottom: 16px;
}

.required {
    color: #e53935;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-col {
    flex: 1;
    min-width: 150px;
}

.form-col--grow {
    flex: 2;
}

.form-col--auto {
    flex: 0 0 auto;
    min-width: 140px;
}

/* ============================================
   Point Mode Selector
   ============================================ */
.point-mode-selector {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.radio-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: #4CAF50;
}

.radio-option__label {
    font-size: 0.95rem;
    color: #333;
}

.point-section {
    animation: fadeIn 0.3s ease;
}

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

/* ============================================
   Location Picker Map
   ============================================ */
.location-picker-container {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #ddd;
    margin-bottom: 16px;
}

.location-map {
    height: 300px;
    width: 100%;
}

.mini-map {
    height: 150px;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    margin-top: 12px;
    border: 1px solid #ddd;
}

.location-controls {
    padding: 10px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
}

.coordinates-display {
    display: flex;
    gap: 20px;
    padding: 10px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    font-size: 0.9rem;
    color: #666;
}

.coordinates-display strong {
    color: #333;
    font-family: 'Monaco', 'Consolas', monospace;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn svg {
    flex-shrink: 0;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #43A047;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-outline {
    background: transparent;
    border: 1px solid #ddd;
    color: #333;
}

.btn-outline:hover {
    background: #f8f9fa;
    border-color: #ccc;
}

.btn-danger {
    background: #e53935;
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-delete:hover {
    background: #e53935;
}

/* ============================================
   Media Uploader (Image & Audio)
   ============================================ */
.media-uploader {
    position: relative;
}

.media-uploader__controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.media-uploader__controls .divider {
    color: #999;
    font-size: 0.9rem;
}

.media-uploader__preview {
    position: relative;
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid #ddd;
}

/* Image Preview */
#imagePreview img {
    display: block;
    max-width: 100%;
    max-height: 300px;
    margin: 0 auto;
}

/* Audio Preview */
#audioPreview {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

#audioPreview audio {
    flex: 1;
    max-width: 100%;
}

/* ============================================
   Camera Modal
   ============================================ */
.camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-modal__content {
    width: 100%;
    max-width: 640px;
    padding: 20px;
}

.camera-modal__content video {
    width: 100%;
    border-radius: 8px;
    background: #000;
}

.camera-modal__controls {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
}

/* ============================================
   Recording UI
   ============================================ */
.recording-ui {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px;
    background: #fff5f5;
    border: 1px solid #ffcdd2;
    border-radius: 8px;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: #e53935;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

.recording-timer {
    font-size: 1.2rem;
    font-weight: 600;
    font-family: 'Monaco', 'Consolas', monospace;
    color: #e53935;
}

/* ============================================
   Flash Messages
   ============================================ */
#storyCreatorMessages {
    margin-bottom: 20px;
}

.flash-message {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

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

.flash-message--success {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
}

.flash-message--error {
    background: #ffebee;
    border: 1px solid #ef9a9a;
    color: #c62828;
}

.flash-message--warning {
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #f57f17;
}

/* ============================================
   Loading State
   ============================================ */
.btn.is-loading {
    position: relative;
    color: transparent !important;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-primary.is-loading::after {
    border-top-color: white;
}

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

/* Loading state */
.btn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-top: -9px;
    margin-left: -9px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-outline.is-loading::after {
    border-color: #4CAF50;
    border-top-color: transparent;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
    .story-creator {
        padding: 12px;
    }

    .form-section {
        padding: 16px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-col--auto {
        min-width: 100%;
    }

    .point-mode-selector {
        flex-direction: column;
        gap: 12px;
    }

    .media-uploader__controls {
        flex-direction: column;
        align-items: stretch;
    }

    .media-uploader__controls .divider {
        text-align: center;
    }

    .media-uploader__controls .btn {
        width: 100%;
    }

    .recording-ui {
        flex-direction: column;
        text-align: center;
    }
}
