/* ================================
   三角梅花卉电商 - 主样式文件
   ================================ */

/* 引入样式模块 */
@import url('variables.css');
@import url('components.css');

/* 引入Google Fonts中文字体 */
@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Noto+Sans+SC:wght@300;400;500;700&family=Noto+Serif+SC:wght@400;600;700&display=swap');

/* ===== 基础重置 ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background-color: var(--color-background);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 主内容区域留出导航栏空间 */
main {
    padding-top: var(--navbar-height);
}

/* ===== 排版 ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: var(--font-bold);
    line-height: var(--leading-tight);
    color: var(--color-text);
    margin-bottom: var(--space-4);
}

h1 {
    font-size: var(--text-4xl);
}

h2 {
    font-size: var(--text-3xl);
}

h3 {
    font-size: var(--text-2xl);
}

h4 {
    font-size: var(--text-xl);
}

h5 {
    font-size: var(--text-lg);
}

h6 {
    font-size: var(--text-base);
}

p {
    margin-bottom: var(--space-4);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-secondary);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== 布局容器 ===== */
.container {
    width: 100%;
    max-width: var(--container-xl);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.container-sm {
    max-width: var(--container-sm);
}

.container-md {
    max-width: var(--container-md);
}

.container-lg {
    max-width: var(--container-lg);
}

/* ===== Flexbox工具类 ===== */
.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.items-end {
    align-items: flex-end;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-2 {
    gap: var(--space-2);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

.gap-8 {
    gap: var(--space-8);
}

/* ===== Grid工具类 ===== */
.grid {
    display: grid;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ===== 间距工具类 ===== */
.m-0 {
    margin: 0;
}

.m-4 {
    margin: var(--space-4);
}

.mt-4 {
    margin-top: var(--space-4);
}

.mt-8 {
    margin-top: var(--space-8);
}

.mb-4 {
    margin-bottom: var(--space-4);
}

.mb-8 {
    margin-bottom: var(--space-8);
}

.my-8 {
    margin-top: var(--space-8);
    margin-bottom: var(--space-8);
}

.my-12 {
    margin-top: var(--space-12);
    margin-bottom: var(--space-12);
}

.p-0 {
    padding: 0;
}

.p-4 {
    padding: var(--space-4);
}

.p-6 {
    padding: var(--space-6);
}

.p-8 {
    padding: var(--space-8);
}

.py-8 {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
}

.py-12 {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
}

.py-16 {
    padding-top: var(--space-16);
    padding-bottom: var(--space-16);
}

.px-4 {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

.px-6 {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
}

/* ===== 文本工具类 ===== */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.text-sm {
    font-size: var(--text-sm);
}

.text-lg {
    font-size: var(--text-lg);
}

.text-xl {
    font-size: var(--text-xl);
}

.text-2xl {
    font-size: var(--text-2xl);
}

.font-light {
    font-weight: var(--font-light);
}

.font-normal {
    font-weight: var(--font-normal);
}

.font-medium {
    font-weight: var(--font-medium);
}

.font-bold {
    font-weight: var(--font-bold);
}

.text-muted {
    color: var(--color-text-muted);
}

.text-primary {
    color: var(--color-primary);
}

.text-secondary {
    color: var(--color-secondary);
}

/* ===== 显示工具类 ===== */
.hidden {
    display: none;
}

.block {
    display: block;
}

.inline-block {
    display: inline-block;
}

/* ===== 区块样式 ===== */
.section {
    padding: var(--space-16) 0;
}

.section-title {
    font-family: var(--font-decorative);
    font-size: var(--text-3xl);
    color: var(--color-text);
    text-align: center;
    margin-bottom: var(--space-4);
}

.section-subtitle {
    font-size: var(--text-lg);
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: var(--space-10);
}

/* ===== 产品网格 ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-6);
}

/* ===== 页面标题区域 ===== */
.page-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    padding: var(--space-12) 0;
    text-align: center;
    color: var(--color-white);
}

.page-header h1 {
    font-family: var(--font-decorative);
    font-size: var(--text-4xl);
    color: var(--color-white);
    margin-bottom: var(--space-2);
}

.page-header p {
    font-size: var(--text-lg);
    opacity: 0.9;
    margin-bottom: 0;
}

/* ===== 购物车样式 ===== */
.cart-item {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.cart-item-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    color: var(--color-text);
    margin-bottom: var(--space-2);
}

.cart-item-price {
    font-size: var(--text-lg);
    font-weight: var(--font-bold);
    color: var(--color-price);
}

.cart-quantity {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.cart-quantity button {
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-lg);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.cart-quantity button:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white);
}

.cart-quantity input {
    width: 50px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
}

/* ===== 订单摘要 ===== */
.order-summary {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-card);
}

.order-summary-title {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    color: var(--color-text);
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 2px solid var(--color-primary);
}

.order-summary-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}

.order-summary-total {
    display: flex;
    justify-content: space-between;
    padding-top: var(--space-4);
    margin-top: var(--space-4);
    border-top: 2px solid var(--color-primary);
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
}

.order-summary-total .total-price {
    color: var(--color-price);
}

/* ===== 响应式设计 ===== */
@media (max-width: 1024px) {
    .grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .section {
        padding: var(--space-10) 0;
    }
}

@media (max-width: 480px) {

    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 0 var(--space-4);
    }

    .cart-item {
        flex-direction: column;
    }

    .cart-item-image {
        width: 100%;
        height: 150px;
    }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-slow) ease forwards;
}

.animate-slide-up {
    animation: slideUp var(--transition-slow) ease forwards;
}

/* ===== 加载状态 ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-cream-dark);
    border-top-color: var(--color-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== 消息提示 ===== */
.toast {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    padding: var(--space-4) var(--space-6);
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-tooltip);
    animation: slideUp var(--transition-base) ease;
}

.toast-success {
    background: var(--color-success);
}

.toast-error {
    background: var(--color-error);
}

/* ===== 花朵装饰背景 ===== */
.flower-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 30c-5 0-10 5-10 15s5 15 10 15 10-5 10-15-5-15-10-15zm15 20c0-5 5-10 15-10s15 5 15 10-5 10-15 10-15-5-15-10zm-30 0c0-5-5-10-15-10S5 45 5 50s5 10 15 10 15-5 15-10zm15 15c5 0 10 5 10 15s-5 15-10 15-10-5-10-15 5-15 10-15z' fill='%23E91E63'/%3E%3C/svg%3E");
    background-size: 60px 60px;
    pointer-events: none;
}