/**
 * Media Library - picker modal + library page.
 *
 * Deliberately plain CSS in its own file rather than a sass partial:
 * looksomething.min.css is a build artefact (`npm run watch` in assets/css),
 * so editing the sass would leave the compiled stylesheet stale until someone
 * runs the build. This file is enqueued directly and needs no build step.
 *
 * Colour values mirror assets/css/sass/abstracts/variables/_colors.scss.
 */

:root {
   --ls-main-blue: #5258F6;
   --ls-dark-blue: #393FDE;
   --ls-typography: #2D2D2D;
   --ls-border-color: #CBD5E1;
   --ls-gray-1: #F1F2F6;
   --ls-gray-2: #F9FAFF;
   --ls-gray-3: #979797;
   --ls-gray-bg: #F1F5F9;
   --ls-error: #CF0000;
   --ls-success: #0D7B0D;
}

/* ---------------------------------------------------------------------------
 * Modal shell
 * ------------------------------------------------------------------------ */

body.ls-media-modal-open {
   overflow: hidden;
}

.ls-media-modal {
   display: none;
   position: fixed;
   inset: 0;
   z-index: 10000;
}

.ls-media-modal.active {
   display: block;
}

.ls-media-modal-backdrop {
   position: absolute;
   inset: 0;
   background: rgba(45, 45, 45, .55);
}

.ls-media-modal-dialog {
   position: relative;
   z-index: 1;
   display: flex;
   flex-direction: column;
   width: min(1100px, calc(100vw - 48px));
   height: min(760px, calc(100vh - 48px));
   margin: 24px auto;
   background: #fff;
   border-radius: 4px;
   box-shadow: 0 12px 40px rgba(45, 45, 45, .25);
   overflow: hidden;
}

.ls-media-modal-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: 18px 24px;
   border-bottom: 1px solid var(--ls-border-color);
}

.ls-media-modal-header .title {
   font-size: 18px;
   font-weight: 600;
   color: var(--ls-typography);
}

.ls-media-close {
   cursor: pointer;
   line-height: 0;
   opacity: .6;
   transition: opacity .2s ease;
}

.ls-media-close:hover {
   opacity: 1;
}

.ls-media-close img {
   width: 16px;
   height: 16px;
}

/* Tabs ------------------------------------------------------------------- */

.ls-media-modal-tabs {
   display: flex;
   gap: 4px;
   padding: 0 24px;
   border-bottom: 1px solid var(--ls-border-color);
   background: var(--ls-gray-2);
}

.ls-media-tab {
   padding: 14px 18px;
   font-size: 14px;
   color: var(--ls-gray-3);
   cursor: pointer;
   border-bottom: 2px solid transparent;
   transition: all .2s ease;
   white-space: nowrap;
}

.ls-media-tab:hover {
   color: var(--ls-typography);
}

.ls-media-tab.active {
   color: var(--ls-main-blue);
   border-bottom-color: var(--ls-main-blue);
   font-weight: 600;
}

/* Panels ----------------------------------------------------------------- */

.ls-media-modal-body {
   flex: 1;
   min-height: 0;
   display: flex;
}

.ls-media-panel {
   display: none;
   flex: 1;
   min-height: 0;
   flex-direction: column;
}

.ls-media-panel.active {
   display: flex;
}

.ls-media-toolbar {
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 16px;
   padding: 16px 24px;
   border-bottom: 1px solid var(--ls-gray-1);
}

.ls-media-toolbar .ls-component {
   margin: 0;
   flex: 1;
   max-width: 340px;
}

.ls-media-toolbar .ls-input {
   width: 100%;
   padding: 10px 14px;
   border: 1px solid var(--ls-border-color);
   border-radius: 2px;
   font-size: 14px;
}

.ls-media-count {
   font-size: 13px;
   color: var(--ls-gray-3);
   white-space: nowrap;
}

/* Grid ------------------------------------------------------------------- */

.ls-media-grid {
   flex: 1;
   min-height: 0;
   overflow-y: auto;
   display: grid;
   grid-template-columns: repeat(5, minmax(0, 1fr));
   gap: 16px;
   padding: 24px;
   align-content: start;
}

.ls-media-item {
   border: 2px solid transparent;
   border-radius: 3px;
   overflow: hidden;
   background: var(--ls-gray-bg);
   cursor: default;
   transition: border-color .15s ease, box-shadow .15s ease;
   height: 200px;
   display: flex;
   flex-direction: column;
}

.ls-media-item.selectable {
   cursor: pointer;
}

.ls-media-item:focus-visible {
   outline: none;
   border-color: var(--ls-main-blue);
}

.ls-media-item.selectable:hover {
   box-shadow: 0 2px 10px rgba(45, 45, 45, .14);
}

.ls-media-item.selected {
   border-color: var(--ls-main-blue);
   box-shadow: 0 0 0 3px rgba(82, 88, 246, .18);
}

.ls-media-item .thumb {
   position: relative;
   aspect-ratio: 1 / 1;
   display: flex;
   align-items: center;
   justify-content: center;
   background: #fff;
   overflow: hidden;
}

.ls-media-item .thumb img {
   max-width: 100%;
   max-height: 100%;
   object-fit: contain;
}

.ls-media-item .check {
   position: absolute;
   top: 6px;
   right: 6px;
   width: 20px;
   height: 20px;
   border-radius: 50%;
   background: var(--ls-main-blue);
   display: none;
}

.ls-media-item .check::after {
   content: "";
   position: absolute;
   left: 7px;
   top: 3px;
   width: 5px;
   height: 10px;
   border: solid #fff;
   border-width: 0 2px 2px 0;
   transform: rotate(45deg);
}

.ls-media-item.selected .check {
   display: block;
}

.ls-media-item .meta {
   padding: 8px 10px;
   background: #fff;
   border-top: 1px solid var(--ls-gray-1);
}

.ls-media-item .meta .name {
   font-size: 12px;
   color: var(--ls-typography);
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
}

.ls-media-item .meta .dims {
   font-size: 11px;
   color: var(--ls-gray-3);
   margin-top: 2px;
}

.ls-media-grid-footer {
   padding: 0 24px 16px;
}

.ls-media-grid-footer .ls-button-container {
   justify-content: center;
}

/* Empty / loading / error ------------------------------------------------ */

.ls-media-empty,
.ls-media-error,
.ls-media-loader {
   grid-column: 1 / -1;
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   gap: 8px;
   padding: 48px 24px;
   text-align: center;
}

.ls-media-empty .img-container img {
   width: 80px;
   opacity: .45;
}

.ls-media-empty .title {
   font-size: 16px;
   font-weight: 600;
   color: var(--ls-typography);
}

.ls-media-empty .text {
   font-size: 13px;
   color: var(--ls-gray-3);
}

.ls-media-error {
   color: var(--ls-error);
   font-size: 14px;
}

/* Dropzone --------------------------------------------------------------- */

.ls-media-dropzone {
   flex: 1;
   min-height: 0;
   display: flex;
   align-items: center;
   justify-content: center;
   margin: 24px;
   border: 2px dashed var(--ls-border-color);
   border-radius: 4px;
   background: var(--ls-gray-2);
   transition: all .2s ease;
}

.ls-media-dropzone.dragging {
   border-color: var(--ls-main-blue);
   background: rgba(82, 88, 246, .06);
}

.ls-media-dropzone-inner {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 10px;
   text-align: center;
}

.ls-media-dropzone-inner .icon img {
   width: 40px;
   opacity: .5;
}

.ls-media-dropzone-inner .title {
   font-size: 18px;
   font-weight: 600;
   color: var(--ls-typography);
}

.ls-media-dropzone-inner .text {
   font-size: 13px;
   color: var(--ls-gray-3);
}

.ls-media-dropzone-inner .hint {
   font-size: 12px;
   color: var(--ls-gray-3);
   margin-top: 4px;
}

.ls-media-upload-status {
   padding: 0 24px 16px;
   font-size: 13px;
   min-height: 20px;
}

.ls-media-upload-status.error {
   color: var(--ls-error);
}

.ls-media-upload-status.success {
   color: var(--ls-success);
}

.ls-media-upload-status .uploading {
   display: flex;
   align-items: center;
   gap: 10px;
   color: var(--ls-typography);
}

/* Footer ----------------------------------------------------------------- */

.ls-media-modal-footer {
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 16px;
   padding: 16px 24px;
   border-top: 1px solid var(--ls-border-color);
   background: var(--ls-gray-2);
}

.ls-media-selection-info {
   font-size: 13px;
   color: var(--ls-gray-3);
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

.ls-media-modal-footer .actions {
   display: flex;
   gap: 10px;
   flex-shrink: 0;
}

.ls-media-modal-footer .ls-button.disabled {
   opacity: .45;
   pointer-events: none;
}

/* Local loader, in case the theme loader is not on the page --------------- */

.ls-media-modal .ls-loader,
#media-library .ls-loader {
   width: 22px;
   height: 22px;
   border: 3px solid var(--ls-gray-1);
   border-top-color: var(--ls-main-blue);
   border-radius: 50%;
   animation: ls-media-spin .8s linear infinite;
}

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

/* ---------------------------------------------------------------------------
 * Media Library page
 * ------------------------------------------------------------------------ */

#media-library .ls-media-page-toolbar {
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 16px;
   flex-wrap: wrap;
   margin-bottom: 20px;
}

#media-library .ls-media-page-toolbar .ls-component {
   margin: 0;
   min-width: 280px;
}

#media-library .ls-media-page-grid {
   display: grid;
   grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
   gap: 18px;
   margin-bottom: 24px;
}

#media-library .ls-media-item {
   position: relative;
   background: #fff;
   border: 1px solid var(--ls-border-color);
}

#media-library .ls-media-item .thumb {
   background: var(--ls-gray-bg);
}

#media-library .ls-media-item .check {
   display: none !important;
}

#media-library .ls-media-item .ls-media-actions {
   position: absolute;
   top: 8px;
   right: 8px;
   display: flex;
   gap: 6px;
   opacity: 0;
   transition: opacity .2s ease;
}

#media-library .ls-media-item:hover .ls-media-actions,
#media-library .ls-media-item:focus-within .ls-media-actions {
   opacity: 1;
}

#media-library .ls-media-actions .action {
   width: 28px;
   height: 28px;
   display: flex;
   align-items: center;
   justify-content: center;
   background: #fff;
   border: 1px solid var(--ls-border-color);
   border-radius: 3px;
   cursor: pointer;
   transition: all .2s ease;
}

#media-library .ls-media-actions .action:hover {
   background: var(--ls-gray-1);
}

#media-library .ls-media-actions .action img {
   width: 14px;
   height: 14px;
}

#media-library .ls-media-page-footer {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 10px;
}

#media-library .ls-media-page-count {
   font-size: 13px;
   color: var(--ls-gray-3);
}

/* Field affordance ------------------------------------------------------- */

.ls-media-field .fake-upload.ls-media-open {
   user-select: none;
}

@media (max-width: 782px) {
   .ls-media-modal-dialog {
      width: calc(100vw - 16px);
      height: calc(100vh - 16px);
      margin: 8px auto;
   }

   .ls-media-grid {
      grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
      padding: 16px;
      gap: 12px;
   }

   .ls-media-modal-footer {
      flex-direction: column;
      align-items: stretch;
   }
}