/* =========================================
   1. FORM LAYOUT HELPERS
   ========================================= */
.form-table-label {
    width: 35%;
    vertical-align: middle;
    font-weight: bold;
}

.form-table-field { width: 65%; }
.form-table-field-wide { width: 75%; }
.td { align-content: center; }

.location-field-wrapper {
    display: flex;
    align-items: center;
}

.location-field-wrapper select,
.location-field-wrapper input {
    flex: 1 1 auto;
}

.location-add-btn { margin-left: 8px; }

/* =========================================
   2. MEDIA CONTROLS & BUTTONS
   ========================================= */
.hidden-storage, .hidden-picker {
    display: none !important;
}

.media-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.media-controls .btn { flex: 1; }

.media-btn {
    display: block;
    width: 100%;
    text-align: center;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 0;
    transition: opacity 0.2s;
}

.media-btn:hover { opacity: 0.9; }
.media-btn:active { transform: translateY(1px); }

.media-actions-group {
    display: inline-block;
    margin-bottom: 10px;
}

.media-actions-group .btn { margin-right: 5px; }

/* =========================================
   3. LIVE RECORDING UI
   ========================================= */
.recording-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(220, 53, 69, 0.9);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    z-index: 10;
    animation: blink-rec 1s infinite;
    pointer-events: none;
}

@keyframes blink-rec {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.audio-visuals {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    background: #f5f5f5;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #e3e3e3;
}

#audio_visualizer {
    width: 200px;
    height: 40px;
    background-color: #333;
    border-radius: 3px;
}

.audio-timer {
    font-family: monospace;
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

#video_camera_preview, #photo_camera_preview {
    background: #000;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-bottom: 10px;
}

/* =========================================
   4. THUMBNAILS & PREVIEWS (The Grid)
   ========================================= */
.media-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0 20px;
    width: 100%;
}

.preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
    background: #f8f8f8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.preview-item audio {
    width: 180px;
    height: 40px;
    margin-top: 30px;
}

.preview-item:has(audio), .preview-item.has-audio {
    width: 200px;
    height: auto;
    padding: 5px;
    display: flex;
    justify-content: center;
}

.preview-remove {
    position: absolute;
    top: 0; right: 0;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    width: 24px;
    height: 24px;
    text-align: center;
    line-height: 22px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-bottom-left-radius: 4px;
    z-index: 10;
    transition: background 0.2s;
}

.preview-remove:hover { background: rgb(200, 35, 51); }

.existing-media {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.existing-media-item {
    flex: 0 0 auto;
    max-width: 220px;
    background: #fff;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* =========================================
   5. RESPONSIVENESS
   ========================================= */

/* Desktop Specific */
@media (min-width: 768px) {
    .visible-xs-block { display: none !important; }
}

/* Mobile Specific */
@media (max-width: 767px) {
    .form-table-label, .form-table-field, .form-table-field-wide {
        display: block;
        width: 100% !important;
        margin-bottom: 5px;
    }

    .media-controls { flex-direction: column; }

    .media-controls .btn, .media-btn, .well.form-actions .btn {
        width: 100%;
        display: block;
        padding: 12px;
    }

    .media-actions-group, .media-actions-group .btn {
        display: block;
        width: 100%;
        margin-right: 0;
    }

    .media-actions-group .btn { margin-bottom: 8px; }

    .media-preview-container { justify-content: flex-start; }
    .preview-item { width: 80px; height: 80px; }
    .preview-item:has(audio), .preview-item.has-audio { width: 100%; }

    .hidden-xs { display: none !important; }
    .visible-xs-block {
        display: block !important;
        width: 100%;
        margin-bottom: 10px;
    }
}