/* ==========================================================================
   Media Picker Component Styles
   ========================================================================== */

.fml-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.fml-picker-modal {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    width: 100%;
    max-width: 72rem;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.fml-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgb(229 231 235);
    flex-shrink: 0;
}
.fml-picker-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: rgb(17 24 39);
    margin: 0;
}
.fml-picker-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    color: rgb(156 163 175);
    cursor: pointer;
    border-radius: 0.375rem;
    transition: color 150ms, background-color 150ms;
}
.fml-picker-close:hover { color: rgb(55 65 81); background: rgb(243 244 246); }
.fml-picker-close svg { width: 1.25rem; height: 1.25rem; }

.fml-picker-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgb(229 231 235);
    padding: 0 1.5rem;
    flex-shrink: 0;
}
.fml-picker-tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgb(107 114 128);
    border: none;
    background: transparent;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 150ms, border-color 150ms;
}
.fml-picker-tab:hover { color: rgb(55 65 81); }
.fml-picker-tab.active {
    color: rgb(var(--primary-600));
    border-bottom-color: rgb(var(--primary-600));
}

.fml-picker-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Upload tab */
.fml-picker-upload-zone {
    position: relative;
    margin: 2rem;
    padding: 4rem 2rem;
    border: 2px dashed rgb(209 213 219);
    border-radius: 0.75rem;
    background: rgb(249 250 251);
    text-align: center;
    transition: border-color 200ms, background-color 200ms;
}
.fml-picker-upload-zone.fml-drag-over {
    border-color: rgb(var(--primary-500));
    background: rgba(var(--primary-500), 0.05);
}
.fml-picker-upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    border-radius: 9999px;
    background: rgb(243 244 246);
    margin: 0 auto 1rem;
}
.fml-picker-upload-icon svg { width: 2rem; height: 2rem; color: rgb(156 163 175); }
.fml-picker-upload-zone h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: rgb(17 24 39);
    margin: 0 0 0.375rem;
}
.fml-picker-upload-zone p {
    font-size: 0.875rem;
    color: rgb(107 114 128);
    margin: 0 0 1rem;
}
.fml-picker-upload-zone .fml-upload-hint {
    font-size: 0.75rem;
    color: rgb(156 163 175);
    margin-top: 1rem;
}
.fml-picker-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: 1px solid rgb(209 213 219);
    background: white;
    color: rgb(55 65 81);
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: background-color 150ms, border-color 150ms;
}
.fml-picker-select-btn:hover { background: rgb(243 244 246); border-color: rgb(156 163 175); }

/* Upload progress */
.fml-picker-upload-progress {
    padding: 1rem 1.5rem;
}
.fml-picker-upload-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgb(243 244 246);
}
.fml-picker-upload-item:last-child { border-bottom: none; }
.fml-picker-upload-name {
    flex: 1;
    font-size: 0.875rem;
    color: rgb(55 65 81);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fml-picker-upload-status {
    font-size: 0.75rem;
    font-weight: 500;
}
.fml-picker-upload-status.success { color: rgb(22 163 74); }
.fml-picker-upload-status.error { color: rgb(220 38 38); }
.fml-picker-upload-status.uploading { color: rgb(var(--primary-500)); }

/* Library tab layout */
.fml-picker-library {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.fml-picker-library-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.fml-picker-library-sidebar {
    width: 20rem;
    flex-shrink: 0;
    border-left: 1px solid rgb(229 231 235);
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.fml-picker-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid rgb(229 231 235);
    flex-shrink: 0;
}
.fml-picker-filter {
    font-size: 0.875rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid rgb(209 213 219);
    border-radius: 0.5rem;
    background: white;
    color: rgb(17 24 39);
    outline: none;
}
.fml-picker-filter:focus {
    border-color: rgb(var(--primary-500));
    box-shadow: 0 0 0 1px rgb(var(--primary-500));
}
.fml-picker-search {
    flex: 1;
    max-width: 16rem;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid rgb(209 213 219);
    border-radius: 0.5rem;
    background: white;
    color: rgb(17 24 39);
    outline: none;
}
.fml-picker-search:focus {
    border-color: rgb(var(--primary-500));
    box-shadow: 0 0 0 1px rgb(var(--primary-500));
}

.fml-picker-grid-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}
.fml-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}
@media (min-width: 768px)  { .fml-picker-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1024px) { .fml-picker-grid { grid-template-columns: repeat(6, 1fr); } }

.fml-picker-tile {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 0.5rem;
    border: 2px solid rgb(229 231 235);
    background: rgb(243 244 246);
    cursor: pointer;
    padding: 0;
    text-align: left;
    width: 100%;
    transition: border-color 150ms, box-shadow 150ms;
}
.fml-picker-tile:hover { border-color: rgb(156 163 175); }
.fml-picker-tile.selected {
    border-color: rgb(var(--primary-500));
    box-shadow: 0 0 0 1px rgb(var(--primary-500));
}
.fml-picker-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.fml-picker-tile-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: 100%;
    height: 100%;
    color: rgb(156 163 175);
}
.fml-picker-tile-icon svg { width: 1.5rem; height: 1.5rem; }
.fml-picker-tile-icon span {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.fml-picker-tile-check {
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    width: 1.25rem;
    height: 1.25rem;
    background: rgb(var(--primary-500));
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
}
.fml-picker-tile-check svg { width: 0.75rem; height: 0.75rem; color: white; }

.fml-picker-load-more {
    display: flex;
    justify-content: center;
    padding: 1rem 0 0.5rem;
}
.fml-picker-load-more button {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(var(--primary-600));
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.375rem 1rem;
    border-radius: 0.375rem;
    transition: background-color 150ms;
}
.fml-picker-load-more button:hover { background: rgba(var(--primary-500), 0.08); }
.fml-picker-load-more button:disabled { color: rgb(156 163 175); cursor: default; }

/* Sidebar detail */
.fml-picker-detail-preview {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 0.5rem;
    background: rgb(243 244 246);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}
.fml-picker-detail-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.fml-picker-detail-preview-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: rgb(156 163 175);
}
.fml-picker-detail-preview-icon svg { width: 3rem; height: 3rem; }
.fml-picker-detail-preview-icon span { font-size: 0.875rem; font-weight: 500; }

.fml-picker-meta {
    font-size: 0.75rem;
    color: rgb(107 114 128);
    margin-bottom: 1rem;
    line-height: 1.6;
}
.fml-picker-meta-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgb(243 244 246);
}
.fml-picker-meta-label { font-weight: 600; color: rgb(55 65 81); }

.fml-picker-field { margin-bottom: 0.75rem; }
.fml-picker-field:last-child { margin-bottom: 0; }
.fml-picker-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    color: rgb(55 65 81);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.fml-picker-input,
.fml-picker-textarea {
    width: 100%;
    font-size: 0.8125rem;
    padding: 0.375rem 0.5rem;
    border: 1px solid rgb(209 213 219);
    border-radius: 0.375rem;
    background: white;
    color: rgb(17 24 39);
    outline: none;
    transition: border-color 150ms;
    box-sizing: border-box;
}
.fml-picker-input:focus,
.fml-picker-textarea:focus {
    border-color: rgb(var(--primary-500));
    box-shadow: 0 0 0 1px rgb(var(--primary-500));
}
.fml-picker-textarea { resize: vertical; }

.fml-picker-detail-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Footer */
.fml-picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid rgb(229 231 235);
    flex-shrink: 0;
}
.fml-picker-footer-count {
    font-size: 0.875rem;
    color: rgb(107 114 128);
}
.fml-picker-footer-actions {
    display: flex;
    gap: 0.5rem;
}

/* Spinner */
.fml-picker-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgb(229 231 235);
    border-top-color: rgb(var(--primary-500));
    border-radius: 50%;
    animation: fml-picker-spin 0.6s linear infinite;
}
@keyframes fml-picker-spin {
    to { transform: rotate(360deg); }
}
.fml-picker-spinner-sm {
    width: 0.875rem;
    height: 0.875rem;
    border-width: 2px;
}
.fml-picker-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

/* Empty state */
.fml-picker-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}
.fml-picker-empty svg { width: 3rem; height: 3rem; color: rgb(209 213 219); margin-bottom: 0.75rem; }
.fml-picker-empty p { font-size: 0.875rem; color: rgb(107 114 128); margin: 0; }

/* Single image preview (WordPress featured image style) */
.fml-picker-single-preview {
    position: relative;
    max-width: 16rem;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid rgb(229 231 235);
}
.fml-picker-single-preview img {
    display: block;
    width: 100%;
    height: auto;
}
.fml-picker-single-preview-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem 2rem;
    background: rgb(243 244 246);
    font-size: 0.8125rem;
    font-weight: 500;
    color: rgb(107 114 128);
}
.fml-picker-single-preview-icon svg { width: 1.5rem; height: 1.5rem; flex-shrink: 0; }
.fml-picker-remove-link {
    display: inline-block;
    font-size: 0.8125rem;
    color: rgb(220 38 38);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    margin-top: 0.375rem;
}
.fml-picker-remove-link:hover { color: rgb(185 28 28); }

/* Multi-select thumbnail row */
.fml-picker-multi-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.fml-picker-multi-item {
    position: relative;
    width: 5rem;
    height: 5rem;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid rgb(229 231 235);
}
.fml-picker-multi-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.fml-picker-multi-item-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(243 244 246);
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    color: rgb(107 114 128);
}
.fml-picker-multi-remove {
    position: absolute;
    top: 0;
    right: 0;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(220 38 38);
    color: white;
    border: none;
    border-radius: 0 0 0 0.25rem;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 150ms;
}
.fml-picker-multi-item:hover .fml-picker-multi-remove { opacity: 1; }
.fml-picker-multi-remove svg { width: 0.75rem; height: 0.75rem; }

.fml-picker-sidebar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    color: rgb(156 163 175);
    padding: 2rem 1rem;
}
.fml-picker-sidebar-empty svg { width: 2.5rem; height: 2.5rem; margin-bottom: 0.75rem; }
.fml-picker-sidebar-empty p { font-size: 0.8125rem; margin: 0; }

.fml-picker-notification {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 60;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    transition: opacity 300ms, transform 300ms;
}
.fml-picker-notification.success {
    background: rgb(220 252 231);
    color: rgb(22 101 52);
    border: 1px solid rgb(134 239 172);
}
.fml-picker-notification.error {
    background: rgb(254 226 226);
    color: rgb(153 27 27);
    border: 1px solid rgb(252 165 165);
}

/* Media Picker - Dark mode */
.dark .fml-picker-modal { background: rgb(17 24 39); }
.dark .fml-picker-header { border-color: rgb(55 65 81); }
.dark .fml-picker-header h2 { color: white; }
.dark .fml-picker-close { color: rgb(107 114 128); }
.dark .fml-picker-close:hover { color: white; background: rgb(31 41 55); }
.dark .fml-picker-tabs { border-color: rgb(55 65 81); }
.dark .fml-picker-tab { color: rgb(156 163 175); }
.dark .fml-picker-tab:hover { color: rgb(209 213 219); }
.dark .fml-picker-tab.active { color: rgb(var(--primary-400)); border-bottom-color: rgb(var(--primary-400)); }
.dark .fml-picker-upload-zone { background: rgb(17 24 39); border-color: rgb(55 65 81); }
.dark .fml-picker-upload-zone.fml-drag-over { border-color: rgb(var(--primary-500)); background: rgba(var(--primary-500), 0.08); }
.dark .fml-picker-upload-icon { background: rgb(31 41 55); }
.dark .fml-picker-upload-icon svg { color: rgb(107 114 128); }
.dark .fml-picker-upload-zone h3 { color: white; }
.dark .fml-picker-upload-zone p { color: rgb(156 163 175); }
.dark .fml-picker-select-btn { background: rgb(31 41 55); border-color: rgb(55 65 81); color: rgb(209 213 219); }
.dark .fml-picker-select-btn:hover { background: rgb(55 65 81); border-color: rgb(75 85 99); }
.dark .fml-picker-toolbar { border-color: rgb(55 65 81); }
.dark .fml-picker-filter,
.dark .fml-picker-search { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: white; }
.dark .fml-picker-tile { border-color: rgb(55 65 81); background: rgb(31 41 55); }
.dark .fml-picker-tile:hover { border-color: rgb(75 85 99); }
.dark .fml-picker-tile.selected { border-color: rgb(var(--primary-500)); }
.dark .fml-picker-tile-icon { color: rgb(107 114 128); }
.dark .fml-picker-library-sidebar { border-color: rgb(55 65 81); }
.dark .fml-picker-detail-preview { background: rgb(31 41 55); }
.dark .fml-picker-detail-preview-icon { color: rgb(107 114 128); }
.dark .fml-picker-meta { color: rgb(156 163 175); }
.dark .fml-picker-meta-row { border-color: rgb(55 65 81); }
.dark .fml-picker-meta-label { color: rgb(209 213 219); }
.dark .fml-picker-label { color: rgb(209 213 219); }
.dark .fml-picker-input,
.dark .fml-picker-textarea { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: white; }
.dark .fml-picker-footer { border-color: rgb(55 65 81); }
.dark .fml-picker-footer-count { color: rgb(156 163 175); }
.dark .fml-picker-empty svg { color: rgb(75 85 99); }
.dark .fml-picker-empty p { color: rgb(156 163 175); }
.dark .fml-picker-spinner { border-color: rgb(55 65 81); border-top-color: rgb(var(--primary-500)); }
.dark .fml-picker-single-preview { border-color: rgb(55 65 81); }
.dark .fml-picker-single-preview-icon { background: rgb(31 41 55); color: rgb(156 163 175); }
.dark .fml-picker-remove-link { color: rgb(248 113 113); }
.dark .fml-picker-remove-link:hover { color: rgb(252 165 165); }
.dark .fml-picker-multi-item { border-color: rgb(55 65 81); }
.dark .fml-picker-multi-item-icon { background: rgb(31 41 55); color: rgb(156 163 175); }
.dark .fml-picker-sidebar-empty { color: rgb(107 114 128); }
.dark .fml-picker-upload-name { color: rgb(209 213 219); }
.dark .fml-picker-upload-item { border-color: rgb(55 65 81); }

/* ==========================================================================
   Media Grid Page Styles
   ========================================================================== */

.fml-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.fml-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.fml-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    justify-content: flex-end;
}
.fml-select,
.fml-search {
    font-size: 0.875rem;
    line-height: 1.25rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgb(209 213 219);
    border-radius: 0.5rem;
    background: white;
    color: rgb(17 24 39);
    outline: none;
    transition: border-color 150ms;
}
.fml-select:focus,
.fml-search:focus {
    border-color: rgb(var(--primary-500));
    box-shadow: 0 0 0 1px rgb(var(--primary-500));
}
.fml-search { width: 100%; max-width: 20rem; }
.fml-count {
    font-size: 0.875rem;
    color: rgb(107 114 128);
    white-space: nowrap;
}

/* Upload Zone */
.fml-upload-zone {
    position: relative;
    margin-bottom: 1.5rem;
    padding: 3rem 2rem;
    border: 2px dashed rgb(209 213 219);
    border-radius: 0.75rem;
    background: rgb(249 250 251);
    text-align: center;
    transition: border-color 200ms, background-color 200ms;
}
.fml-upload-zone.fml-drag-over {
    border-color: rgb(var(--primary-500));
    background: rgba(var(--primary-500), 0.05);
}
.fml-upload-zone-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 9999px;
    background: rgb(243 244 246);
    margin: 0 auto 1rem;
}
.fml-upload-zone-icon svg { width: 1.5rem; height: 1.5rem; color: rgb(156 163 175); }
.fml-upload-zone h3 {
    font-size: 1rem;
    font-weight: 600;
    color: rgb(17 24 39);
    margin: 0 0 0.25rem;
}
.fml-upload-zone p {
    font-size: 0.875rem;
    color: rgb(107 114 128);
    margin: 0 0 1rem;
}
.fml-btn-select-files {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: 1px solid rgb(209 213 219);
    background: white;
    color: rgb(55 65 81);
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: background-color 150ms, border-color 150ms;
}
.fml-btn-select-files:hover {
    background: rgb(243 244 246);
    border-color: rgb(156 163 175);
}
.fml-upload-hint {
    font-size: 0.75rem;
    color: rgb(156 163 175);
    margin-top: 0.75rem;
}

/* Upload progress */
.fml-upload-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}
.fml-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid rgb(229 231 235);
    border-top-color: rgb(var(--primary-500));
    border-radius: 50%;
    animation: fml-spin 0.6s linear infinite;
}
@keyframes fml-spin {
    to { transform: rotate(360deg); }
}
.fml-spinner-sm {
    display: inline-block;
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: fml-spin 0.6s linear infinite;
}
.fml-upload-progress p {
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(107 114 128);
    margin: 0;
}

/* Grid */
.fml-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
@media (min-width: 640px)  { .fml-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 768px)  { .fml-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1024px) { .fml-grid { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 1280px) { .fml-grid { grid-template-columns: repeat(8, 1fr); } }

/* Tiles */
.fml-tile {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 0.5rem;
    border: 1px solid rgb(229 231 235);
    background: rgb(243 244 246);
    cursor: pointer;
    padding: 0;
    text-align: left;
    width: 100%;
    transition: box-shadow 150ms, border-color 150ms;
}
.fml-tile:hover {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    border-color: rgb(var(--primary-500));
}
.fml-tile:focus {
    outline: 2px solid rgb(var(--primary-500));
    outline-offset: 2px;
}
.fml-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.fml-tile-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: 100%;
    height: 100%;
    color: rgb(156 163 175);
}
.fml-tile-icon svg { width: 2rem; height: 2rem; }
.fml-tile-icon span {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.fml-tile-overlay {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 1.5rem 0.5rem 0.5rem;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    opacity: 0;
    transition: opacity 150ms;
    pointer-events: none;
}
.fml-tile:hover .fml-tile-overlay { opacity: 1; }
.fml-tile-overlay p {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty */
.fml-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    border: 2px dashed rgb(209 213 219);
    border-radius: 0.75rem;
    text-align: center;
}
.fml-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem; height: 3rem;
    border-radius: 9999px;
    background: rgb(243 244 246);
    margin-bottom: 1rem;
}
.fml-empty-icon svg { width: 1.5rem; height: 1.5rem; color: rgb(156 163 175); }
.fml-empty h3 { font-size: 0.875rem; font-weight: 500; color: rgb(17 24 39); margin: 0 0 0.25rem; }
.fml-empty p { font-size: 0.875rem; color: rgb(107 114 128); margin: 0; }

/* Pagination */
.fml-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid rgb(229 231 235);
    margin-top: 1rem;
}
.fml-pagination-info { font-size: 0.875rem; color: rgb(107 114 128); }
.fml-pagination-buttons { display: flex; align-items: center; gap: 0.25rem; }
.fml-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    background: transparent;
    color: rgb(55 65 81);
    cursor: pointer;
    transition: background-color 150ms;
}
.fml-page-btn:hover { background: rgb(243 244 246); }
.fml-page-btn.active { background: rgb(var(--primary-500)); color: white; }
.fml-page-btn.active:hover { background: rgb(var(--primary-600)); }
.fml-page-btn:disabled, .fml-page-btn.disabled {
    color: rgb(209 213 219);
    cursor: default;
    pointer-events: none;
}
.fml-page-btn svg { width: 1rem; height: 1rem; }

/* Detail Modal */
.fml-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.fml-modal {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    width: 100%;
    max-width: 64rem;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.fml-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgb(229 231 235);
    flex-shrink: 0;
}
.fml-modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: rgb(17 24 39);
    margin: 0;
}
.fml-modal-close svg { width: 1.25rem; height: 1.25rem; }
.fml-modal-body {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
}
@media (min-width: 768px) {
    .fml-modal-body { flex-direction: row; }
}
.fml-modal-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgb(243 244 246);
    min-height: 16rem;
    padding: 1.5rem;
    position: relative;
}
.fml-modal-preview > img {
    max-width: 100%;
    max-height: 24rem;
    object-fit: contain;
    border-radius: 0.375rem;
}
.fml-modal-preview-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: rgb(156 163 175);
}
.fml-modal-preview-icon svg { width: 4rem; height: 4rem; }
.fml-modal-preview-icon span { font-size: 0.875rem; font-weight: 500; }

/* Image Editor */
.fml-editor-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.fml-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.fml-editor-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid rgb(209 213 219);
    border-radius: 0.375rem;
    background: white;
    color: rgb(55 65 81);
    cursor: pointer;
    transition: background-color 150ms, border-color 150ms;
    padding: 0;
}
.fml-editor-btn:hover {
    background: rgb(243 244 246);
    border-color: rgb(156 163 175);
}
.fml-editor-btn svg { width: 1rem; height: 1rem; }
.fml-editor-btn-sep {
    width: 1px;
    height: 1.5rem;
    background: rgb(209 213 219);
    margin: 0 0.25rem;
}
.fml-editor-canvas {
    width: 100%;
    max-height: 20rem;
    overflow: hidden;
}
.fml-editor-canvas img {
    display: block;
    max-width: 100%;
}
.fml-editor-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.fml-edit-image-wrap {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.fml-modal-sidebar {
    width: 100%;
    padding: 1.5rem;
    overflow-y: auto;
    border-top: 1px solid rgb(229 231 235);
}
@media (min-width: 768px) {
    .fml-modal-sidebar {
        width: 22rem;
        flex-shrink: 0;
        border-top: none;
        border-left: 1px solid rgb(229 231 235);
    }
}
.fml-field { margin-bottom: 1rem; }
.fml-field:last-child { margin-bottom: 0; }
.fml-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgb(55 65 81);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}
.fml-input,
.fml-textarea {
    width: 100%;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgb(209 213 219);
    border-radius: 0.5rem;
    background: white;
    color: rgb(17 24 39);
    outline: none;
    transition: border-color 150ms;
    box-sizing: border-box;
}
.fml-input:focus,
.fml-textarea:focus {
    border-color: rgb(var(--primary-500));
    box-shadow: 0 0 0 1px rgb(var(--primary-500));
}
.fml-textarea { resize: vertical; }
.fml-meta {
    font-size: 0.75rem;
    color: rgb(107 114 128);
    margin-bottom: 1.25rem;
    line-height: 1.6;
}
.fml-meta-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgb(243 244 246);
}
.fml-meta-label { font-weight: 600; color: rgb(55 65 81); }
.fml-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgb(229 231 235);
    flex-shrink: 0;
}

/* Media Grid - Dark mode */
.dark .fml-select, .dark .fml-search {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
    color: white;
}
.dark .fml-count { color: rgb(156 163 175); }
.dark .fml-upload-zone {
    background: rgb(17 24 39);
    border-color: rgb(55 65 81);
}
.dark .fml-upload-zone.fml-drag-over {
    border-color: rgb(var(--primary-500));
    background: rgba(var(--primary-500), 0.08);
}
.dark .fml-upload-zone-icon { background: rgb(31 41 55); }
.dark .fml-upload-zone-icon svg { color: rgb(107 114 128); }
.dark .fml-upload-zone h3 { color: white; }
.dark .fml-upload-zone p { color: rgb(156 163 175); }
.dark .fml-btn-select-files {
    background: rgb(31 41 55);
    border-color: rgb(55 65 81);
    color: rgb(209 213 219);
}
.dark .fml-btn-select-files:hover {
    background: rgb(55 65 81);
    border-color: rgb(75 85 99);
}
.dark .fml-upload-hint { color: rgb(107 114 128); }
.dark .fml-spinner { border-color: rgb(55 65 81); border-top-color: rgb(var(--primary-500)); }
.dark .fml-tile { border-color: rgb(55 65 81); background: rgb(31 41 55); }
.dark .fml-tile:hover { border-color: rgb(var(--primary-500)); }
.dark .fml-tile-icon { color: rgb(107 114 128); }
.dark .fml-empty { border-color: rgb(55 65 81); }
.dark .fml-empty-icon { background: rgb(31 41 55); }
.dark .fml-empty-icon svg { color: rgb(107 114 128); }
.dark .fml-empty h3 { color: white; }
.dark .fml-empty p { color: rgb(156 163 175); }
.dark .fml-pagination { border-color: rgb(55 65 81); }
.dark .fml-pagination-info { color: rgb(156 163 175); }
.dark .fml-page-btn { color: rgb(209 213 219); }
.dark .fml-page-btn:hover { background: rgba(255,255,255,0.05); }
.dark .fml-page-btn.active { background: rgb(var(--primary-500)); color: white; }
.dark .fml-page-btn.disabled { color: rgb(75 85 99); }
.dark .fml-modal { background: rgb(17 24 39); }
.dark .fml-modal-header { border-color: rgb(55 65 81); }
.dark .fml-modal-header h2 { color: white; }
.dark .fml-modal-preview { background: rgb(31 41 55); }
.dark .fml-modal-preview-icon { color: rgb(107 114 128); }
.dark .fml-editor-btn {
    background: rgb(31 41 55);
    border-color: rgb(55 65 81);
    color: rgb(209 213 219);
}
.dark .fml-editor-btn:hover {
    background: rgb(55 65 81);
    border-color: rgb(75 85 99);
}
.dark .fml-editor-btn-sep { background: rgb(55 65 81); }
.dark .fml-modal-sidebar { border-color: rgb(55 65 81); }
.dark .fml-label { color: rgb(209 213 219); }
.dark .fml-input, .dark .fml-textarea {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
    color: white;
}
.dark .fml-meta { color: rgb(156 163 175); }
.dark .fml-meta-row { border-color: rgb(55 65 81); }
.dark .fml-meta-label { color: rgb(209 213 219); }
.dark .fml-modal-footer { border-color: rgb(55 65 81); }
