/* static/css/modals.css */
/* Стили для модальных окон камеры и галереи - ОБНОВЛЕННАЯ ВЕРСИЯ */

/* ==========================================================================
   ОСНОВНЫЕ СТИЛИ МОДАЛЬНЫХ ОКОН
   ========================================================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background-color: var(--modal-bg);
    margin: 2% auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    animation: slideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, var(--modal-header-bg-1), var(--modal-header-bg-2));
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-body {
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-alt);
    border-radius: 0 0 12px 12px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.close {
    color: var(--text-muted);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    color: #dc3545;
    background: var(--surface-alt);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   ОБНОВЛЕННОЕ МОДАЛЬНОЕ ОКНО КАМЕРЫ
   ========================================================================== */

.camera-modal-content {
    width: 1000px;
    max-width: 95%;
    display: flex;
    flex-direction: column;
}

.camera-modal-content .modal-body {
    padding: 0;
    max-height: 75vh;
    overflow: hidden;
}

/* Контейнер для кнопок в заголовке */
.camera-header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.camera-header-controls .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.camera-header-controls .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Основной layout камеры */
.camera-layout {
    display: flex;
    gap: 20px;
    height: 500px;
    padding: 20px;
}

/* Левая колонка - камера и управление съемкой */
.camera-left-column {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.camera-container {
    position: relative;
    width: 100%;
    height: 400px;
    background: var(--overlay-color);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #495057;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--overlay-color);
}

#photo-canvas {
    display: none;
}

.camera-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    text-align: center;
    background: rgba(220, 53, 69, 0.9);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.3);
    z-index: 10;
}

.camera-error i {
    font-size: 24px;
    margin-bottom: 10px;
    display: block;
}

/* Блок управления предпросмотром */
.preview-controls {
    background: var(--surface-alt);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.preview-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 8px;
}

.preview-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.preview-buttons .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.preview-hint {
    color: var(--text-muted);
    font-size: 12px;
}

/* Правая колонка - галерея сделанных фото */
.camera-right-column {
    flex: 2;
    display: flex;
    flex-direction: column;
    min-width: 280px;
}

.photos-section {
    background: var(--surface-alt);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.photos-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--surface-hover);
    border-bottom: 1px solid var(--border-color);
}

.photos-section-header h4 {
    margin: 0;
    color: var(--text-color);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.photos-count {
    background: var(--text-muted);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.photos-list-container {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.photos-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    min-height: 100%;
}

.photo-preview-item {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s ease;
    aspect-ratio: 1;
}

.photo-preview-item:hover {
    border-color: var(--primary-color);
    transform: scale(1.03);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

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

.remove-photo {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    padding: 0;
    border-radius: 50%;
    font-size: 10px;
    background: rgba(220, 53, 69, 0.95);
    border: 1px solid white;
    color: white;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-preview-item:hover .remove-photo {
    opacity: 1;
}

.remove-photo:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.no-photos-message {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--surface);
    border-radius: 6px;
    border: 2px dashed #dee2e6;
}

.no-photos-message i {
    font-size: 24px;
    color: var(--text-muted);
}

/* ==========================================================================
   МОДАЛЬНОЕ ОКНО ГАЛЕРЕИ
   ========================================================================== */

.gallery-modal-content {
    width: 920px;
    max-width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.gallery-modal-content .modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.gallery-modal-content .modal-header {
    padding: 12px 20px;
}

.gallery-modal-content .modal-header h3 {
    font-size: 1.2rem;
}

.gallery-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 500px;
    margin: 10px 20px;
    background: var(--overlay-color);
    border-radius: 12px;
    overflow: hidden;
    border: 3px solid #495057;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    flex: 1;
}

.gallery-image-container {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

#gallery-main-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.3);
}

.gallery-nav-btn:hover {
    background: rgba(0, 0, 0, 0.95);
    transform: translateY(-50%) scale(1.1);
    border-color: rgba(255,255,255,0.6);
}

.gallery-prev-btn {
    left: 20px;
}

.gallery-next-btn {
    right: 20px;
}

.gallery-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#gallery-delete-btn {
    display: flex !important;
    align-items: center;
    gap: 5px;
    visibility: visible !important;
    opacity: 1 !important;
    font-size: 12px;
    padding: 6px 12px;
}

.gallery-info {
    text-align: center;
    margin: 8px 20px;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--modal-header-bg-1), var(--modal-header-bg-2));
    border-radius: 6px;
    border-left: 3px solid #dc3545;
}

.gallery-info span {
    font-weight: bold;
    color: var(--text-color);
    font-size: 14px;
    display: block;
    margin-bottom: 3px;
}

.gallery-info small {
    color: var(--text-muted);
    font-size: 11px;
}

.gallery-thumbnails {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    max-height: 100px;
    overflow-y: auto;
    padding: 10px 15px;
    background: var(--surface-alt);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin: 0 20px 15px 20px;
}

.gallery-thumb {
    width: 70px;
    height: 70px;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.gallery-thumb.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.3);
    transform: scale(1.05);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-thumb:hover {
    border-color: #0056b3;
    transform: scale(1.05);
}

.gallery-thumb.active::after {
    content: '✓';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
}

/* ==========================================================================
   АДАПТИВНОСТЬ ДЛЯ ОБНОВЛЕННОЙ КАМЕРЫ
   ========================================================================== */

@media (max-width: 1024px) {
    .camera-modal-content {
        width: 98%;
    }
    
    .camera-layout {
        flex-direction: column;
        height: auto;
    }
    
    .camera-left-column,
    .camera-right-column {
        min-width: auto;
    }
    
    .camera-container {
        height: 350px;
    }
    
    .photos-section {
        height: 300px;
    }
}

@media (max-width: 768px) {
    .modal-content {
        margin: 1% auto;
        width: 98%;
    }
    
    .camera-modal-content {
        width: 98%;
    }
    
    .camera-header-controls {
        flex-direction: column;
        gap: 5px;
    }
    
    .camera-container {
        height: 300px;
    }
    
    .photos-list {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 8px;
    }
    
    .preview-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .camera-container {
        height: 250px;
    }
    
    .photos-list {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 6px;
    }
    
    .modal-header {
        padding: 10px 15px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .camera-header-controls .btn,
    .preview-buttons .btn {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .gallery-container {
        height: 300px;
    }
    
    .gallery-nav-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .gallery-prev-btn {
        left: 10px;
    }
    
    .gallery-next-btn {
        right: 10px;
    }
    
    .gallery-thumb {
        width: 50px;
        height: 50px;
    }
}

/* Стили для скроллбаров */
.modal-body::-webkit-scrollbar,
.photos-list-container::-webkit-scrollbar,
.gallery-thumbnails::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track,
.photos-list-container::-webkit-scrollbar-track,
.gallery-thumbnails::-webkit-scrollbar-track {
    background: var(--surface-alt);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb,
.photos-list-container::-webkit-scrollbar-thumb,
.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.photos-list-container::-webkit-scrollbar-thumb:hover,
.gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Дополнения к modals.css для компактного режима камеры */

/* Компактное модальное окно камеры */
.camera-modal-content {
    width: 900px;
    max-width: 95%;
    max-height: 85vh;
}

.camera-modal-content .modal-body {
    padding: 0;
    max-height: calc(85vh - 120px); /* Учитываем высоту header и footer */
    overflow: hidden;
}

/* Адаптивность для компактного режима */
@media (max-width: 1366px) {
    .camera-modal-content {
        width: 850px;
    }
}

@media (max-width: 1024px) {
    .camera-modal-content {
        width: 95%;
        margin: 1% auto;
    }
}

@media (max-width: 768px) {
    .camera-modal-content {
        width: 98%;
        margin: 0.5% auto;
    }
    
    .modal-header {
        padding: 10px 15px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-footer {
        padding: 10px 15px;
    }
}

@media (max-width: 480px) {
    .camera-modal-content {
        width: 99%;
        margin: 0 auto;
    }
    
    .modal-header,
    .modal-footer {
        padding: 8px 12px;
    }
    
    .modal-header h3 {
        font-size: 1rem;
    }
}

/* Улучшенные анимации */
@keyframes slideInCompact {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.camera-modal-content {
    animation: slideInCompact 0.3s ease-out;
}

/* Улучшенные стили для сообщений об ошибках */
.camera-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    text-align: center;
    z-index: 10;
}

.camera-error i {
    font-size: 32px;
    margin-bottom: 10px;
    color: #dc3545;
}

.camera-error span {
    font-size: 14px;
    line-height: 1.4;
}

/* Улучшенные стили для скроллбаров */
.photos-list-container-compact::-webkit-scrollbar {
    width: 4px;
}

.photos-list-container-compact::-webkit-scrollbar-track {
    background: var(--surface-alt);
    border-radius: 2px;
}

.photos-list-container-compact::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.photos-list-container-compact::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Улучшенные стили для кнопок в компактном режиме */
.camera-header-controls .btn {
    transition: all 0.2s ease;
}

.camera-header-controls .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preview-buttons-compact .btn {
    transition: all 0.2s ease;
}

.preview-buttons-compact .btn:hover {
    transform: translateY(-1px);
}

/* Анимация появления предпросмотра */
.preview-controls-compact {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Анимация для миниатюр */
.photo-preview-item {
    animation: scaleIn 0.2s ease-out;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Анимации для уведомлений */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}