/* Telegram WebApp Styles */

:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #2481cc;
    --tg-theme-button-text-color: #ffffff;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    line-height: 1.6;
    padding: 0;
    margin: 0;
    min-height: 100vh;
    /* Remove tap delay on mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 18px 40px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

h1 {
    font-size: 26px;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--tg-theme-hint-color);
    font-size: 14px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    margin-bottom: 12px;
}

.status-pill {
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    color: #0b5137;
    background: #d1e7dd;
    position: relative;
    z-index: 1;
}

.status-preview {
    color: #664d03;
    background: #fff3cd;
}

.status-live {
    color: #0b5137;
    background: #d1e7dd;
}

.info-text {
    color: var(--tg-theme-text-color);
    font-size: 13px;
    line-height: 1.5;
}

.info-text strong {
    color: var(--tg-theme-hint-color);
}

/* Breadcrumb */
.breadcrumb {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--tg-theme-text-color);
}

.breadcrumb-link {
    color: var(--tg-theme-link-color);
    text-decoration: none;
    cursor: pointer;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.notice {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 18px;
    font-size: 14px;
    color: var(--tg-theme-text-color);
}

.section {
    margin-bottom: 16px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.section h2 {
    font-size: 18px;
}

.count-pill {
    background: rgba(0, 0, 0, 0.06);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
}

.hint {
    color: var(--tg-theme-hint-color);
    font-size: 13px;
    margin-bottom: 10px;
}

.hint.error {
    color: #dc3545;
}

/* Content Grid - flexible for both categories and products */
.content-grid {
    display: grid;
    gap: 12px;
}

/* Category Grid - larger buttons */
.category-grid {
    grid-template-columns: 1fr;
}

.category-btn {
    width: 100%;
    padding: 20px 24px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--tg-theme-text-color);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    min-height: 64px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    /* Enable immediate touch response */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.category-btn:active {
    transform: scale(0.97);
    background: rgba(0, 0, 0, 0.12);
    transition: transform 0.05s ease, background 0.05s ease;
}

.category-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Instant touch feedback */
.category-btn {
    transition: transform 0.05s ease, background 0.1s ease, box-shadow 0.2s ease;
}

/* Product Grid - compact cards */
.product-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.product-card {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: transform 0.2s;
    /* Enable immediate touch response */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.product-card:active {
    transform: scale(0.98);
    transition: transform 0.05s ease;
}

.card-media {
    position: relative;
    width: 100%;
    padding-top: 75%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.12) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-media img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: transparent;
}

/* Image loading optimization */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

.card-media.placeholder {
    font-size: 32px;
    color: var(--tg-theme-hint-color);
}

.media-count-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.card-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-body h3 {
    font-size: 15px;
    line-height: 1.4;
}

.card-meta {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
}

.card-footer {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
}

.dm-btn {
    margin-top: 6px;
    text-align: center;
    display: inline-block;
}

/* Media Viewer and Carousel */
.media-viewer {
    position: relative;
    width: 100%;
    min-height: 300px;
    max-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
    border-radius: 12px;
    overflow: hidden;
}

.media-viewer img {
    max-width: 100%;
    max-height: 500px;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.media-viewer img.loaded {
    opacity: 1;
}

.media-carousel {
    position: relative;
    margin-bottom: 20px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background-color: var(--tg-theme-bg-color);
    border-radius: 16px;
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--tg-theme-text-color);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

.media-gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.gallery-image {
    width: 100%;
    border-radius: 12px;
    object-fit: contain;
}

.actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 12px;
    text-align: center;
    min-height: 56px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    /* Enable immediate touch response */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* For anchor tags styled as buttons */
a.btn {
    text-decoration: none;
    display: inline-block;
}

.btn:active {
    transform: scale(0.97);
    transition: transform 0.05s ease;
}

.btn:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

/* Instant button feedback */
.btn {
    transition: transform 0.05s ease, box-shadow 0.2s ease, opacity 0.1s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary {
    background-color: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.95;
    box-shadow: 0 4px 16px rgba(36, 129, 204, 0.3);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.08);
    color: var(--tg-theme-text-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.12);
}

/* Navigation buttons with enhanced styling */
.nav-button {
    min-height: 56px !important;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-button:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.nav-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Back button enhanced styling */
#back-btn {
    min-height: 56px;
    font-size: 16px;
    font-weight: 600;
    border: 2px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    position: relative;
    z-index: 10;
}

#back-btn:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

/* Thumbnail grid styling */
.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-bottom: 16px;
}

.media-thumbnail {
    position: relative;
    padding-top: 100%;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.media-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.media-thumbnail.active {
    border: 3px solid var(--tg-theme-button-color, #3390ec);
}

.thumb-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-danger {
    background-color: #dc3545;
    color: #ffffff;
}

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

.pill-btn {
    border: none;
    background: rgba(0, 0, 0, 0.08);
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }

    h1 {
        font-size: 22px;
    }
    
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: rgba(0, 0, 0, 0.08);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Enable immediate touch response */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.icon-btn:active {
    transform: scale(0.9);
    background: rgba(0, 0, 0, 0.15);
    transition: transform 0.05s ease, background 0.05s ease;
}

/* Views */
.view {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Welcome Screen */
.welcome-message {
    text-align: center;
    margin-bottom: 24px;
    padding: 20px;
}

.welcome-message h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    width: 100%;
    padding: 24px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--tg-theme-text-color);
    cursor: pointer;
    transition: transform 0.05s ease, background 0.1s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 72px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    /* Enable immediate touch response */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.action-btn:active {
    transform: scale(0.97);
    background: rgba(0, 0, 0, 0.12);
    transition: transform 0.05s ease, background 0.05s ease;
}

.action-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn-icon {
    font-size: 28px;
}

.btn-text {
    flex: 1;
    text-align: left;
}

/* Language Selection */
.language-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.language-btn {
    width: 100%;
    padding: 18px 22px;
    font-size: 17px;
    font-weight: 600;
    border: 2px solid transparent;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.06);
    color: var(--tg-theme-text-color);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    /* Enable immediate touch response */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.language-btn:active {
    transform: scale(0.98);
    transition: transform 0.05s ease;
}

.language-btn:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.language-btn.selected {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border-color: var(--tg-theme-button-color);
}

.lang-flag {
    font-size: 24px;
}

.lang-name {
    flex: 1;
}

.checkmark {
    font-size: 18px;
    color: inherit;
}

/* Search */
.search-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

#search-input {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
}

#search-input:focus {
    outline: none;
    border-color: var(--tg-theme-button-color);
}

#search-submit-btn {
    padding: 10px 16px;
    margin-bottom: 0;
    min-height: 40px;
    font-size: 14px;
    width: 100%;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}

.pagination .btn {
    margin-bottom: 0;
    flex: 1;
}

.pagination .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info {
    font-size: 14px;
    font-weight: 600;
    color: var(--tg-theme-text-color);
    white-space: nowrap;
}

/* Footer Actions */
.footer-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.footer-actions .btn {
    margin-bottom: 0;
}

/* Status Messages */
#status.error {
    background: #f8d7da;
    color: #721c24;
}

/* Video/Media Error Messages */
.media-error {
    color: white;
    padding: 20px;
    text-align: center;
}

.media-error-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.media-error-title {
    font-size: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}

.media-error-message {
    font-size: 14px;
    color: #ddd;
    margin-bottom: 4px;
}

.media-error-details {
    font-size: 12px;
    color: #ccc;
}

.media-error-hint {
    font-size: 13px;
    color: #aaa;
    margin-top: 12px;
    line-height: 1.5;
}

.media-loading {
    color: white;
    padding: 20px;
    text-align: center;
}

.media-loading-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.media-loading-text {
    font-size: 16px;
}
