/* ==========================================================================
   Media Library Cleaner — Admin Stylesheet
   Follows WordPress admin design conventions.
   All colours reference WP admin CSS custom properties where available.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Layout wrapper
   -------------------------------------------------------------------------- */
.emsc-scanner-wrap {
    max-width: 1400px;
}

/* --------------------------------------------------------------------------
   Backup notice
   -------------------------------------------------------------------------- */
.emsc-notice-backup {
    margin: 16px 0 !important;
}

/* --------------------------------------------------------------------------
   Scan controls
   -------------------------------------------------------------------------- */
.emsc-scan-controls {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.emsc-scan-controls h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.emsc-scan-options {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.emsc-option-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.emsc-option-label input[type="checkbox"] {
    margin: 0;
}

/* --------------------------------------------------------------------------
   Progress bar
   -------------------------------------------------------------------------- */
#emsc-scan-progress {
    margin: 12px 0;
}

.emsc-progress-track {
    background: #f0f0f1;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    height: 20px;
    overflow: hidden;
}

.emsc-progress-bar {
    background: #2271b1;
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.emsc-phase-label {
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 6px;
}

.emsc-progress-text {
    font-size: 12px;
    color: #50575e;
    margin: 6px 0 0;
}

/* --------------------------------------------------------------------------
   Summary bar
   -------------------------------------------------------------------------- */
.emsc-summary-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    font-size: 13px;
    color: #1d2327;
    border-bottom: 1px solid #f0f0f1;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.emsc-summary-sep {
    color: #c3c4c7;
}

.emsc-summary-item strong {
    font-size: 15px;
}

/* --------------------------------------------------------------------------
   Result tabs
   -------------------------------------------------------------------------- */
.emsc-results-tabs {
    margin-bottom: 0;
}

.emsc-tab-count {
    font-weight: 400;
    color: #50575e;
    font-size: 12px;
    margin-left: 2px;
}

/* --------------------------------------------------------------------------
   Grid toolbar (select all / none)
   -------------------------------------------------------------------------- */
.emsc-grid-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.emsc-non-image-note {
    font-size: 12px;
    color: #787c82;
    margin-left: auto;
}

/* --------------------------------------------------------------------------
   Card grid
   -------------------------------------------------------------------------- */
.emsc-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 4px 0 24px;
}

.emsc-empty {
    color: #50575e;
    font-style: italic;
    grid-column: 1 / -1;
}

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.emsc-card {
    background: #fff;
    border: 2px solid #c3c4c7;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    cursor: default;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.emsc-card-unused {
    cursor: pointer;
}

.emsc-card-unused:hover {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Selected state */
.emsc-card-selected {
    border-color: #2271b1 !important;
    box-shadow: 0 0 0 1px #2271b1 !important;
    background: #f0f6fc;
}

/* Checkbox — hidden visually, still accessible */
.emsc-card-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    opacity: 0; /* Hidden — selection shown via overlay and border instead */
    pointer-events: auto;
}

/* Selected overlay — large checkmark in top-right corner */
.emsc-card-selected-overlay {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    background: #2271b1;
    border-bottom-left-radius: 3px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.emsc-card-selected .emsc-card-selected-overlay {
    display: flex;
}

.emsc-card-selected-overlay .dashicons {
    color: #fff;
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* --------------------------------------------------------------------------
   Card thumbnail
   -------------------------------------------------------------------------- */
.emsc-card-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f6f7f7;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid #f0f0f1;
    position: relative;
}

.emsc-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Used-tab thumbnails open the lightbox directly, so they get the zoom cursor. */
.emsc-card-used .emsc-card-thumb img {
    cursor: zoom-in;
}

/* Unused-tab thumbnails are part of the selection target — no cursor change,
   since clicking them selects the card. The zoom trigger button handles preview. */
.emsc-zoom-trigger {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    padding: 0;
}

.emsc-zoom-trigger:hover {
    background: rgba(0, 0, 0, 0.75);
}

.emsc-zoom-trigger .dashicons {
    color: #fff;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.emsc-file-icon {
    font-size: 40px !important;
    width: 40px !important;
    height: 40px !important;
    color: #787c82;
}

/* --------------------------------------------------------------------------
   Card meta
   -------------------------------------------------------------------------- */
.emsc-card-meta {
    padding: 10px 12px 12px;
}

.emsc-card-filename {
    font-size: 12px;
    font-weight: 600;
    color: #1d2327;
    margin: 0 0 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.emsc-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.emsc-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.5;
}

.emsc-tag-type {
    background: #f0f0f1;
    color: #50575e;
}

.emsc-tag-size {
    background: #f0f6fc;
    color: #2271b1;
}

.emsc-tag-dims {
    background: #f6f7f7;
    color: #50575e;
}

.emsc-tag-date {
    background: #f6f7f7;
    color: #787c82;
    font-weight: 400;
    text-transform: none;
}

/* --------------------------------------------------------------------------
   Used tab — reference list
   -------------------------------------------------------------------------- */
.emsc-card-used {
    cursor: default;
}

.emsc-card-refs {
    margin-top: 10px;
    border-top: 1px solid #f0f0f1;
    padding-top: 8px;
}

.emsc-refs-label {
    font-size: 11px;
    font-weight: 600;
    color: #50575e;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 4px;
}

.emsc-refs-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.emsc-ref-item {
    font-size: 12px;
    padding: 3px 0;
    border-bottom: 1px solid #f6f7f7;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex-wrap: wrap;
}

.emsc-ref-item:last-child {
    border-bottom: none;
}

.emsc-ref-item a {
    color: #2271b1;
    text-decoration: none;
}

.emsc-ref-item a:hover {
    text-decoration: underline;
}

.emsc-tag-reftype {
    background: #f0f0f1;
    color: #50575e;
    flex-shrink: 0;
}

.emsc-refs-toggle {
    display: inline-block;
    margin-top: 6px;
    background: none;
    border: none;
    padding: 0;
    color: #2271b1;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
}

.emsc-refs-toggle:hover {
    color: #135e96;
}

/* Revisions shown italicised */
.emsc-ref-type-revision .emsc-ref-item {
    color: #787c82;
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Sticky selection bar
   -------------------------------------------------------------------------- */
#emsc-selection-bar {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: #fff;
    border-top: 2px solid #2271b1;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    margin: 0 -20px;               /* bleed to edge of .wrap padding */
    padding: 0 20px;
}

.emsc-selection-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 0;
    max-width: 1400px;
}

.emsc-sel-summary {
    font-size: 14px;
    color: #1d2327;
}

.emsc-sel-summary strong {
    color: #2271b1;
}

.emsc-selection-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.emsc-perm-label {
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   Selection bar — deleting state
   -------------------------------------------------------------------------- */
@keyframes emsc-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.emsc-spin {
    display: inline-block;
    animation: emsc-spin 1s linear infinite;
}

/* --------------------------------------------------------------------------
   Selection bar — completed state
   -------------------------------------------------------------------------- */
.emsc-bar-complete {
    border-top-color: #00a32a;
}

.emsc-complete-icon {
    color: #00a32a;
    vertical-align: middle;
    margin-right: 4px;
}

.emsc-complete-summary {
    font-size: 14px;
    color: #1d2327;
}

.emsc-complete-errors {
    color: #d63638;
}

/* --------------------------------------------------------------------------
   Confirm modal
   -------------------------------------------------------------------------- */
.emsc-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

body.emsc-modal-open {
    overflow: hidden;
}

.emsc-modal {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
    max-width: 480px;
    width: 100%;
    overflow: hidden;
}

.emsc-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f0f0f1;
}

.emsc-modal-icon {
    font-size: 24px !important;
    width: 24px !important;
    height: 24px !important;
    color: #d63638;
    flex-shrink: 0;
}

.emsc-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.emsc-modal-body {
    padding: 16px 24px;
}

.emsc-modal-body p {
    margin: 0 0 12px;
    font-size: 14px;
    color: #1d2327;
    line-height: 1.5;
}

.emsc-modal-body p:last-child {
    margin-bottom: 0;
}

.emsc-modal-warning {
    background: #fcf0f1;
    border-left: 3px solid #d63638;
    padding: 10px 14px !important;
    border-radius: 0 3px 3px 0;
    font-size: 13px !important;
    color: #50575e !important;
}

.emsc-modal-warning strong {
    color: #d63638;
    display: block;
    margin-bottom: 2px;
}

.emsc-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #f0f0f1;
    background: #f6f7f7;
}

.emsc-modal-confirm-btn {
    background: #d63638 !important;
    border-color: #b02a2c !important;
}

.emsc-modal-confirm-btn:hover {
    background: #b02a2c !important;
    border-color: #8f2123 !important;
}

/* --------------------------------------------------------------------------
   Completion modal (green success variant)
   -------------------------------------------------------------------------- */
.emsc-modal-header-success {
    border-bottom-color: #d7f0da;
    background: #f0fdf1;
}

.emsc-modal-icon-success {
    font-size: 24px !important;
    width: 24px !important;
    height: 24px !important;
    color: #00a32a;
    flex-shrink: 0;
}

.emsc-modal-footer-center {
    justify-content: center;
}

.emsc-completion-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px !important;
    font-weight: 600;
    color: #1d2327;
    margin-bottom: 8px !important;
}

.emsc-completion-count .dashicons {
    color: #00a32a;
    font-size: 22px !important;
    width: 22px !important;
    height: 22px !important;
    flex-shrink: 0;
}

.emsc-completion-errors {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px !important;
    color: #d63638;
    margin-top: 8px !important;
}

.emsc-completion-errors .dashicons {
    flex-shrink: 0;
}

.emsc-completion-note {
    font-size: 12px !important;
    color: #787c82;
    margin-top: 10px !important;
    padding-top: 10px !important;
    border-top: 1px solid #f0f0f1;
}

/* --------------------------------------------------------------------------
   Image preview lightbox
   -------------------------------------------------------------------------- */
.emsc-lightbox-overlay {
    background: rgba(0, 0, 0, 0.85);
    cursor: zoom-out;
}

.emsc-lightbox-box {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: default;
}

.emsc-lightbox-box img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 3px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.emsc-lightbox-filename {
    color: #fff;
    font-size: 13px;
    margin: 12px 0 0;
    text-align: center;
}

.emsc-lightbox-close {
    position: absolute;
    top: -40px;
    right: -8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
}

.emsc-lightbox-close .dashicons {
    color: #fff;
    font-size: 28px;
    width: 28px;
    height: 28px;
}

.emsc-lightbox-close:hover .dashicons {
    color: #c3c4c7;
}

/* --------------------------------------------------------------------------
   Info tab
   -------------------------------------------------------------------------- */
.emsc-info-wrap {
    max-width: 900px;
    padding-top: 8px;
}

.emsc-info-wrap h3 {
    margin-bottom: 16px;
}

.emsc-info-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.emsc-info-stat-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.emsc-info-stat-icon {
    font-size: 28px !important;
    width: 28px !important;
    height: 28px !important;
    color: #2271b1;
    flex-shrink: 0;
}

.emsc-info-stat-icon--yes { color: #00a32a; }
.emsc-info-stat-icon--no  { color: #d63638; }

.emsc-info-stat-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.emsc-info-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #1d2327;
    line-height: 1.2;
}

.emsc-info-stat-label {
    font-size: 12px;
    color: #50575e;
    line-height: 1.3;
}

.emsc-info-notice {
    margin-bottom: 20px !important;
}

.emsc-info-notice code {
    display: inline-block;
    margin-top: 6px;
    background: #f0f0f1;
    padding: 3px 8px;
    border-radius: 2px;
    font-size: 12px;
}

.emsc-info-section {
    margin-bottom: 28px;
}

.emsc-info-section h4 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
}

.emsc-info-table {
    width: 100%;
}

.emsc-info-key {
    width: 240px;
    font-weight: 600;
    color: #1d2327;
}

.emsc-info-yes { color: #00a32a; font-weight: 600; }
.emsc-info-no  { color: #d63638; font-weight: 600; }
.emsc-log-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.emsc-log-header-actions {
    flex-shrink: 0;
    padding-top: 4px;
}

.emsc-log-session-title {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.emsc-log-session-meta {
    font-size: 12px;
    color: #787c82;
    font-weight: 400;
}

.emsc-log-session-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.emsc-tag-log-success {
    background: #edfaef;
    color: #00a32a;
    text-transform: none;
    font-weight: 600;
}

.emsc-tag-log-error {
    background: #fcf0f1;
    color: #d63638;
    text-transform: none;
    font-weight: 600;
}

.emsc-log-stat-neutral {
    color: #50575e;
}

/* --------------------------------------------------------------------------
   Log tab
   -------------------------------------------------------------------------- */
.emsc-log-tab-wrap {
    max-width: 900px;
    padding-top: 8px;
}

.emsc-log-tab-header {
    margin-bottom: 20px;
}

.emsc-log-tab-header h3 {
    margin-bottom: 4px;
}

.emsc-log-tab-empty {
    text-align: center;
    padding: 48px 24px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    color: #50575e;
}

.emsc-log-empty-icon {
    font-size: 40px !important;
    width: 40px !important;
    height: 40px !important;
    color: #c3c4c7;
    display: block;
    margin: 0 auto 12px;
}

.emsc-log-tab-summary {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
}

.emsc-log-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
}

.emsc-log-stat .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.emsc-log-stat-success { color: #00a32a; }
.emsc-log-stat-error   { color: #d63638; }

.emsc-log-sessions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.emsc-log-session {
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    overflow: hidden;
}

.emsc-log-session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f6f7f7;
    border-bottom: 1px solid #c3c4c7;
    padding: 10px 14px;
    font-size: 13px;
    gap: 12px;
    flex-wrap: wrap;
}

.emsc-log-body {
    background: #1d2327;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px 14px;
}

.emsc-log-list {
    margin: 0;
    padding: 0;
    list-style: none;
    font-family: Consolas, "Courier New", monospace;
    font-size: 12px;
    line-height: 1.7;
}

.emsc-log-item          { color: #c3c4c7; }
.emsc-log-item.emsc-log-success { color: #68de7c; }
.emsc-log-item.emsc-log-error   { color: #f86368; }
.emsc-log-item.emsc-log-warning { color: #f0c33c; }
.emsc-log-item.emsc-log-info    { color: #72aee6; }

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.emsc-pagination-slot {
    margin: 4px 0;
}

.emsc-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
}

.emsc-pagination-summary {
    font-size: 12px;
    color: #50575e;
    flex-shrink: 0;
}

.emsc-pagination-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.emsc-page-btn {
    min-width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    color: #2271b1;
    font-size: 13px;
    cursor: pointer;
    padding: 0 6px;
}

.emsc-page-btn:hover:not(:disabled) {
    border-color: #2271b1;
    background: #f0f6fc;
}

.emsc-page-btn:disabled {
    color: #c3c4c7;
    cursor: not-allowed;
}

.emsc-page-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.emsc-page-current {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    font-weight: 600;
}

.emsc-page-ellipsis {
    color: #787c82;
    padding: 0 4px;
    font-size: 13px;
}

.emsc-cross-page-links {
    margin-left: 12px;
    white-space: nowrap;
}

.emsc-select-all-pages-link,
.emsc-deselect-all-pages-link {
    font-size: 12px;
    color: #2271b1;
    text-decoration: underline;
    white-space: nowrap;
}

.emsc-deselect-all-pages-link {
    margin-left: 10px;
}

.emsc-select-all-pages-link:hover,
.emsc-deselect-all-pages-link:hover {
    color: #135e96;
}

@media screen and (max-width: 960px) {
    .emsc-card-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
}

@media screen and (max-width: 600px) {
    .emsc-pagination {
        flex-direction: column;
        align-items: flex-start;
    }

    .emsc-cross-page-links {
        margin-left: 0;
    }

    .emsc-card-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #emsc-selection-bar {
        margin: 0 -10px;
        padding: 0 10px;
    }
}
