/* /mini_app/style.css */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f5f5;
    color: #1a1a2e;
    padding-bottom: 80px;
}

/* ===== HEADER ===== */
.app-header {
    background: #16213e;
    color: white;
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}

.app-header h1 {
    font-size: 20px;
    font-weight: bold;
}

.cart-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cart-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== MAIN CONTENT ===== */
.app-main {
    max-width: 500px;
    margin: 0 auto;
    padding: 15px;
}

/* ===== SEARCH BAR ===== */
.search-bar {
    margin-bottom: 15px;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    background: white;
    outline: none;
}

.search-bar input:focus {
    border-color: #16213e;
}

/* ===== CARD GRID ===== */
.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ===== CARD ITEM ===== */
.card-item {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s;
}

.card-item:hover {
    transform: translateY(-2px);
}

.card-item img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    background: #f8f9fa;
    padding: 5px;
}

.card-image-placeholder {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: #f8f9fa;
}

.card-info {
    padding: 10px 12px;
}

.card-number {
    font-size: 11px;
    color: #888;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-price {
    font-size: 14px;
    font-weight: bold;
    color: #16213e;
}

.stock-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    margin-top: 4px;
}

.in-stock {
    background: #d1e7dd;
    color: #0f5132;
}

.out-of-stock {
    background: #f8d7da;
    color: #842029;
}

/* ===== CARD DETAIL PAGE ===== */
.detail-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px 15px;
}

.detail-image {
    width: 100%;
    max-height: 350px;
    object-fit: contain;
    background: white;
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 20px;
}

.detail-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

.detail-number {
    font-size: 16px;
    color: #888;
    margin-bottom: 15px;
}

.detail-info {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.detail-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detail-info-row:last-child {
    border-bottom: none;
}

.detail-info-label {
    color: #888;
}

.detail-info-value {
    font-weight: 500;
}

.detail-price {
    font-size: 28px;
    font-weight: bold;
    color: #16213e;
    margin: 15px 0;
}

/* ===== BUTTONS ===== */
.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary {
    background: #16213e;
    color: white;
}

.btn-primary:hover {
    background: #1a2a4a;
}

.btn-secondary {
    background: #e9ecef;
    color: #1a1a2e;
}

.btn-secondary:hover {
    background: #dee2e6;
}

.btn-success {
    background: #198754;
    color: white;
}

.btn-success:hover {
    background: #157347;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #bb2d3b;
}

.quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 15px 0;
}

.quantity-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: white;
    font-size: 20px;
    cursor: pointer;
}

.quantity-btn:hover {
    background: #f0f0f0;
}

.quantity-display {
    font-size: 20px;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
}

/* ===== CART PAGE ===== */
.cart-item {
    display: flex;
    gap: 12px;
    background: white;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    align-items: center;
}

.cart-item-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: #f8f9fa;
    border-radius: 8px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    font-size: 14px;
}

.cart-item-number {
    font-size: 12px;
    color: #888;
}

.cart-item-price {
    font-weight: bold;
    font-size: 14px;
    color: #16213e;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item-actions button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: white;
    font-size: 14px;
    cursor: pointer;
}

.cart-item-actions button:hover {
    background: #f0f0f0;
}

.cart-item-qty {
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

.cart-summary {
    background: white;
    border-radius: 12px;
    padding: 15px;
    margin-top: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: sticky;
    bottom: 0;
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 16px;
}

.cart-total-row.bold {
    font-weight: bold;
    font-size: 18px;
    border-top: 2px solid #eee;
    padding-top: 12px;
    margin-top: 5px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
    .card-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .card-item img {
        height: 140px;
    }
    
    .card-image-placeholder {
        height: 140px;
        font-size: 36px;
    }
    
    .card-name {
        font-size: 12px;
    }
}

/* ===== TELEGRAM MINI APP ADJUSTMENTS ===== */
body.tg-app {
    background: var(--tg-theme-bg-color, #f5f5f5);
    color: var(--tg-theme-text-color, #1a1a2e);
}

.tg-app .app-header {
    background: var(--tg-theme-secondary-bg-color, #16213e);
}