/* ТК-Удачный Mini App Styles */

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

:root {
    --primary-color: #409eff;
    --success-color: #67c23a;
    --danger-color: #f56c6c;
    --warning-color: #e6a23c;
    --info-color: #909399;
    --text-color: #303133;
    --text-secondary: #606266;
    --border-color: #dcdfe6;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 16px;
    line-height: 1.5;
}

#app {
    width: 100%;
    min-height: 100vh;
}

/* Loading Screen */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    font-size: 18px;
}

.loading-screen .el-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* Mini App Container */
.mini-app {
    max-width: 600px;
    margin: 0 auto;
    background-color: var(--bg-color);
    min-height: 100vh;
    padding-bottom: 60px;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color), #66b1ff);
    color: white;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
}

.logo-icon {
    font-size: 24px;
}

.cart-icon {
    cursor: pointer;
    padding: 4px;
}

/* Search Bar */
.search-bar {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

/* Content Area */
.app-content {
    padding: 16px;
}

.page {
    animation: fadeIn 0.3s ease;
}

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

/* Home Page */
.welcome-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.welcome-banner h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.action-card {
    background: white;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}

.action-card:active {
    transform: scale(0.95);
}

.action-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.action-label {
    font-size: 14px;
    font-weight: 500;
}

/* Sections */
.section-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 12px;
    color: var(--text-color);
}

/* Categories */
.categories-section {
    margin-bottom: 24px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

.category-card {
    background: white;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}

.category-card:active {
    transform: scale(0.95);
}

.category-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.category-name {
    font-size: 13px;
    font-weight: 500;
}

/* Products */
.products-section {
    margin-bottom: 24px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}

.product-card:active {
    transform: scale(0.98);
}

.product-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: #f5f5f5;
}

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

.placeholder-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: #f5f5f5;
}

.badge-new {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--success-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

.badge-hit {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--danger-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

.product-info {
    padding: 12px;
}

.product-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.3;
    max-height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-price {
    display: flex;
    align-items: center;
    gap: 8px;
}

.current-price {
    font-size: 18px;
    font-weight: bold;
    color: var(--danger-color);
}

.old-price {
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: line-through;
}

.product-stock {
    font-size: 12px;
    color: var(--success-color);
    margin-top: 4px;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.page-header h2 {
    font-size: 20px;
    font-weight: bold;
}

/* Catalog Page */
.category-filter {
    margin-bottom: 16px;
}

/* Cart Page */
.cart-content {
    background: white;
    border-radius: 12px;
    padding: 16px;
}

.empty-cart {
    text-align: center;
    padding: 40px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.cart-items {
    margin-bottom: 20px;
}

.cart-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.cart-item:last-child {
    border-bottom: none;
}

.item-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
}

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

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.item-price {
    color: var(--danger-color);
    font-weight: bold;
}

.item-controls {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
}

.item-controls-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
    width: 100%;
}

.item-controls-mobile .el-button {
    flex-shrink: 0;
}

.delete-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    background-color: #f56c6c !important;
    color: white !important;
    border: 1px solid #f56c6c !important;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    display: inline-block !important;
    min-width: 80px;
    text-align: center;
    height: 32px;
    line-height: 14px;
}

.delete-btn:active {
    background-color: #f23434 !important;
}

.cart-summary {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 12px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 16px;
}

.summary-row.bonus-row {
    color: var(--warning-color);
    font-weight: 500;
}

/* Profile Page */
.user-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    cursor: pointer;
}

.user-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    background: #f0f9ff;
}

.user-avatar {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.user-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 4px;
}

.user-phone,
.user-email {
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.user-id {
    color: var(--info-color);
    font-size: 12px;
    margin-top: 4px;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.profile-menu {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:active {
    background: var(--bg-color);
}

.menu-item.danger {
    color: var(--danger-color);
}

/* Orders Section */
.orders-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    box-shadow: var(--shadow);
}

.orders-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-color);
}

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.order-item {
    padding: 12px;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

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

.order-id {
    font-weight: bold;
    color: var(--primary-color);
}

.order-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.order-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-amount {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-color);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 600px;
    margin: 0 auto;
    background: white;
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    font-size: 12px;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item .el-icon {
    font-size: 24px;
}

/* Product Detail Dialog */
.product-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.product-gallery {
    width: 100%;
    padding-top: 100%;
    position: relative;
    background: #f5f5f5;
    border-radius: 12px;
    overflow: hidden;
}

.product-gallery img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.placeholder-image-large {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
}

.product-info-detail {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 12px;
}

.product-tags {
    margin-bottom: 12px;
}

.product-price-detail {
    margin-bottom: 12px;
}

.product-description {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.6;
}

.product-stock-detail {
    color: var(--success-color);
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-actions {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Element Plus Overrides */
.el-input__wrapper {
    border-radius: 12px !important;
}

.el-button {
    border-radius: 12px;
}

.el-dialog {
    border-radius: 16px !important;
}

/* Checkout Page */
.checkout-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.checkout-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.checkout-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-color);
}

.delivery-option {
    display: flex;
    width: 100%;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.delivery-option:hover {
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.option-content {
    margin-left: 8px;
}

.option-title {
    font-weight: bold;
    font-size: 15px;
}

.option-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.pickup-option {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pickup-name {
    font-weight: bold;
}

.pickup-address {
    font-size: 12px;
    color: var(--text-secondary);
}

.bonus-section {
    background: linear-gradient(135deg, #fff9e6, #fff3cd);
    border: 1px solid #ffc107;
}

.bonus-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.bonus-applied {
    margin-top: 8px;
    padding: 8px;
    background: rgba(103, 194, 58, 0.1);
    border-radius: 8px;
    color: var(--success-color);
    font-weight: bold;
}

.summary-section {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border: 1px solid #3b82f6;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.summary-row.total-row {
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 16px;
    font-weight: bold;
}

.total-amount {
    color: var(--primary-color);
    font-size: 20px;
}

.bonus-row {
    color: var(--success-color);
}

/* Order Success Page */
.order-success-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
}

.success-content {
    text-align: center;
    padding: 32px;
    max-width: 400px;
}

.success-icon {
    font-size: 80px;
    margin-bottom: 16px;
}

.success-content h2 {
    font-size: 24px;
    margin-bottom: 16px;
    color: var(--text-color);
}

.order-info {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
}

.order-info p {
    margin: 8px 0;
    font-size: 14px;
}

.payment-section {
    margin: 24px 0;
}

.success-info {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 16px 0;
}

.success-info p {
    margin: 8px 0;
}

/* Profile Enhancements */
.profile-stats-extended {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.profile-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
    box-shadow: var(--shadow);
}

.profile-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--text-color);
}

.favorite-category {
    padding: 12px;
    background: linear-gradient(135deg, #fff5f5, #ffe0e0);
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    color: var(--danger-color);
}

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

.section-header h3 {
    margin: 0;
}

.order-item {
    cursor: pointer;
    transition: all 0.2s;
}

.order-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
}

.user-member-since {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Bonus History */
.bonus-history {
    padding: 16px 0;
}

.bonus-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bonus-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 8px;
}

.bonus-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
}

.bonus-info {
    flex: 1;
}

.bonus-description {
    font-weight: 500;
    color: var(--text-color);
}

.bonus-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.bonus-amount {
    font-weight: bold;
    font-size: 16px;
}

.bonus-amount.positive {
    color: var(--success-color);
}

.bonus-amount.negative {
    color: var(--danger-color);
}

/* Settings */
.settings-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-color);
    border-radius: 8px;
}

.setting-info {
    flex: 1;
}

.setting-title {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 4px;
}

.setting-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Edit Profile Dialog */
.edit-profile-dialog .el-dialog__body {
    padding: 16px !important;
    max-height: 60vh;
    overflow-y: auto;
}

.edit-profile-dialog .el-dialog__footer {
    padding: 16px !important;
    border-top: 1px solid var(--border-color);
    background: white;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/* Phone input */
.phone-input .el-input__inner {
    font-size: 16px !important;
    letter-spacing: 0.5px;
}

.phone-input .el-input-group__prepend {
    padding: 0 8px;
}

/* Date Picker improvements */
.birthday-input {
    font-size: 16px !important;
    padding: 10px 12px !important;
    border: 1px solid #dcdfe6 !important;
    border-radius: 4px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #303133;
    background-color: #fff;
}

.birthday-input:focus {
    outline: none;
    border-color: #409eff !important;
}

.birthday-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
}

.birthday-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Auth Dialog */
.auth-dialog .el-dialog__body {
    padding: 20px !important;
}

.auth-dialog .el-input__wrapper {
    border-radius: 8px !important;
}

.auth-dialog .el-input__inner {
    font-size: 18px !important;
    letter-spacing: 1px;
    text-align: center;
    font-weight: 500;
}

/* Mobile fix for dialogs */
@media (max-width: 480px) {
    .el-dialog {
        margin: 5vh auto !important;
        max-height: 90vh;
    }

    .el-dialog__body {
        max-height: calc(90vh - 200px);
        overflow-y: auto;
    }

    .edit-profile-dialog .el-form-item {
        margin-bottom: 16px;
    }

    .edit-profile-dialog .el-input__inner {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* ==================== CATEGORY PAGE ==================== */

.page-header-category {
    background: white;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.category-title-back {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.category-title-back::before {
    content: '←';
    font-size: 20px;
}

.category-title-back:active {
    opacity: 0.6;
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.breadcrumb-item {
    color: var(--primary-color);
    cursor: pointer;
    transition: opacity 0.2s;
}

.breadcrumb-item:hover {
    opacity: 0.7;
}

.breadcrumb-item.current {
    color: var(--text-secondary);
    cursor: default;
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--text-secondary);
}

/* Subcategories */
.subcategories-section {
    padding: 16px;
}

.subcategories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.subcategory-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.subcategory-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.subcategory-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: 12px;
    flex-shrink: 0;
}

.subcategory-info {
    flex: 1;
    min-width: 0;
}

.subcategory-name {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subcategory-desc {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subcategory-arrow {
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Category Products */
.category-products-section {
    padding: 16px;
    padding-top: 0;
}

/* Catalog breadcrumbs */
.catalog-breadcrumbs {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}


