/**
 * 光貿電子發票會員中心樣式
 * 
 * @package WooCommerce_Amego_Invoice
 * @version 1.0.0
 */

/* 發票頁面主容器 */
.amego-invoices-page {
    text-align: left;
}

/* 若此頁在非 WooCommerce 的 My Account 版型中被載入（沒有 body.woocommerce-account），
   預設的 .woocommerce-MyAccount-content 會在許多佈景下 float:right；
   這裡將其重置為全寬避免整體內容貼右側。 */
/* 使用 WooCommerce 預設 My Account 版型；此頁不再覆寫容器浮動與寬度。 */

/* 頁面標題區域 */
.amego-invoices-header {
    margin-bottom: 1em;
}

.amego-invoices-header h2 {
    margin: 0;
}

.amego-invoices-description {
    margin: 0;
    color: #666;
    font-size: 16px;
    line-height: 1.5;
}

/* 統計區域 */
.amego-invoices-stats {
    display: flex;
    gap: 16px;
    margin: 0 0 1em;
    padding: 12px;
    background: #f7f7f7;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    color: inherit;
}

.amego-stat-item {
    flex: 1;
    text-align: center;
}

.amego-stat-number {
    display: block;
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.amego-stat-label {
    display: block;
    font-size: 14px;
    opacity: 0.9;
}

/* 發票表格 */
.amego-invoices-table-wrapper {
    overflow-x: auto;
    margin-bottom: 1em;
}

.amego-invoices-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.amego-invoices-table th,
.amego-invoices-table td {
    padding: 15px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.amego-invoices-table th.invoice-status,
.amego-invoices-table td.invoice-status,
.amego-invoices-table th.invoice-actions,
.amego-invoices-table td.invoice-actions {
    text-align: center;
}

.amego-invoices-table th.invoice-status,
.amego-invoices-table td.invoice-status {
    width: 120px;
}

.amego-invoices-table th.invoice-actions,
.amego-invoices-table td.invoice-actions {
    width: 180px;
}

.amego-invoices-table th {
    background: transparent;
    font-weight: 600;
    color: inherit;
    font-size: inherit;
}

.amego-invoices-table tbody tr {
    transition: background-color 0.3s ease;
}

.amego-invoices-table tbody tr:hover {
    background-color: #f8f9fa;
}

/* 發票狀態樣式 */
.invoice-status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.invoice-status-badge.status-pending {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.invoice-status-badge.status-issued {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.invoice-status-badge.status-cancelled {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.invoice-status-badge.status-failed {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* 操作按鈕 */
.invoice-actions-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.invoice-actions-buttons .button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.amego-download-btn {
    background-color: #007cba;
    color: white;
    border: 1px solid #007cba;
}

.amego-download-btn:hover {
    background-color: #005a87;
    border-color: #005a87;
}

.amego-download-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.invoice-actions-buttons .button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

/* 小文字樣式 */
.random-code,
.order-date {
    color: #666;
    font-size: 11px;
}

.text-muted {
    color: #999;
}

.amego-invoice-download-note {
    margin-top: 15px;
    color: #666;
    font-size: 13px;
}

.woocommerce-order-invoice .shop_table {
    width: 100%;
}

.woocommerce-order-invoice .invoice-status {
    text-align: left;
}

.woocommerce-order-invoice .invoice-actions {
    text-align: left;
}

.woocommerce-order-invoice .invoice-actions-buttons {
    justify-content: flex-start;
}

@media (max-width: 768px) {

    .woocommerce-order-invoice .shop_table_responsive tr th {
        display: none;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td {
        display: block;
        width: 100%;
        padding: 12px 16px;
        border-bottom: 1px solid #e0e0e0;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td:before {
        content: attr(data-title);
        font-weight: 600;
        color: #333;
        margin-bottom: 8px;
        display: block;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td.invoice-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 12px 16px;
        border-bottom: 1px solid #e0e0e0;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td.invoice-actions:before {
        content: attr(data-title);
        font-weight: 600;
        color: #333;
        margin-bottom: 0;
        margin-right: 16px;
        flex-shrink: 0;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td.invoice-actions .invoice-actions-buttons {
        margin-left: auto;
        width: auto;
        flex-wrap: nowrap;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td.invoice-actions .invoice-actions-buttons .button {
        width: auto;
        min-width: 80px;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td.invoice-status {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 12px 16px;
        border-bottom: 1px solid #e0e0e0;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td.invoice-status:before {
        content: attr(data-title);
        font-weight: 600;
        color: #333;
        margin-bottom: 0;
        margin-right: 16px;
        flex-shrink: 0;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td.invoice-status .invoice-status-badge {
        margin-left: auto;
        text-align: right;
    }

    .woocommerce-order-invoice .shop_table_responsive tr td.invoice-actions:before {
        margin-bottom: 4px;
    }
}

/* 分頁 */
.amego-invoices-pagination {
    text-align: center;
    margin-top: 1em;
}

.amego-invoices-pagination .page-numbers {
    display: inline-block;
    margin: 0 2px;
}

/* 無發票狀態 */
.amego-no-invoices {
    text-align: center;
    padding: 40px 20px;
}

.amego-no-invoices .button {
    float: none !important;
    /* 覆寫 Woo 預設將通知內按鈕靠右的樣式 */
    display: inline-block;
    margin: 16px auto 0;
}

.amego-no-invoices-icon {
    margin-bottom: 20px;
}

.amego-no-invoices-icon .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    color: #ccc;
}

.amego-no-invoices h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 24px;
}

.amego-no-invoices p {
    margin: 0 0 25px 0;
    color: #666;
    font-size: 16px;
}

/* 載入動畫 */
.dashicons.spin {
    animation: amego-spin 1s linear infinite;
}

@keyframes amego-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .amego-invoices-stats {
        flex-direction: column;
    }

    /* 手機版將金額與狀態欄位拉滿，避免表格被固定寬度撐開 */
    .amego-invoices-table th.invoice-amount,
    .amego-invoices-table td.invoice-amount,
    .amego-invoices-table th.invoice-status,
    .amego-invoices-table td.invoice-status,
    .amego-invoices-table th.invoice-actions,
    .amego-invoices-table td.invoice-actions {
        width: 100% !important;
        display: block;
        text-align: left;
    }

    .amego-invoices-table td.invoice-status .invoice-status-badge {
        display: inline-block;
        margin-top: 4px;
    }

    .invoice-actions-buttons {
        justify-content: flex-end;
    }
}

/* 交由 WooCommerce 的 shop_table_responsive 處理小螢幕表格，移除客製卡片樣式 */

/* 高對比模式支援 */
@media (prefers-contrast: high) {
    .amego-invoices-table {
        border: 2px solid #000;
    }

    .amego-invoices-table th,
    .amego-invoices-table td {
        border-bottom: 1px solid #000;
    }

    .invoice-status-badge {
        border-width: 2px;
    }
}

/* 深色模式支援 */
/* 深色模式交由佈景/ WooCommerce 樣式處理，避免過度覆蓋 */

/* 列印樣式 */
@media print {

    .amego-invoices-stats,
    .invoice-actions,
    .amego-invoices-pagination {
        display: none !important;
    }

    .amego-invoices-table {
        border-collapse: collapse;
        width: 100%;
    }

    .amego-invoices-table th,
    .amego-invoices-table td {
        border: 1px solid #000;
        padding: 8px;
    }
}

/* 只在本外掛頁面啟用的 My Account 佈局修正（避免受主題將內容整體推到右側） */
/* 不新增自訂布局類別，維持核心與佈景預設行為。 */