@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Верхній тулбар */
.top-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: #1f2937;
    border: 1px solid #374151;
    color: #e5e7eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.top-icon-btn:hover {
    background: #374151;
    color: #38bdf8;
    transform: translateY(-1px);
}
.top-icon-btn:active {
    transform: translateY(0);
}

.cad-action-btn {
    padding: 6px 10px;
    border-radius: 9px;
    background: #1f2937;
    border: 1px solid #374151;
    font-size: 11px;
    font-weight: 700;
    color: #e5e7eb;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}
.cad-action-btn:hover {
    background: #374151;
    border-color: #4b5563;
}

/* Кнопки режимів 3D Гізмо */
.gizmo-mode-btn {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    transition: all 0.15s;
}
.gizmo-mode-btn:hover {
    color: #38bdf8;
    background: #1e293b;
}
.gizmo-mode-btn.active {
    background: #0284c7;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(2, 132, 199, 0.5);
}

/* БОКОВІ ЯРЛИКИ (TABS) */
.side-tab-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #192233;
    border: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.side-tab-btn:hover {
    background: #223049;
    border-color: #38bdf8;
    transform: scale(1.05);
}
.side-tab-btn.active {
    background: #0f2744;
    border-color: #0284c7;
    box-shadow: 0 0 12px rgba(2, 132, 199, 0.45);
}
.side-tab-btn .tab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #0284c7;
    color: #ffffff;
    font-size: 8px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    padding: 1px 4px;
    border-radius: 6px;
}

/* ВИСУВНІ ПАНЕЛІ (DRAWERS) */
.cad-drawer {
    position: absolute;
    right: 48px; /* поруч із панеллю вкладок w-12 (48px) */
    top: 0;
    bottom: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    transform: translateX(0);
    opacity: 1;
}
.cad-drawer.drawer-closed {
    transform: translateX(110%);
    opacity: 0;
    pointer-events: none;
}

/* ІНТЕРАКТИВНИЙ 3D VIEWCUBE */
.viewcube-wrapper {
    width: 60px;
    height: 60px;
    perspective: 260px;
    cursor: pointer;
}

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-25deg) rotateY(40deg);
    transition: transform 0.1s ease-out;
}

.face {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(30, 41, 59, 0.85);
    border: 1.5px solid #0284c7;
    color: #f8fafc;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: visible;
    transition: all 0.15s;
}
.face:hover {
    background: #0284c7;
    color: #ffffff;
}

.face.front  { transform: rotateY(0deg) translateZ(30px); }
.face.back   { transform: rotateY(180deg) translateZ(30px); }
.face.right  { transform: rotateY(90deg) translateZ(30px); }
.face.left   { transform: rotateY(-90deg) translateZ(30px); }
.face.top    { transform: rotateX(90deg) translateZ(30px); }
.face.bottom { transform: rotateX(-90deg) translateZ(30px); }

.cube-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #94a3b8;
    transition: all 0.15s;
}
.cube-btn:hover {
    background: #1e293b;
    color: #38bdf8;
}

/* Картки примітивів */
.shape-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 7px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.shape-card:hover {
    background: #1e293b;
    border-color: #0284c7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.2);
}
.shape-card:active {
    transform: scale(0.96);
}

.shape-preview-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: #172554;
    color: #38bdf8;
    font-size: 15px;
}

/* Смугастий візерунок отворів (Hole) */
.stripe-pattern {
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.15),
        rgba(255, 255, 255, 0.15) 3px,
        transparent 3px,
        transparent 6px
    );
}

/* Слайдери */
.cad-slider {
    accent-color: #0284c7;
    height: 5px;
    border-radius: 4px;
    background: #334155;
    outline: none;
}

body.paint-mode-active #cadCanvas {
    cursor: crosshair !important;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: #0b0f19;
}
::-webkit-scrollbar-thumb {
    background: #1f2937;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #374151;
}

@keyframes scaleUp {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.animate-scale-up {
    animation: scaleUp 0.18s ease-out forwards;
}

/* ВИПРАВЛЕННЯ ДЛЯ ПЛАНШЕТІВ ТА МОБІЛЬНИХ */
@supports (height: 100dvh) {
    body {
        height: 100dvh !important;
    }
}

/* Врахування нижньої системної смуги планшета */
.cad-drawer {
    max-height: 100%;
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Робимо так, щоб гізмо-елементи не перехоплювали зайві дотики */
#viewportContainer {
    touch-action: none;
}

.cad-preset-btn {
    padding: 6px 8px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    background: #0f172a;
    border: 1px solid #1e293b;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}
.cad-preset-btn:hover {
    border-color: #38bdf8;
    color: #ffffff;
}
.cad-preset-btn.active {
    background: #0c4a6e;
    border-color: #0284c7;
    color: #38bdf8;
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.35);
}

.cad-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 9px;
    background: #0f172a;
    border: 1px solid #1e293b;
    font-size: 11px;
    color: #cbd5e1;
    cursor: pointer;
    transition: border-color 0.15s;
}
.cad-toggle-row:hover {
    border-color: #334155;
}
.cad-checkbox {
    accent-color: #06b6d4;
    width: 15px;
    height: 15px;
    cursor: pointer;
}