/* =========================================
   1. CORE VARIABLES & SETUP
   ========================================= */
:root {
    /* Luxury / God Mode Colors */
    --gold-primary: #FFD700;
    --gold-secondary: #B8860B;
    --gold-soft: rgba(255, 215, 0, 0.1);
    --dark-bg: #0b0b0e;
    --panel-bg: #15151a;
    --border-color: #2d2d35;
    
    /* Play Market Colors (Exact) */
    --play-green: #01875f;
    --play-dark-green: #00694a;
    --play-bg: #ffffff;
    --play-text: #202124;
    --play-gray: #5f6368;
    --play-border: #dadce0;
    
    /* Sizes */
    --header-height: 57px;
    --toolbox-width: 300px;
    --inspector-width: 320px;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* Блокируем скролл всей страницы */
    font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--dark-bg);
}

/* =========================================
   2. LAYOUT ENGINE (ADMIN LTE FIXES)
   ========================================= */

/* Главная обертка */
.wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 
   Content Wrapper (Корневой контейнер билдера)
   Мы переопределяем стили AdminLTE, чтобы получить чистый Flexbox контейнер
*/
#builder-root.content-wrapper {
    margin-left: 250px; /* Ширина развернутого меню AdminLTE */
    height: calc(100vh - var(--header-height)) !important;
    min-height: 0 !important;
    background-color: var(--dark-bg) !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: row !important; /* Тулбокс слева, Холст справа */
    align-items: stretch !important;
    overflow: hidden !important;
    transition: margin-left 0.3s ease-in-out;
}

/* Адаптация под свернутое меню */
body.sidebar-collapse #builder-root.content-wrapper {
    margin-left: 73px !important;
}

/* Адаптация под мобильные */
@media (max-width: 768px) {
    #builder-root.content-wrapper { margin-left: 0 !important; }
}

/* =========================================
   3. TOOLBOX (LEFT PANE)
   ========================================= */

.builder-pane.left-pane {
    width: var(--toolbox-width);
    flex: 0 0 var(--toolbox-width); /* Жесткая фиксация ширины */
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 50;
    height: 100%;
}

.lego-toolbox {
    padding: 15px;
    overflow-y: auto;
    height: 100%;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-secondary) var(--panel-bg);
}

.toolbox-header {
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.toolbox-header h6 {
    margin: 0;
    color: var(--gold-primary);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

/* Элементы тулбокса */
.toolbox-item {
    background: #25252b;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 8px;
    cursor: grab;
    display: flex;
    align-items: center;
    color: #e0e0e0;
    transition: all 0.2s ease;
    user-select: none;
}

.toolbox-item:hover {
    border-color: var(--gold-primary);
    background: var(--gold-soft);
    transform: translateX(5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.toolbox-item i {
    color: var(--gold-primary);
    width: 24px;
    margin-right: 10px;
    text-align: center;
    font-size: 1.1rem;
}

.toolbox-item-label {
    font-size: 0.9rem;
    font-weight: 500;
}

/* =========================================
   4. CANVAS & PHONE (CENTER PANE)
   ========================================= */

.builder-pane.center-pane {
    flex: 1; /* Занимает все оставшееся место */
    min-width: 0; /* ФИКС: предотвращает растягивание флексом */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #121214;
    background-image: 
        radial-gradient(#222 1px, transparent 1px),
        radial-gradient(#1a1a1f 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    position: relative;
    overflow: hidden;
}

.device-frame-wrapper {
    position: relative;
    z-index: 10;
    padding: 20px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: floatUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.device-frame {
    width: 375px;
    height: 780px; /* Стандартная высота современного Android */
    max-height: 95vh;
    background: #000;
    border-radius: 40px;
    box-shadow: 
        0 0 0 12px #1a1a1f, 
        0 0 0 14px #333,
        0 30px 80px rgba(0,0,0,0.8);
    position: relative;
    overflow: hidden;
    border: 6px solid #000;
    flex-shrink: 0;
}

/* Вырез камеры */
.device-notch {
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 150px; height: 30px;
    background: #000;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    z-index: 1000;
    pointer-events: none;
}

/* ЭКРАН ТЕЛЕФОНА (Белый для Play Market) */
.device-screen {
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    /* Скрываем скроллбар */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.device-screen::-webkit-scrollbar { display: none; }

/* Зона контента (куда падают блоки) */
#preview-content {
    padding-top: 40px; /* Отступ под статус бар */
    padding-bottom: 40px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Статус бар (часы) */
.system-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 25px;
    font-size: 13px;
    font-weight: 600;
    color: #000;
    z-index: 999;
    pointer-events: none;
}

/* =========================================
   5. PROPERTY INSPECTOR (RIGHT PANE - FIXED)
   ========================================= */

.property-inspector {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: var(--inspector-width);
    background-color: var(--panel-bg);
    border-left: 1px solid var(--border-color);
    z-index: 9000; /* Поверх всего */
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -10px 0 40px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.property-inspector.is-open {
    transform: translateX(0);
}

.inspector-header {
    padding: 15px;
    background: #1a1a1f;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.inspector-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Стили полей инспектора */
.inspector-field { margin-bottom: 15px; }
.inspector-field label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.inspector-input, .form-control {
    background: #0a0a0c !important;
    border: 1px solid #333 !important;
    color: #fff !important;
    font-size: 13px;
    border-radius: 4px;
}
.inspector-input:focus {
    border-color: var(--gold-primary) !important;
    box-shadow: none !important;
}

/* =========================================
   6. BUILDER INTERNAL ELEMENTS (DRAG & DROP)
   ========================================= */

/* Блок внутри телефона */
.preview-block {
    position: relative;
    background: #fff;
    transition: box-shadow 0.2s;
    user-select: none;
}

/* Эффекты наведения и выбора */
.preview-block:hover {
    box-shadow: inset 0 0 0 2px rgba(1, 135, 95, 0.3); /* Зеленая рамка Play Market */
    z-index: 50;
}
.preview-block.selected {
    box-shadow: inset 0 0 0 2px var(--play-green) !important;
    background-color: rgba(1, 135, 95, 0.02);
    z-index: 60;
}

/* Ручка перетаскивания */
.block-drag-handle {
    height: 24px;
    background: rgba(32, 33, 36, 0.05);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    padding: 0 10px;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s;
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 100;
}
.preview-block:hover .block-drag-handle,
.preview-block.selected .block-drag-handle { opacity: 1; }

.block-drag-handle:active { cursor: grabbing; }

/* Кнопки управления блоком (глаз, удалить) */
.block-controls {
    position: absolute;
    top: 2px;
    right: 5px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 101;
    display: flex;
    gap: 2px;
}
.preview-block:hover .block-controls,
.preview-block.selected .block-controls { opacity: 1; }

.control-btn {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
}
.control-btn:hover { background: #f1f3f4; }

/* Плейсхолдер при сортировке */
.sortable-placeholder {
    background: rgba(1, 135, 95, 0.1) !important;
    border: 2px dashed var(--play-green) !important;
    height: 80px;
    margin-bottom: 10px;
    border-radius: 8px;
    visibility: visible !important;
}

/* =========================================
   7. GOOGLE PLAY COMPONENT STYLES (EXACT)
   ========================================= */

/* Header */
.app-header.playmarket { padding: 20px 24px 0; display: flex; gap: 20px; }
.app-icon-playmarket img { width: 72px; height: 72px; border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); object-fit: cover; }
.app-name-playmarket { font-size: 24px; font-weight: 500; color: var(--play-text); margin: 0; line-height: 1.2; letter-spacing: 0.5px; }
.app-dev-playmarket { font-size: 14px; color: var(--play-green); font-weight: 500; margin-top: 4px; display: block; text-decoration: none; }
.app-meta-playmarket { font-size: 12px; color: var(--play-gray); margin-top: 4px; }

/* Install Button */
.install-area.playmarket { padding: 20px 24px; }
.install-button-playmarket {
    background: var(--play-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 100%;
    height: 36px;
    font-weight: 500;
    font-size: 14px;
    letter-spacing: 0.25px;
    cursor: pointer;
    transition: background 0.2s;
}
.install-button-playmarket:active { background: var(--play-dark-green); }

/* Stats Row */
.stats-container.playmarket { display: flex; padding: 0 24px 20px; border-bottom: 1px solid #f0f0f0; overflow-x: auto; }
.stat-item-playmarket { padding-right: 20px; margin-right: 20px; position: relative; text-align: center; min-width: 60px; }
.stat-item-playmarket::after { content: ''; position: absolute; right: 0; top: 10%; height: 80%; width: 1px; background: #e0e0e0; }
.stat-item-playmarket:last-child::after { display: none; }
.stat-value-playmarket { font-weight: 500; font-size: 14px; color: var(--play-text); display: flex; justify-content: center; gap: 2px; }
.stat-label-playmarket { font-size: 12px; color: var(--play-gray); margin-top: 2px; }

/* Description */
.description-playmarket { padding: 0 24px 20px; }
.section-title-playmarket { 
    font-size: 18px; font-weight: 500; color: var(--play-text); margin-bottom: 12px; 
    display: flex; justify-content: space-between; align-items: center; 
}
.desc-text-pm { font-size: 14px; color: var(--play-gray); line-height: 20px; }
.tags-row-pm { display: flex; gap: 8px; margin-top: 15px; overflow-x: auto; scrollbar-width: none; }
.tag-chip-pm { 
    border: 1px solid #dadce0; border-radius: 16px; padding: 6px 12px; 
    font-size: 13px; color: var(--play-gray); white-space: nowrap; 
}

/* Screenshots */
.screenshots-container.playmarket { padding: 10px 0 20px 24px; }
.screenshots-scroll { display: flex; gap: 12px; overflow-x: auto; padding-right: 24px; scrollbar-width: none; }
.screenshot-img { border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); height: 180px; object-fit: cover; }

/* Ratings */
.ratings-playmarket { padding: 0 24px 20px; }
.rating-big-pm { font-size: 48px; font-weight: 500; color: var(--play-text); line-height: 1; }
.stars-pm { color: var(--play-green); font-size: 12px; margin: 4px 0; }
.count-pm { font-size: 10px; color: var(--play-gray); }

/* Reviews */
.reviews-playmarket { padding: 0 24px 20px; }
.review-item-pm { margin-bottom: 20px; }
.review-header-pm { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.review-avatar-pm { width: 32px; height: 32px; border-radius: 50%; background-color: #eee; background-size: cover; }
.review-name-pm { font-size: 13px; font-weight: 500; color: #202124; }
.review-text-pm { font-size: 13px; color: var(--play-gray); line-height: 20px; }

/* =========================================
   8. EXTRA UI
   ========================================= */

/* AI Button */
.ai-btn {
    position: fixed; bottom: 30px; right: 350px;
    width: 60px; height: 60px; border-radius: 50%;
    background: linear-gradient(135deg, #FFD700, #B8860B);
    border: none; color: #000; font-size: 24px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 5px 20px rgba(0,0,0,0.5); z-index: 500;
    transition: transform 0.3s;
}
.ai-btn:hover { transform: scale(1.1) rotate(15deg); }

/* Animation */
@keyframes floatUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--panel-bg); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-primary); }
/* --- DESCRIPTION TEXT FIX --- */
.desc-text-pm {
    font-size: 14px;
    color: var(--play-gray);
    line-height: 1.5;
    white-space: pre-wrap; /* 🔥 Сохраняет переносы строк */
    word-wrap: break-word; /* 🔥 Переносит длинные слова */
}

/* --- BADGES --- */
.badge-editors-choice {
    background-color: transparent;
    color: var(--play-text);
    border: 1px solid #dadce0;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
}

/* --- CLICKABLE LOGO --- */
.app-icon-playmarket.cursor-pointer {
    cursor: pointer;
    position: relative;
}
.app-icon-playmarket.cursor-pointer:hover .edit-overlay {
    opacity: 1;
}
.edit-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: opacity 0.2s;
}

/* --- INSPECTOR LISTS --- */
.list-item {
    background: #25252b;
    border: 1px solid rgba(255,255,255,0.1);
}
.drag-handle {
    cursor: grab;
    opacity: 0.5;
}
.drag-handle:hover { opacity: 1; color: var(--gold-primary); }

/* --- PULSE ANIMATION --- */
@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(1, 135, 95, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(1, 135, 95, 0); }
    100% { box-shadow: 0 0 0 0 rgba(1, 135, 95, 0); }
}
.anim-pulse {
    animation: pulse-green 2s infinite;
}
