{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template tiny_mediacms/iframe_video_library

    Video library browser for iframe modal.

    Example context (json):
    {
        "elementid": "editor1"
    }
}}
<div class="tiny_iframecms_library_container">
    <!-- Search and Filter Bar -->
    <div class="row mb-3">
        <div class="col-md-8">
            <div class="input-group">
                <input type="text" class="form-control tiny_iframecms_library_search" 
                       placeholder="{{#str}} librarysearchplaceholder, tiny_mediacms {{/str}}">
                <button type="button" class="btn btn-outline-secondary tiny_iframecms_library_search_btn">
                    <i class="fa fa-search" aria-hidden="true"></i>
                    {{#str}} search, moodle {{/str}}
                </button>
            </div>
        </div>
        <div class="col-md-4">
            <select class="form-control tiny_iframecms_library_sort">
                <option value="date_desc">{{#str}} librarysortnewest, tiny_mediacms {{/str}}</option>
                <option value="date_asc">{{#str}} librarysortoldest, tiny_mediacms {{/str}}</option>
                <option value="title_asc">{{#str}} librarysorttitle, tiny_mediacms {{/str}}</option>
                <option value="views_desc">{{#str}} librarysortviews, tiny_mediacms {{/str}}</option>
            </select>
        </div>
    </div>

    <!-- Video Grid -->
    <div class="tiny_iframecms_library_grid" style="max-height: 400px; overflow-y: auto;">
        <!-- Loading state -->
        <div class="tiny_iframecms_library_loading text-center py-5">
            <div class="spinner-border text-primary" role="status">
                <span class="sr-only">{{#str}} loading, tiny_mediacms {{/str}}</span>
            </div>
            <p class="mt-2 text-muted">{{#str}} libraryloading, tiny_mediacms {{/str}}</p>
        </div>

        <!-- Videos will be rendered here -->
        <div class="tiny_iframecms_library_items row d-none">
            <!-- Video items will be dynamically inserted here -->
        </div>

        <!-- Empty state -->
        <div class="tiny_iframecms_library_empty text-center py-5 d-none">
            <i class="fa fa-video-camera fa-3x text-muted mb-3" aria-hidden="true"></i>
            <p class="text-muted">{{#str}} libraryempty, tiny_mediacms {{/str}}</p>
        </div>

        <!-- Error state -->
        <div class="tiny_iframecms_library_error text-center py-5 d-none">
            <i class="fa fa-exclamation-triangle fa-3x text-warning mb-3" aria-hidden="true"></i>
            <p class="text-danger tiny_iframecms_library_error_message">{{#str}} libraryerror, tiny_mediacms {{/str}}</p>
            <button type="button" class="btn btn-secondary tiny_iframecms_library_retry">
                {{#str}} libraryretry, tiny_mediacms {{/str}}
            </button>
        </div>
    </div>

    <!-- Pagination -->
    <div class="tiny_iframecms_library_pagination d-flex justify-content-between align-items-center mt-3 d-none">
        <button type="button" class="btn btn-outline-secondary btn-sm tiny_iframecms_library_prev" disabled>
            <i class="fa fa-chevron-left" aria-hidden="true"></i> {{#str}} libraryprev, tiny_mediacms {{/str}}
        </button>
        <span class="tiny_iframecms_library_page_info text-muted"></span>
        <button type="button" class="btn btn-outline-secondary btn-sm tiny_iframecms_library_next">
            {{#str}} librarynext, tiny_mediacms {{/str}} <i class="fa fa-chevron-right" aria-hidden="true"></i>
        </button>
    </div>
</div>
