/* ================================================
   LINE LIFF App Styles
   ================================================ */

:root {
    --line-green: #00B900;
    --line-green-dark: #009900;
    --line-green-light: #E8F5E9;
    --primary: var(--line-green);
    --primary-dark: var(--line-green-dark);
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --border-color: #E0E0E0;
    --danger: #FF5252;
    --warning: #FFC107;
    --success: #4CAF50;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ================================================
   Loading Screen
   ================================================ */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================================================
   Utility Classes
   ================================================ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* ================================================
   Buttons
   ================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-primary);
    position: relative;
}

/* ================================================
   Badge
   ================================================ */

.badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--danger);
    color: white;
    font-size: 0.625rem;
    font-weight: bold;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ================================================
   Login Screen
   ================================================ */

.screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 100;
}

.center-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

.logo {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* ================================================
   Header
   ================================================ */

.header {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-secondary);
}

/* ================================================
   Navigation Tabs
   ================================================ */

.nav-tabs {
    display: none;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    overflow-x: auto;
    white-space: nowrap;
}

.nav-tab {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

@media (min-width: 768px) {
    .nav-tabs { display: flex; }
    .bottom-nav { display: none; }
}

/* ================================================
   Bottom Navigation (Mobile)
   ================================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.625rem;
    cursor: pointer;
    position: relative;
}

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

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
}

/* ================================================
   Main Content
   ================================================ */

.main-content {
    padding: 1rem;
    padding-bottom: calc(60px + env(safe-area-inset-bottom) + 1rem);
    min-height: calc(100vh - 60px);
}

.page {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* ================================================
   Welcome Banner
   ================================================ */

.welcome-banner {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
}

.welcome-banner h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* ================================================
   Sections
   ================================================ */

.section {
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ================================================
   Product Grid
   ================================================ */

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

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

.product-card:hover {
    transform: translateY(-2px);
}

.product-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--bg-secondary);
}

.product-info {
    padding: 0.75rem;
}

.product-name {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary);
}

.product-seller {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ================================================
   Category Grid
   ================================================ */

.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.category-item {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.category-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.category-name {
    font-size: 0.75rem;
}

/* ================================================
   Search & Filter
   ================================================ */

.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-bar input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-bar select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    font-size: 0.875rem;
}

/* ================================================
   Modal
   ================================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

@media (min-width: 768px) {
    .modal {
        align-items: center;
    }
}

.modal-content {
    background: var(--bg-primary);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.5rem;
    position: relative;
    animation: slideUp 0.3s ease;
}

@media (min-width: 768px) {
    .modal-content {
        border-radius: var(--radius-lg);
    }
}

.modal-lg {
    max-width: 700px;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

/* ================================================
   Product Detail
   ================================================ */

.product-detail-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.product-detail-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.product-detail-price {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 1rem;
}

.product-detail-desc {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.quantity-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.quantity-selector button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-primary);
    font-size: 1.25rem;
    cursor: pointer;
}

.quantity-selector input {
    width: 60px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.5rem;
    font-size: 1rem;
}

/* ================================================
   Cart
   ================================================ */

.cart-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cart-item {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius);
    background: var(--bg-secondary);
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.cart-item-price {
    color: var(--primary);
    font-weight: 600;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-item-qty button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    cursor: pointer;
}

.cart-item-qty span {
    min-width: 30px;
    text-align: center;
}

.cart-item-remove {
    color: var(--danger);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
}

.cart-summary {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
    box-shadow: var(--shadow);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

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

/* ================================================
   Empty State
   ================================================ */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state svg {
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ================================================
   Form
   ================================================ */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* ================================================
   Checkout
   ================================================ */

.checkout-section {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.checkout-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.address-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.address-item {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
}

.address-item.selected {
    border-color: var(--primary);
    background: var(--line-green-light);
}

.address-item-name {
    font-weight: 500;
}

.address-item-detail {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ================================================
   Orders
   ================================================ */

.orders-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.order-card {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.order-number {
    font-weight: 600;
}

.order-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-secondary);
}

.order-status.confirmed {
    background: var(--line-green-light);
    color: var(--primary);
}

.order-status.pending {
    background: #FFF8E1;
    color: #F57C00;
}

.order-date {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.order-total {
    font-weight: 600;
    color: var(--primary);
}

.order-items-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ================================================
   Order Detail
   ================================================ */

.order-detail-header {
    text-align: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.order-detail-number {
    font-size: 1.25rem;
    font-weight: 600;
}

.order-detail-section {
    margin-bottom: 1rem;
}

.order-detail-section h4 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.order-line {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.order-line:last-child {
    border-bottom: none;
}

.order-line-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    background: var(--bg-secondary);
}

.order-line-info {
    flex: 1;
}

.order-line-name {
    font-size: 0.875rem;
}

.order-line-qty {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.order-line-price {
    font-weight: 500;
}

/* ================================================
   Toast
   ================================================ */

#toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--text-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    animation: toastIn 0.3s ease;
    white-space: nowrap;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================
   Pagination
   ================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem 0;
}

#page-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ================================================
   Profile Page
   ================================================ */

.profile-section {
    background: var(--bg-primary);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.profile-header {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-secondary);
}

.profile-info h3 {
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
}

.section-title {
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title svg {
    color: var(--primary);
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-row label {
    font-size: 0.9rem;
}

.setting-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

/* ================================================
   Address Cards
   ================================================ */

.address-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.address-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.address-card-name {
    font-weight: 600;
}

.address-card-phone {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.address-card-detail {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.address-card-actions {
    display: flex;
    gap: 0.5rem;
}

/* ================================================
   Badges
   ================================================ */

.badge-primary {
    background: var(--line-green-light);
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ================================================
   Checkbox Label
   ================================================ */

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* ================================================
   Form Buttons
   ================================================ */

.form-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ================================================
   Shipping Cost
   ================================================ */

.shipping-cost-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.free-shipping-notice {
    background: var(--line-green-light);
    color: var(--primary);
    padding: 0.5rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    text-align: center;
    margin-top: 0.5rem;
}

/* ================================================
   Button Variants
   ================================================ */

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #E53935;
}
