/**
 * Product Designer - front office editor.
 *
 * Three columns on the desktop (tools, stage, properties), stacked on small
 * screens with the tool panels turning into a bottom sheet.
 */

.pd-editor {
    --pd-accent: #2fb5d2;
    --pd-bg: #f6f7fb;
    --pd-panel: #ffffff;
    --pd-border: #e3e6ef;
    --pd-text: #232c3d;
    --pd-muted: #7b8194;

    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 70vh;
    margin: 0 0 2rem;
    background: var(--pd-bg);
    color: var(--pd-text);
    border: 1px solid var(--pd-border);
    border-radius: 8px;
    overflow: hidden;
}

/* ---------------------------------------------------------------- Topbar */

.pd-topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--pd-panel);
    border-bottom: 1px solid var(--pd-border);
}

.pd-topbar-left,
.pd-topbar-center,
.pd-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pd-back {
    color: var(--pd-muted);
    text-decoration: none;
    font-size: 0.875rem;
}

.pd-product-name {
    font-weight: 600;
}

.pd-separator {
    width: 1px;
    height: 20px;
    background: var(--pd-border);
}

.pd-quantity {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-size: 0.875rem;
    color: var(--pd-muted);
}

.pd-quantity input {
    width: 60px;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--pd-border);
    border-radius: 4px;
}

/* ------------------------------------------------------------- Workspace */

.pd-workspace {
    display: flex;
    flex: 1;
    min-height: 0;
}

.pd-sidebar {
    display: flex;
    flex-shrink: 0;
    background: var(--pd-panel);
}

.pd-sidebar-left {
    width: 320px;
    border-right: 1px solid var(--pd-border);
}

.pd-sidebar-right {
    width: 280px;
    flex-direction: column;
    padding: 1rem;
    gap: 1.5rem;
    border-left: 1px solid var(--pd-border);
    overflow-y: auto;
}

.pd-tools {
    display: flex;
    flex-direction: column;
    width: 86px;
    padding: 0.5rem;
    gap: 0.25rem;
    background: #fbfcfe;
    border-right: 1px solid var(--pd-border);
}

.pd-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.6rem 0.25rem;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--pd-muted);
    cursor: pointer;
    font-size: 0.7rem;
}

.pd-tool:hover {
    background: #eef6f9;
}

.pd-tool.pd-tool-active {
    background: var(--pd-accent);
    color: #ffffff;
}

.pd-tool-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.pd-panels {
    flex: 1;
    overflow-y: auto;
}

.pd-panel {
    display: none;
    padding: 1rem;
}

.pd-panel.pd-panel-active {
    display: block;
}

.pd-panel h3,
.pd-panel-block h3 {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pd-muted);
}

.pd-input {
    width: 100%;
    margin-bottom: 0.6rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--pd-border);
    border-radius: 4px;
}

.pd-hint {
    font-size: 0.78rem;
    color: var(--pd-muted);
}

/* ----------------------------------------------------------------- Stage */

.pd-stage {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    padding: 1rem;
    gap: 0.75rem;
}

.pd-view-tabs,
.pd-area-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
}

.pd-view-tab,
.pd-area-tab {
    padding: 0.35rem 0.85rem;
    background: var(--pd-panel);
    border: 1px solid var(--pd-border);
    border-radius: 999px;
    color: var(--pd-muted);
    cursor: pointer;
    font-size: 0.8rem;
}

.pd-view-tab.pd-active,
.pd-area-tab.pd-active {
    background: var(--pd-accent);
    border-color: var(--pd-accent);
    color: #ffffff;
}

.pd-colors {
    display: flex;
    gap: 0.4rem;
}

.pd-color {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--pd-border);
    cursor: pointer;
}

.pd-color.pd-active {
    box-shadow: 0 0 0 2px var(--pd-accent);
}

.pd-canvas-wrapper {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 320px;
    padding: 0.5rem;
    background: var(--pd-panel);
    border: 1px solid var(--pd-border);
    border-radius: 6px;
}

.pd-canvas-wrapper .canvas-container {
    margin: 0 auto;
}

.pd-info {
    margin: 0;
    font-size: 0.8rem;
    color: var(--pd-muted);
}

.pd-info.pd-low-dpi {
    color: #c9333d;
    font-weight: 600;
}

/* ------------------------------------------------------------ Properties */

.pd-object-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.pd-icon-button,
.pd-mini-button {
    min-width: 32px;
    height: 32px;
    padding: 0 0.4rem;
    background: var(--pd-panel);
    border: 1px solid var(--pd-border);
    border-radius: 4px;
    color: var(--pd-text);
    cursor: pointer;
    line-height: 1;
}

.pd-icon-button:hover,
.pd-mini-button:hover {
    border-color: var(--pd-accent);
    color: var(--pd-accent);
}

.pd-icon-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pd-icon-button.pd-danger:hover {
    border-color: #c9333d;
    color: #c9333d;
}

.pd-button-group {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.6rem;
}

.pd-bold {
    font-weight: 700;
}

.pd-italic {
    font-style: italic;
}

.pd-underline {
    text-decoration: underline;
}

.pd-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
}

.pd-field-label {
    width: 44px;
    color: var(--pd-muted);
}

.pd-field input,
.pd-field select {
    flex: 1;
    min-width: 0;
    padding: 0.3rem 0.4rem;
    border: 1px solid var(--pd-border);
    border-radius: 4px;
}

.pd-field-color input {
    height: 32px;
    padding: 2px;
}

.pd-empty {
    font-size: 0.8rem;
    color: var(--pd-muted);
}

/* ---------------------------------------------------------------- Layers */

.pd-layer {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.25rem;
    border: 1px solid transparent;
    border-radius: 4px;
}

.pd-layer.pd-active {
    border-color: var(--pd-accent);
    background: #f0fbfe;
}

.pd-layer-label {
    flex: 1;
    overflow: hidden;
    padding: 0.2rem 0.3rem;
    background: transparent;
    border: 0;
    color: var(--pd-text);
    cursor: pointer;
    font-size: 0.8rem;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pd-layer .pd-icon-button {
    min-width: 24px;
    height: 24px;
    font-size: 0.7rem;
}

/* -------------------------------------------------------------- Cliparts */

.pd-clipart-category {
    margin: 0.75rem 0 0.4rem;
    font-size: 0.78rem;
    color: var(--pd-muted);
}

.pd-clipart-grid,
.pd-shape-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
}

.pd-clipart,
.pd-shape {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    padding: 0.35rem;
    background: var(--pd-panel);
    border: 1px solid var(--pd-border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
}

.pd-clipart:hover,
.pd-shape:hover {
    border-color: var(--pd-accent);
}

.pd-clipart img {
    max-width: 100%;
    max-height: 100%;
}

/* -------------------------------------------------------------- Feedback */

.pd-messages {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.pd-toast {
    max-width: 320px;
    padding: 0.6rem 0.9rem;
    background: #232c3d;
    border-radius: 6px;
    color: #ffffff;
    font-size: 0.82rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    transition: opacity 0.3s ease;
}

.pd-toast-success {
    background: #1f8a5b;
}

.pd-toast-warning {
    background: #b9791c;
}

.pd-toast-error {
    background: #c9333d;
}

.pd-toast-out {
    opacity: 0;
}

.pd-loader {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.7);
}

.pd-editor.pd-busy .pd-loader {
    display: flex;
}

.pd-loader span {
    width: 42px;
    height: 42px;
    border: 3px solid var(--pd-border);
    border-top-color: var(--pd-accent);
    border-radius: 50%;
    animation: pd-spin 0.9s linear infinite;
}

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

/* ------------------------------------------------------------ Responsive */

@media (max-width: 1199px) {
    .pd-sidebar-left {
        width: 260px;
    }

    .pd-sidebar-right {
        width: 240px;
    }
}

@media (max-width: 991px) {
    .pd-workspace {
        flex-direction: column;
    }

    .pd-sidebar {
        width: 100%;
        border: 0;
        border-top: 1px solid var(--pd-border);
    }

    .pd-sidebar-left {
        order: 2;
    }

    .pd-sidebar-right {
        order: 3;
        width: 100%;
    }

    .pd-stage {
        order: 1;
    }

    .pd-tools {
        flex-direction: row;
        width: auto;
        border-right: 0;
        border-bottom: 1px solid var(--pd-border);
    }

    .pd-sidebar-left {
        flex-direction: column;
    }
}
