/* =========================================================
   Admin area
   ========================================================= */

/* ----------------------------- Каркас ----------------------------- */

.admin-shell {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
}

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;

    width: var(--admin-sidebar-width);

    display: flex;
    flex-direction: column;

    background: var(--color-dark);
    color: #fff;
}

.admin-main {
    width: calc(100% - var(--admin-sidebar-width));
    min-height: 100vh;
    margin-left: var(--admin-sidebar-width);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);

    padding: 20px var(--space-5);

    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.admin-brand-logo {
    display: grid;
    place-items: center;

    width: 40px;
    height: 40px;

    border-radius: var(--radius-md);

    background: var(--color-brand);
    color: var(--color-dark);

    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 800;
}

.admin-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-brand-text strong {
    font-size: 14px;
    font-weight: 700;
}

.admin-brand-text span {
    margin-top: 1px;
    color: var(--color-subtle);
    font-size: 11.5px;
}

.admin-navigation {
    flex: 1;
    padding: var(--space-4) var(--space-3);
}

.admin-nav-section {
    margin: var(--space-5) var(--space-2) var(--space-2);
    color: #6b7280;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);

    margin-bottom: 3px;
    padding: 10px 12px;

    border-radius: var(--radius-sm);

    color: #cbd5e1;
    font-size: 14px;
    text-decoration: none;

    transition:
        background var(--transition-fast),
        color var(--transition-fast);
}

.admin-nav-item:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.admin-nav-item.active {
    background: rgba(82, 196, 26, .14);
    color: #fff;
    box-shadow: inset 2px 0 0 var(--color-brand);
}

.admin-nav-icon {
    width: 20px;
    color: var(--color-brand);
    font-size: 16px;
    text-align: center;
}

.admin-sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--space-3);
}

.admin-user-avatar {
    display: grid;
    place-items: center;

    width: 34px;
    height: 34px;

    border-radius: 50%;

    background: #374151;
    color: #fff;

    font-size: 12px;
    font-weight: 700;
}

.admin-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-user-info strong {
    overflow: hidden;
    color: #fff;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-user-info span {
    color: var(--color-subtle);
    font-size: 11px;
}

.admin-logout {
    width: 100%;
    min-height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    border: 1px solid #374151;
    border-radius: var(--radius-sm);

    background: transparent;
    color: #d1d5db;

    font-size: 13px;
    cursor: pointer;

    transition:
        background var(--transition-fast),
        color var(--transition-fast);
}

.admin-logout:hover {
    background: #1f2937;
    color: #fff;
}

.admin-header {
    min-height: 56px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);

    padding: 12px var(--space-7);

    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.admin-header .admin-breadcrumb {
    margin: 0;
    color: var(--color-muted);
    font-size: 13px;
}

.admin-header .admin-breadcrumb span {
    margin: 0 6px;
    color: var(--color-border-strong);
}

.admin-content {
    padding: var(--space-7);
}

/* ----------------------------- Логин ----------------------------- */

.login-page {
    position: relative;

    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: var(--space-6);

    background:
        radial-gradient(circle at 10% 0%, rgba(82, 196, 26, .16), transparent 38%),
        radial-gradient(circle at 90% 100%, rgba(31, 41, 55, .16), transparent 42%),
        var(--color-bg);
}

.login-background {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.login-decoration {
    position: absolute;
    border-radius: 50%;
    filter: blur(10px);
    opacity: .6;
}

.login-decoration-one {
    top: -120px;
    right: -80px;
    width: 340px;
    height: 340px;
    background: rgba(82, 196, 26, .18);
}

.login-decoration-two {
    bottom: -140px;
    left: -100px;
    width: 380px;
    height: 380px;
    background: rgba(31, 41, 55, .14);
}

.login-card {
    position: relative;
    z-index: 1;

    width: 100%;
    max-width: 430px;
    padding: var(--space-8);

    border: 1px solid rgba(255, 255, 255, .8);
    border-radius: var(--radius-lg);

    background: rgba(255, 255, 255, .96);

    box-shadow: var(--shadow-lg);
}

.login-logo {
    display: grid;
    place-items: center;

    width: 50px;
    height: 50px;
    margin-bottom: var(--space-5);

    border-radius: var(--radius-md);

    background: var(--color-brand-strong);
    color: #fff;

    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 800;
}

.login-header {
    margin-bottom: var(--space-6);
}

.login-header h1 {
    margin: 0 0 7px;
    font-size: 27px;
}

.login-header p {
    margin: 0;
    color: var(--color-muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.login-button {
    min-height: var(--control-height-lg);

    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-top: 4px;
    padding: 0 var(--space-4);

    border: 0;
    border-radius: var(--radius-sm);

    background: var(--color-brand-strong);
    color: #fff;

    font-weight: 700;
    cursor: pointer;
}

.login-button:hover {
    background: var(--color-brand-hover);
}

.login-footer {
    margin-top: var(--space-5);
    color: var(--color-subtle);
    font-size: 11px;
    text-align: center;
}

/* ----------------------------- Медиатека ----------------------------- */

.photo-library {
    position: relative;
}

.photo-count {
    margin-top: 5px;
    color: var(--color-muted);
    font-size: 13px;
}

.photo-count span {
    margin-left: 4px;
    color: var(--color-subtle);
}

.upload-button {
    position: relative;
    overflow: hidden;
}

.upload-button input {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    opacity: 0;
    cursor: pointer;
}

.upload-button input:disabled {
    cursor: default;
}

.upload-button-icon {
    font-size: 17px;
    line-height: 1;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: var(--space-4);
}

.photo-card {
    overflow: hidden;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);

    background: var(--color-surface);

    cursor: pointer;
    transition:
        transform var(--transition-fast),
        box-shadow var(--transition-fast),
        border-color var(--transition-fast);
}

.photo-card:hover {
    border-color: var(--color-border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.photo-card.selected {
    border-color: var(--color-brand-strong);
    box-shadow: 0 0 0 2px var(--color-brand-ring);
}

.photo-card:focus-visible {
    outline: 2px solid var(--color-brand-strong);
    outline-offset: 2px;
}

.photo-preview {
    position: relative;
    aspect-ratio: 1;
    background: var(--color-surface-3);
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-select {
    position: absolute;
    z-index: 2;
    top: 9px;
    left: 9px;

    display: grid;
    place-items: center;

    width: 30px;
    height: 30px;

    border-radius: var(--radius-xs);

    background: rgba(255, 255, 255, .95);
    box-shadow: var(--shadow-xs);
}

.photo-badge {
    position: absolute;
    top: 9px;
    right: 9px;

    max-width: calc(100% - 52px);
    overflow: hidden;

    padding: 4px 8px;

    border-radius: var(--radius-xs);

    background: rgba(255, 255, 255, .95);
    box-shadow: var(--shadow-xs);

    font-size: 11px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-badge.free {
    color: var(--color-success);
}

.photo-badge.attached {
    color: var(--color-info);
}

.photo-badge.main {
    top: auto;
    right: auto;
    bottom: 9px;
    left: 9px;
    color: var(--color-brand-hover);
}

.photo-info {
    padding: 10px 11px;
}

.photo-name {
    overflow: hidden;

    color: var(--color-ink);
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-meta {
    display: flex;
    justify-content: space-between;
    gap: var(--space-2);

    margin-top: 4px;

    color: var(--color-muted);
    font-size: 11px;
}

.selection-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-4);

    margin-bottom: var(--space-4);
    padding: 10px 14px;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);

    background: var(--color-surface);
}

.selection-info {
    margin-left: auto;
    color: var(--color-muted);
    font-size: 13px;
}

.load-more {
    display: flex;
    justify-content: center;
    margin-top: var(--space-6);
}

.drop-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-editor);

    display: grid;
    place-items: center;

    padding: var(--space-6);

    background: rgba(17, 24, 39, .55);
    backdrop-filter: blur(3px);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity var(--transition-fast),
        visibility var(--transition-fast);
}

.photo-library.is-dragging .drop-overlay {
    opacity: 1;
    visibility: visible;
}

.drop-overlay-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;

    width: min(460px, 100%);
    padding: var(--space-9);

    border: 2px dashed var(--color-brand);
    border-radius: var(--radius-lg);

    background: var(--color-surface);
    color: var(--color-text);

    text-align: center;
    box-shadow: var(--shadow-lg);
}

.drop-overlay-icon {
    margin-bottom: 4px;
    color: var(--color-brand-strong);
    font-size: 42px;
    line-height: 1;
}

.drop-overlay-inner strong {
    color: var(--color-ink);
    font-family: var(--font-heading);
    font-size: 20px;
}

.drop-overlay-inner span {
    color: var(--color-muted);
    font-size: 13px;
}

/* ----------------------------- Редактор фото ----------------------------- */

.photo-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-editor);

    display: flex;
    align-items: center;
    justify-content: center;

    padding: var(--space-5);

    background: rgba(8, 10, 14, .78);
}

.photo-editor {
    width: min(1280px, 100%);
    max-height: calc(100vh - 40px);

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
}

.photo-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);

    padding: 14px var(--space-5);

    border-bottom: 1px solid var(--color-border);
}

.photo-editor-title {
    min-width: 0;
}

.photo-editor-title h3 {
    overflow: hidden;

    margin: 0;

    font-size: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-editor-subtitle {
    display: flex;
    gap: 6px;

    margin-top: 2px;

    color: var(--color-muted);
    font-size: 12px;
}

.photo-editor-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.header-divider {
    width: 1px;
    height: 22px;
    margin: 0 6px;
    background: var(--color-border);
}

.photo-editor-body {
    min-height: 0;

    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;

    flex: 1;
    overflow: hidden;
}

.photo-editor-workspace {
    min-width: 0;

    display: flex;
    flex-direction: column;
    gap: var(--space-3);

    padding: var(--space-4);
}

.photo-editor-stage {
    position: relative;

    height: clamp(320px, 52vh, 580px);
    overflow: hidden;

    border-radius: var(--radius-md);

    background-color: #e9ebee;
    background-image:
        linear-gradient(45deg, #d7dade 25%, transparent 25%),
        linear-gradient(-45deg, #d7dade 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d7dade 75%),
        linear-gradient(-45deg, transparent 75%, #d7dade 75%);
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    background-size: 24px 24px;

    user-select: none;
    touch-action: none;
}

.photo-editor-stage > img {
    position: absolute;
    top: 50%;
    left: 50%;

    max-width: none;
    max-height: none;

    transform: translate(-50%, -50%);

    pointer-events: none;
    user-select: none;
}

.photo-editor-crop {
    position: absolute;

    display: none;

    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, .56);

    cursor: move;
    touch-action: none;
}

.photo-editor-crop::after {
    content: "";

    position: absolute;
    inset: 0;

    border: 1px solid rgba(0, 0, 0, .25);
    pointer-events: none;
}

.crop-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.crop-grid span {
    position: absolute;
    background: rgba(255, 255, 255, .55);
}

.crop-grid span:nth-child(1) {
    top: 0;
    bottom: 0;
    left: 33.333%;
    width: 1px;
}

.crop-grid span:nth-child(2) {
    top: 0;
    bottom: 0;
    left: 66.666%;
    width: 1px;
}

.crop-grid span:nth-child(3) {
    top: 33.333%;
    right: 0;
    left: 0;
    height: 1px;
}

.crop-grid span:nth-child(4) {
    top: 66.666%;
    right: 0;
    left: 0;
    height: 1px;
}

.crop-handle {
    position: absolute;

    width: 16px;
    height: 16px;
    padding: 0;

    border: 2px solid #fff;
    border-radius: 50%;

    background: var(--color-brand);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .4);

    touch-action: none;
}

.crop-handle.nw { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-handle.ne { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }

.stage-hint {
    position: absolute;
    bottom: 10px;
    left: 50%;

    padding: 4px 10px;

    border-radius: var(--radius-full);

    background: rgba(17, 24, 39, .55);
    color: rgba(255, 255, 255, .9);

    font-size: 11px;
    white-space: nowrap;

    transform: translateX(-50%);
    pointer-events: none;
}

.photo-editor-tools {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-5);
}

.tool-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.tool-label {
    margin-right: 2px;
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 600;
}

.tool-zoom input[type="range"] {
    width: 130px;
    accent-color: var(--color-brand-strong);
}

.range-value {
    min-width: 44px;
    color: var(--color-muted);
    font-size: 12px;
    text-align: right;
}

.aspect-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.dimension-separator {
    color: var(--color-subtle);
    font-size: 13px;
}

.photo-editor-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);

    overflow-y: auto;

    padding: var(--space-5);

    border-left: 1px solid var(--color-border);
    background: var(--color-surface-2);
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.sidebar-info {
    gap: var(--space-2);

    padding: var(--space-3);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);

    background: var(--color-surface);
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);

    color: var(--color-muted);
    font-size: 12.5px;
}

.info-row strong {
    color: var(--color-ink);
    font-weight: 600;
    white-space: nowrap;
}

.main-photo-note {
    padding: 8px 10px;

    border-radius: var(--radius-xs);

    background: var(--color-brand-soft);
    color: var(--color-brand-hover);

    font-size: 12.5px;
    font-weight: 600;
}

.photo-editor-sidebar .admin-alert {
    margin-bottom: 0;
}

.photo-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);

    padding: 12px var(--space-5);

    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.photo-editor-footer-left,
.photo-editor-footer-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.shortcut-hint {
    margin-right: var(--space-2);
    color: var(--color-subtle);
    font-size: 11.5px;
}

/* ----------------------------- Адаптив ----------------------------- */

@media (max-width: 1100px) {
    .photo-editor-body {
        grid-template-columns: minmax(0, 1fr) 290px;
    }

    .photo-editor-tools {
        gap: var(--space-3);
    }
}

@media (max-width: 900px) {
    .admin-sidebar {
        width: 220px;
    }

    .admin-main {
        width: calc(100% - 220px);
        margin-left: 220px;
    }

    .admin-content {
        padding: var(--space-5);
    }

    .photo-editor-body {
        grid-template-columns: minmax(0, 1fr);
        overflow-x: hidden;
        overflow-y: auto;
    }

    .photo-editor-workspace,
    .photo-editor-sidebar {
        min-width: 0;
    }

    .photo-editor-sidebar {
        overflow: visible;
        border-top: 1px solid var(--color-border);
        border-left: 0;
    }
}

@media (max-width: 700px) {
    .admin-shell {
        flex-direction: column;
    }

    .admin-sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .admin-brand {
        padding: 12px 16px;
    }

    .admin-brand-logo {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .admin-main {
        width: 100%;
        margin-left: 0;
    }

    .admin-sidebar-footer {
        display: flex;
        align-items: center;
        gap: var(--space-3);

        padding: 10px 12px;
    }

    .admin-user {
        flex: 1;
        margin-bottom: 0;
    }

    .admin-logout {
        width: auto;
        padding: 0 14px;
    }

    .admin-navigation {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: var(--space-2);
    }

    .admin-nav-section {
        display: none;
    }

    .admin-nav-item {
        flex: 1 1 0;
        justify-content: center;

        margin-bottom: 0;
        padding: 8px;
        gap: 6px;

        font-size: 12.5px;
        white-space: nowrap;
    }

    .admin-nav-icon {
        width: 16px;
        font-size: 14px;
    }

    .admin-header {
        padding: 14px var(--space-4);
    }

    .admin-content {
        padding: var(--space-4);
    }

    .login-card {
        padding: var(--space-6) var(--space-5);
    }

    .photo-editor-overlay {
        padding: 0;
    }

    .photo-editor {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .photo-editor-stage {
        height: 42vh;
    }

    .photo-editor-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .photo-editor-footer-right {
        justify-content: flex-end;
    }

    .shortcut-hint {
        display: none;
    }

    .selection-info {
        width: 100%;
        margin-left: 0;
    }
}


/* ----------------------------- Выбор материалов фото ----------------------------- */

.material-picker {
    display: flex;
    flex-direction: column;
    gap: 4px;

    max-height: 220px;
    overflow-y: auto;

    padding: 6px;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);

    background: var(--color-surface);
}

.material-option {
    display: flex;
    align-items: center;
    gap: 8px;

    padding: 6px 8px;

    border-radius: var(--radius-xs);

    color: var(--color-text);
    font-size: 13px;

    cursor: pointer;
}

.material-option:hover {
    background: var(--color-surface-3);
}

.material-option input {
    accent-color: var(--color-brand-strong);
}

.material-option span:first-of-type {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.material-star {
    margin-left: auto;
    color: var(--color-brand-strong);
    font-size: 13px;
}
