/**
 * WooCommerce Product Memo - Frontend Styles
 */

/* 商品頁面備註欄樣式 */
.wc-product-memo-field {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e1e1e1;
    border-radius: 5px;
}

.wc-product-memo-field label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.wc-product-memo-field label .required {
    color: #e74c3c;
    margin-left: 3px;
}

.wc-product-memo-field textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color 0.3s ease;
}

.wc-product-memo-field textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 5px rgba(0, 115, 170, 0.3);
}

.wc-product-memo-field textarea.memo-limit-reached {
    border-color: #e74c3c;
}

.memo-char-count {
    margin-top: 5px;
    font-size: 12px;
    color: #666;
    text-align: right;
}

.memo-char-count .current-length {
    font-weight: bold;
}

/* 購物車中的備註顯示 */
.cart-item-memo {
    margin-top: 8px;
    padding: 8px;
    background: #f8f8f8;
    border-left: 3px solid #0073aa;
    font-size: 13px;
}

.cart-item-memo strong {
    color: #333;
}

.edit-memo-btn {
    margin-left: 10px;
    padding: 2px 8px;
    font-size: 11px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.edit-memo-btn:hover {
    background: #005a87;
}

/* 備註編輯表單 */
.memo-edit-form {
    margin-top: 10px;
    padding: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.memo-edit-textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    resize: vertical;
    font-size: 13px;
    min-height: 60px;
}

.memo-edit-actions {
    margin-top: 8px;
    text-align: right;
}

.memo-edit-actions button {
    margin-left: 5px;
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 3px;
}

.save-memo-btn {
    background: #27ae60;
    color: white;
    border: none;
}

.save-memo-btn:hover {
    background: #229954;
}

.cancel-memo-btn {
    background: #95a5a6;
    color: white;
    border: none;
}

.cancel-memo-btn:hover {
    background: #7f8c8d;
}

/* 結帳頁面備註顯示 */
.checkout-item-memo {
    margin-top: 5px;
    font-size: 13px;
    color: #666;
}

.checkout-item-memo strong {
    color: #333;
}

/* 訂單詳情頁面備註顯示 */
.order-item-memo {
    margin-top: 8px;
    padding: 8px;
    background: #f0f8ff;
    border-left: 3px solid #3498db;
    font-size: 13px;
    border-radius: 0 4px 4px 0;
}

.order-item-memo strong {
    color: #2980b9;
}

/* 發票中的備註樣式 */
.invoice-item-memo {
    margin-top: 5px;
    font-size: 12px;
    color: #555;
    font-style: italic;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .wc-product-memo-field {
        margin: 15px 0;
        padding: 12px;
    }
    
    .wc-product-memo-field textarea {
        font-size: 16px; /* 防止 iOS 縮放 */
    }
    
    .memo-edit-actions {
        text-align: center;
    }
    
    .memo-edit-actions button {
        display: block;
        width: 100%;
        margin: 5px 0;
    }
    
    .edit-memo-btn {
        display: block;
        margin: 5px 0 0 0;
        width: 60px;
    }
}

/* 主題兼容性 */
.woocommerce .wc-product-memo-field,
.woocommerce-page .wc-product-memo-field {
    box-sizing: border-box;
}

.woocommerce .wc-product-memo-field textarea,
.woocommerce-page .wc-product-memo-field textarea {
    box-sizing: border-box;
}

/* 加載動畫 */
.memo-loading {
    opacity: 0.6;
    pointer-events: none;
}

.memo-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: memo-spin 1s linear infinite;
}

@keyframes memo-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 錯誤狀態 */
.memo-error {
    border-color: #e74c3c !important;
    background-color: #fdf2f2;
}

.memo-error-message {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 5px;
}

/* 成功狀態 */
.memo-success {
    border-color: #27ae60 !important;
    background-color: #f2fdf5;
}

/* 高對比度模式支持 */
@media (prefers-contrast: high) {
    .wc-product-memo-field {
        border-color: #000;
    }
    
    .wc-product-memo-field textarea {
        border-color: #000;
    }
    
    .cart-item-memo {
        border-left-color: #000;
    }
}

