/* ==========================================================================
   1. БАЗОВЫЕ НАСТРОЙКИ СТРАНИЦЫ И ПОЛНОЭКРАННЫЙ ЛЕЙАУТ
   ========================================================================== */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    background-color: #1c1c1e;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    box-sizing: border-box;
}

#top-bar {
    flex-shrink: 0;
    z-index: 10;
    background-color: #1c1c1e;
    padding-bottom: 4px;
}

#nav-header {
    padding: 8px 10px;
    margin: 6px 6px 0 6px;
    background-color: #2c2c2e;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    color: #30d158;
    cursor: pointer;
}

.instruction-box {
    background-color: #2c2c2e;
    color: #aeaeb2;
    font-size: 13px;
    line-height: 1.3;
    padding: 8px 10px;
    margin: 6px 6px 4px 6px;
    border-radius: 6px;
    border-left: 3px solid #30d158; 
    box-sizing: border-box;
}

/* Кнопка добавления, находящаяся над сеткой */
.top-action-btn {
    width: calc(100% - 12px);
    margin: 4px 6px;
    padding: 10px;
    background-color: rgba(48, 209, 88, 0.12);
    border: 1px dashed #30d158;
    border-radius: 6px;
    color: #30d158;
    font-weight: bold;
    font-size: 14px;
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}

.top-action-btn:active {
    background-color: rgba(48, 209, 88, 0.25);
}

#limit-warning {
    color: #ff4d4d;
    background-color: rgba(255, 77, 77, 0.1);
    border: 1px solid #ff4d4d;
    padding: 8px 10px;
    border-radius: 6px;
    margin: 4px 6px 0 6px;
    font-size: 13px;
    text-align: center;
    font-weight: bold;
    line-height: 1.3;
}

/* Прокручиваемый контент */
#content-area {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

/* ==========================================================================
   2. СЕТКА СТИКЕРОВ (Максимальная полезная площадь, без закруглений)
   ========================================================================== */
.sticker-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px; /* Минимальный зазор между стикерами */
    padding: 2px; /* Минимальный отступ от краев экрана */
    box-sizing: border-box;
    touch-action: pan-y !important;
}

.sticker-cell {
    aspect-ratio: 1 / 1;
    background: #2c2c2e;
    border-radius: 0 !important; /* Убрали закругления */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible; 
    box-sizing: border-box;
    cursor: pointer;
}

.sticker-cell video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0 !important; /* Убрали закругления у видео */
    pointer-events: none;
}

/* Выделение и иконки на стикерах */
.sticker-cell.selected {
    outline: 2px solid #30d158;
    outline-offset: -2px;
}

.sticker-cell.selected::after {
    content: "✓";
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background-color: #30d158;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.delete-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background-color: rgba(255, 59, 48, 0.9);
    color: white;
    border-radius: 50%;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

/* ==========================================================================
   3. СОРТИРОВКА (SortableJS)
   ========================================================================== */
.sortable-ghost {
    background-color: rgba(0, 0, 0, 0.5) !important;
    outline: 2px dashed #30d158 !important;
}

.sortable-ghost video {
    opacity: 0 !important;
}

.sortable-drag {
    opacity: 1 !important;
    transform: scale(1.05) !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7) !important;
    z-index: 99999 !important;
}

/* ==========================================================================
   4. ФИКСИРОВАННЫЙ ПОДВАЛ
   ========================================================================== */
#finish-container {
    flex-shrink: 0;
    padding: 10px 12px;
    background-color: #1c1c1e;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    z-index: 100;
}

#finish-btn {
    display: block;
    margin: 0 auto;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: bold;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    width: 100%;
    max-width: 400px; 
    background-color: #30d158; 
    color: #ffffff;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: ellipsis; 
}

#finish-btn:active {
    transform: scale(0.98);
}

#finish-btn:disabled {
    background-color: #3a3a3c !important;
    color: #8e8e93 !important;
    cursor: not-allowed;
    box-shadow: none;
}