/* 
 * Telegram Mini App Modern UI 
 * Project: Onemoney
 */

:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #222222;
    --tg-theme-hint-color: #707579;
    --tg-theme-link-color: #3390ec;
    --tg-theme-button-color: #3390ec;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #f4f4f5;
    
    --primary: #3390ec;
    --primary-light: #e3f2fd;
    --secondary: #6c757d;
    --success: #4caf50;
    --danger: #f44336;
    --warning: #ff9800;
    
    --card-shadow: 0 4px 12px rgba(0,0,0,0.05);
    --border-radius: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ton-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    margin-right: 2px;
    object-fit: contain;
}

.ton-icon-lg {
    width: 1.2em;
    height: 1.2em;
    vertical-align: -0.2em;
}

/* Telegram Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --tg-theme-bg-color: #1c1c1d;
        --tg-theme-text-color: #ffffff;
        --tg-theme-hint-color: #aeb5ba;
        --tg-theme-secondary-bg-color: #2c2c2e;
    }
}

body {
    background-color: var(--tg-theme-secondary-bg-color); /* Use secondary bg for outside container */
    color: var(--tg-theme-text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0 auto;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 600px; /* Mobile width container */
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    background-color: var(--tg-theme-bg-color); /* Inner content bg */
    position: relative;
    padding-bottom: 80px;
}

/* App Header */
.app-header {
    background: var(--tg-theme-bg-color);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #3390ec 0%, #0077ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Category Slider */
.category-container {
    padding: 12px 0;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.category-container::-webkit-scrollbar {
    display: none;
}

.category-item {
    display: inline-block;
    padding: 8px 16px;
    margin: 0 6px;
    border-radius: 20px;
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}

.category-item.active {
    background: var(--tg-theme-link-color);
    color: white;
}

/* Product Grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px;
}

.product-card {
    background: var(--tg-theme-bg-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
}

.product-image-container {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio */
    overflow: hidden;
    background: #f8f9fa;
}

.product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.4;
    height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.price {
    color: var(--danger);
    font-size: 16px;
    font-weight: 700;
}

.add-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--tg-theme-link-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.add-btn:active {
    transform: scale(0.9);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--tg-theme-bg-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    border-top: 1px solid rgba(0,0,0,0.05);
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--tg-theme-hint-color);
    font-size: 10px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 4px;
}

.nav-item.active {
    color: var(--tg-theme-link-color);
}

/* Badge */
.nav-badge {
    position: absolute;
    top: 5px;
    right: 25%;
    background: var(--danger);
    color: white;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* Sections */
.section-title {
    padding: 12px 16px;
    font-size: 18px;
    font-weight: 700;
}

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

.animate-fade {
    animation: fadeIn 0.4s ease forwards;
}

/* Product Detail Page */
.product-detail-img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
}

.product-detail-info {
    padding: 20px;
}

.pd-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 12px;
}

.pd-price-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 16px;
}

.pd-price {
    font-size: 24px;
    font-weight: 800;
    color: var(--danger);
}

.pd-original-price {
    font-size: 14px;
    text-decoration: line-through;
    color: var(--tg-theme-hint-color);
}

.pd-meta {
    display: flex;
    gap: 20px;
    color: var(--tg-theme-hint-color);
    font-size: 13px;
    margin-bottom: 24px;
}

.pd-description {
    font-size: 15px;
    line-height: 1.6;
    color: var(--tg-theme-text-color);
}

/* Fixed Bottom Action Bar */
.bottom-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--tg-theme-bg-color);
    padding: 12px 16px env(safe-area-inset-bottom);
    display: flex;
    gap: 12px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    z-index: 1001;
}

.btn-buy {
    flex: 1;
    height: 48px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-buy-primary {
    background: var(--tg-theme-link-color);
    color: white;
}

.btn-buy-secondary {
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    width: 60px;
    flex: 0 0 60px;
}

/* Cart & Address Page */
.cart-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.cart-item {
    background: var(--tg-theme-bg-color);
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    gap: 12px;
    box-shadow: var(--card-shadow);
}
.cart-item-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: #f5f5f5;
}
.cart-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.cart-item-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cart-item-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--danger);
    margin-top: auto;
    margin-bottom: 8px;
}
.cart-item-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.qty-control {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
}
.qty-control i {
    color: var(--tg-theme-link-color);
    cursor: pointer;
}
.address-section {
    padding: 0 16px 16px;
}
.address-card {
    background: var(--tg-theme-bg-color);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--card-shadow);
    cursor: pointer;
    transition: var(--transition);
}
.address-card.active {
    border-color: var(--tg-theme-link-color);
    background: var(--primary-light);
}
.checkout-summary {
    background: var(--tg-theme-bg-color);
    margin: 16px;
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}
.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}
.summary-row:last-child {
    margin-bottom: 0;
}
