/* Üldised stiilid */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --gray-color: #95a5a6;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f7fa;
}

.container {
    max-width: 1600px;
    /* Увеличено для лучшего размещения вертикальных фото */
    margin: 0 auto;
    padding: 0 20px;
}

/* Päis */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

.company-logo-small {
    height: 50px;
    width: auto;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 20px;
}

.company-logo {
    height: 70px;
    width: auto;
}

/* Nupud */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--gray-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-admin {
    background-color: var(--accent-color);
    color: white;
}

.btn-admin:hover {
    background-color: #c0392b;
}

/* Info-sektsioonid */
.info-section,
.instruction-section,
.howto-section {
    margin-bottom: 3rem;
}

.info-card,
.instruction-card,
.howto-card {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.info-card h2,
.instruction-card h2,
.howto-card h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-card ul {
    list-style: none;
    margin: 1rem 0;
}

.info-card li {
    margin: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Galerii */
.management-section,
.gallery-section {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 3rem;
}

.management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header {
    margin-bottom: 1.5rem;
}

.filters,
.gallery-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.search-box {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-color);
}

.search-box input {
    width: 100%;
    padding: 12px 12px 12px 45px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.sort-options {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-options select {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    background-color: white;
    font-size: 1rem;
}

/* Galerii grid - 9:16 VERTIKAALNE FORMAT */
.gallery {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.2rem;
    /* Уменьшен отступ для вертикальных фото */
    margin-bottom: 2rem;
    justify-items: center;
    /* Центрируем карточки */
}

.public-gallery {
    grid-template-columns: repeat(5, 1fr);
}

.gallery-item {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    aspect-ratio: 9/16;
    /* ИЗМЕНЕНО: 16/9 → 9/16 (вертикальный формат) */
    width: 100%;
    max-width: 220px;
    /* Ограничиваем максимальную ширину для вертикальных фото */
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.gallery-image {
    width: 100%;
    height: 82%;
    /* ИЗМЕНЕНО: 70% → 82% (больше места для вертикального фото) */
    object-fit: cover;
    object-position: top center;
    /* Фокусируемся на верхней части, где обычно лицо */
    display: block;
}

.gallery-info {
    padding: 12px 15px;
    height: 18%;
    /* ИЗМЕНЕНО: 30% → 18% (меньше места для текста в вертикальном формате) */
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: white;
    border-top: 1px solid #f0f0f0;
}

.gallery-info h3 {
    font-size: 1rem;
    /* Немного уменьшен шрифт для вертикального формата */
    margin-bottom: 4px;
    color: var(--primary-color);
    text-align: center;
    line-height: 1.2;
}

.gallery-info p {
    color: var(--gray-color);
    font-size: 0.85rem;
    /* Немного уменьшен шрифт */
    text-align: center;
    line-height: 1.2;
}

.gallery-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item:hover .gallery-actions {
    opacity: 1;
}

.action-btn {
    width: 32px;
    /* Немного меньше кнопки для вертикального формата */
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.action-btn:hover {
    background: var(--secondary-color);
    color: white;
    transform: scale(1.1);
}

/* Tühi olek */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gray-color);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #ddd;
}

.empty-state h3 {
    margin-bottom: 1rem;
    color: var(--gray-color);
}

/* Juhend */
.prompt-box {
    background: #f8f9fa;
    border-left: 4px solid var(--secondary-color);
    padding: 1.5rem;
    margin: 1.5rem 0;
    position: relative;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.prompt-box code {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
}

.btn-copy {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}

.btn-copy:hover {
    background: #2980b9;
}

.logo-download {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

/* Sammud */
.steps {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-top: 2rem;
}

.step {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.step-number {
    background: var(--secondary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.step-content h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.public-prompt {
    margin-top: 1rem;
}

/* Modaalid */
.modal {
    display: none; /* Важно: скрыто по умолчанию */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex; /* Отображается только с классом active */
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: var(--primary-color);
}

.modal-close,
.view-modal-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--gray-color);
    line-height: 1;
}

.modal-close:hover,
.view-modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 1.5rem;
}

/* Vorm */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.upload-area {
    border: 2px dashed var(--gray-color);
    border-radius: var(--border-radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.upload-area:hover {
    border-color: var(--secondary-color);
    background: #f8f9fa;
}

.upload-area i {
    font-size: 3rem;
    color: var(--gray-color);
    margin-bottom: 1rem;
}

.upload-area p {
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.upload-area span {
    color: var(--gray-color);
    font-size: 0.9rem;
}

.upload-area input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.image-preview {
    margin-top: 1rem;
    display: none;
}

.image-preview.active {
    display: block;
    text-align: center;
}

#previewImage {
    max-height: 400px;
    /* Увеличено для вертикальных фото */
    max-width: 225px;
    /* 400 * 9/16 ≈ 225 (сохраняем пропорции 9:16) */
    object-fit: cover;
    object-position: top;
    border-radius: var(--border-radius);
    border: 1px solid #ddd;
    margin: 0 auto;
    display: block;
}

.preview-info {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--gray-color);
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Suure vaate modaal - оптимизирован для вертикальных фото */
.view-modal {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.view-modal.active {
    display: flex;
}


.view-modal-content {
    position: relative;
    background: transparent;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: auto;
    max-width: 95vw;
    max-height: 95vh;
}

.view-modal-content img {
    max-height: 85vh;
    max-width: 85vw;
    height: auto;
    width: auto;
    object-fit: contain;
    object-position: center;
    border-radius: var(--border-radius);
    background: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.image-info {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    text-align: center;
    margin-top: 1rem;
    width: fit-content;
    max-width: 80%;
    backdrop-filter: blur(5px);
}

/* Кнопка закрытия в модальном окне */
.view-modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
}

.view-modal-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Kinnituse modaal */
.confirm-modal-content {
    max-width: 500px;
    text-align: center;
}

.confirm-modal-content h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Jalus */
footer {
    background: var(--primary-color);
    color: white;
    padding: 2rem 0;
    text-align: center;
    margin-top: 3rem;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

footer p {
    margin-bottom: 0.5rem;
}

.footer-links {
    margin-top: 1rem;
}

.footer-links a {
    color: white;
    text-decoration: none;
    margin: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.footer-links a:hover {
    text-decoration: underline;
}

.public-footer {
    background: linear-gradient(135deg, var(--primary-color) 0%, #34495e 100%);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.footer-logo-img {
    height: 50px;
    width: auto;
}

/* Hero sektsioon */
.hero-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem;
    border-radius: var(--border-radius);
    margin-bottom: 3rem;
    text-align: center;
}

.hero-section h2 {
    font-size: 2.2rem;
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.2rem;
    max-width: 800px;
    margin: 0 auto;
    opacity: 0.9;
}

/* Mobiilioptimeerimine для 9:16 формата */
@media (max-width: 1400px) {

    .gallery,
    .public-gallery {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }

    .gallery-item {
        max-width: 240px;
    }
}

@media (max-width: 1200px) {

    .gallery,
    .public-gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }

    .gallery-item {
        max-width: 260px;
    }
}

@media (max-width: 992px) {

    .gallery,
    .public-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .gallery-item {
        max-width: 280px;
    }

    .main-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-info {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 768px) {

    .gallery,
    .public-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .gallery-item {
        max-width: 100%;
        aspect-ratio: 9/16;
    }

    header h1 {
        font-size: 2rem;
    }

    .filters,
    .gallery-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: 100%;
    }

    .hero-section {
        padding: 2rem;
    }

    .hero-section h2 {
        font-size: 1.8rem;
    }

    .steps {
        gap: 1.5rem;
    }

    .step {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

@media (max-width: 576px) {

    .gallery,
    .public-gallery {
        grid-template-columns: 1fr;
        max-width: 320px;
        margin: 0 auto 2rem;
    }

    .gallery-item {
        max-width: 300px;
        margin: 0 auto;
        aspect-ratio: 9/16;
        /* Вертикальный формат сохраняем */
    }

    .container {
        padding: 0 15px;
    }

    .info-card,
    .instruction-card,
    .howto-card,
    .management-section,
    .gallery-section {
        padding: 1.5rem;
    }

    .modal-content {
        width: 95%;
    }

    .gallery-actions {
        opacity: 1;
        /* Alati nähtavad mobiilil */
    }

    .modal-actions {
        flex-direction: column;
    }

    .confirm-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    /* Для мобильных делаем фото чуть шире */
    @media (max-width: 400px) {

        .gallery,
        .public-gallery {
            max-width: 280px;
        }

        .gallery-item {
            max-width: 260px;
        }
    }
}

/* Animasioonid */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item {
    animation: fadeIn 0.5s ease-out;
}

/* Teated */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 600;
    z-index: 1001;
    animation: slideIn 0.3s ease-out;
    box-shadow: var(--shadow);
}

.notification.success {
    background-color: var(--success-color);
}

.notification.error {
    background-color: var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Дополнительные стили для вертикальных фото 9:16 */
.format-hint {
    font-size: 0.85rem;
    color: var(--gray-color);
    margin-top: 5px;
    font-style: italic;
}

/* Стили для отображения информации о формате */
.format-info {
    background: #f8f9fa;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    margin-top: 10px;
    border-left: 3px solid var(--secondary-color);
}

.format-info p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--dark-color);
}

/* Для лучшего отображения вертикальных фото в превью */
.image-preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Адаптация формы загрузки для вертикальных фото */
.upload-area span {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
}

/* Индикатор загрузки */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 600;
}

.gallery-loading {
    text-align: center;
    padding: 3rem;
    color: var(--gray-color);
}

.gallery-loading i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--secondary-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}