/* 주문 내역 페이지 스타일 */

/* 사이드바 메뉴 스타일 */
.sidebar-menu {
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    padding: 1.5rem;
}

@media (min-width: 992px) {
    .sidebar-menu {
        background-color: transparent;
        border: none;
        border-radius: 0;
        padding: 0;
    }
}

.sidebar-heading {
    color: #777;
    letter-spacing: 0.05rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.nav-link {
    color: #000;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
    padding-left: 0.25rem;
}

.nav-link.active {
    color: var(--primary-color);
    font-weight: 600;
}

.user-menu-section {
    margin-bottom: 1.5rem;
}

.user-menu-section:last-child {
    margin-bottom: 0;
}

/* 메인 컨텐츠 영역 */
.content-wrapper {
    background-color: #fff;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.page-title {
    color: #333;
    padding: 0;
}

/* 필터 영역 */
.filter-container {
    margin-bottom: 2rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1.25rem;
    border: 1px solid #eee;
}

.filter-body {
    display: flex;
    align-items: stretch;
}

.filter-rows {
    flex: 1;
}

.filter-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-label {
    width: 80px;
    min-width: 80px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.filter-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

/* P0-12 (리뷰 #12): Bootstrap .btn 의 .btn-primary/.btn-secondary 클래스 충돌 방지를 위해
   선택자 우선순위를 .filter-container .btn.filter-btn (specificity 0,3,0) 으로 구체화 +
   기본 .btn 색상을 명시적 reset 하여 !important 12개 모두 제거. */
.filter-container .btn.filter-btn {
    border: 1px solid #ccc;
    background-color: #fff;
    color: #333;
    border-radius: 2rem;
    padding: 0.3rem 1rem;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.filter-container .btn.filter-btn:hover,
.filter-container .btn.filter-btn:focus {
    border-color: #999;
    background-color: #f0f0f0;
    color: #333;
}

/* 필터 버튼 active — Bootstrap .btn-check:checked+.btn / .btn.active / .btn:focus
   조합과의 cascade 충돌을 selector 강화로 막을 수 없어 핵심 3속성만 !important 유지.
   (12개 hack 중 active 시각 식별 실패가 가독성 직결되어 가장 critical — !important 정당.) */
#filterForm .filter-btn.active,
#filterForm .filter-btn.active:hover,
#filterForm .filter-btn.active:focus {
    background-color: #444 !important;
    border-color: #444 !important;
    color: #fff !important;
}

/* 조회 버튼 — 부모(.filter-body) 가 길어져도 버튼 자체 height 유지.
   stretch + min-height:100% 조합으로 132px 까지 늘어나던 문제 해소. */
.filter-search {
    display: flex;
    align-items: center;
    margin-left: 1.25rem;
}

.btn-search {
    background-color: var(--primary-color, #7E4F22);
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    padding: 0.5rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    height: auto;
    align-self: center;
}

.btn-search:hover {
    background-color: #6a4220;
    color: #fff;
}

.date-picker-container {
    max-width: 330px;
}

/* 모바일 필터 */
@media (max-width: 767.98px) {
    .filter-body {
        flex-direction: column;
    }

    .filter-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-label {
        width: auto;
        min-width: auto;
        margin-bottom: 0.375rem;
    }

    .filter-search {
        margin-left: 0;
        margin-top: 0.75rem;
    }

    .date-picker-container {
        max-width: 100%;
        flex-direction: column;
    }

    .btn-search {
        width: 100%;
        padding: 0.5rem 1.5rem;
    }

    .filter-container {
        padding: 1rem 0;
    }

    .date-picker-container {
        max-width: 100%;
        width: 100%;
    }
}

/* 주문 항목 스타일 */
.order-list-container {
    margin-bottom: 1.5rem;
}

.order-item {
    margin-bottom: 1.25rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.order-item:hover {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #eee;
    background-color: #f9f9f9;
}

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

.order-date {
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
}

.order-date::before {
    content: '\F1EF';
    font-family: 'Bootstrap-icons';
    margin-right: 0.5rem;
    color: #8b6a3d;
    font-size: 1.1rem;
}

.order-number-text {
    color: #666;
    font-weight: 500;
}

.order-payment-link {
    color: var(--primary-color, #7E4F22);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s;
}

.order-payment-link:hover {
    color: #6a4220;
    text-decoration: underline;
}

.order-number {
    color: #666;
}

.order-detail-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.order-detail-link:hover {
    text-decoration: underline;
}

/* ---------- 상품별 행 ---------- */
.order-items-body {
    border-bottom: 1px solid #eee;
}

.order-item-row {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    gap: 1rem;
}

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

.order-item-row.item-cancelled {
    opacity: 0.5;
}

.oi-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 0.375rem;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid #eee;
}

.oi-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

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

.oi-name {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.oi-name:hover {
    color: var(--primary-color, #7E4F22);
    text-decoration: underline;
}

.oi-option {
    font-size: 0.85rem;
    color: #888;
}

.oi-shipping-info {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.oi-shipping-info .bi-truck {
    font-size: 0.75rem;
}

.oi-shipping-condition {
    color: #aaa;
    font-size: 0.75rem;
}

.oi-price-qty {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 100px;
    flex-shrink: 0;
}

.oi-qty {
    font-size: 0.85rem;
    color: #666;
}

.oi-price {
    font-weight: 600;
    color: #222;
    font-size: 0.95rem;
}

.oi-status {
    min-width: 80px;
    text-align: center;
    flex-shrink: 0;
}

.oi-actions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 80px;
    flex-shrink: 0;
}

.oi-actions .btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
}

/* ---------- 주문 푸터 ---------- */
.order-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background-color: #f9f9fa;
}

.order-footer-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.order-footer-shipping {
    font-size: 0.9rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.order-footer-shipping .bi-truck {
    color: #999;
}

.order-footer-divider {
    color: #ddd;
    margin: 0 0.25rem;
}

.order-footer-label {
    font-size: 0.9rem;
    color: #666;
}

.order-footer-total {
    font-weight: 700;
    color: #222;
    font-size: 1.05rem;
}

.order-footer-actions {
    display: flex;
    gap: 0.5rem;
}

.order-content {
    padding: 1.25rem;
    border-bottom: 1px solid #eee;
}

.product-title {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed #eee;
}

.product-main {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
}

.order-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.order-meta-icon {
    font-size: 0.9rem;
    margin-right: 0.35rem;
    color: #999;
    line-height: 1;
}

.product-count {
    color: #555;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    line-height: 1.4;
}

.order-prices {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.total-price {
    font-weight: 600;
    color: #222;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    line-height: 1.4;
}

.total-price .order-meta-icon {
    color: #8b6a3d;
}

.shipping-fee {
    font-size: 0.9rem;
    color: #888;
    display: flex;
    align-items: center;
    line-height: 1.4;
}

.order-status {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
}

.status-badge.payment-complete {
    background-color: #e3f2fd;
    color: #0d6efd;
}

.status-badge.payment-complete::before {
    content: '\F26E'; /* 신용카드 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.preparing {
    background-color: #fff3cd;
    color: #856404;
}

.status-badge.preparing::before {
    content: '\F6D3'; /* 온도계 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.shipped {
    background-color: #d1e7dd;
    color: #0f5132;
}

.status-badge.shipped::before {
    content: '\F6FB'; /* 트럭 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.delivered {
    background-color: #d1e7dd;
    color: #0f5132;
}

.status-badge.delivered::before {
    content: '\F270'; /* 체크 박스 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.canceled {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.canceled::before {
    content: '\F623'; /* X 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.exchange {
    background-color: #cff4fc;
    color: #055160;
}

.status-badge.exchange::before {
    content: '\F149'; /* 화살표 회전 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

/* 추가 배지 스타일 */
.status-badge.payment-waiting {
    background-color: #e2e3e5;
    color: #383d41;
}

.status-badge.payment-waiting::before {
    content: '\F40B'; /* 시계 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.exchange-requested {
    background-color: #d6d8db;
    color: #383d41;
}

.status-badge.exchange-requested::before {
    content: '\F116'; /* 반복 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.return-requested {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.return-requested::before {
    content: '\F12F'; /* 화살표 방향 되돌리기 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.exchange-processing {
    background-color: #cff4fc;
    color: #055160;
}

.status-badge.exchange-processing::before {
    content: '\F14E'; /* 상자 화살표 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.return-processing {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.return-processing::before {
    content: '\F286'; /* 리사이클 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

.status-badge.on-delivery {
    background-color: #d1e7dd;
    color: #0f5132;
}

.status-badge.on-delivery::before {
    content: '\F6FB'; /* 트럭 아이콘 */
    font-family: 'Bootstrap-icons';
    margin-right: 0.4rem;
    font-size: 0.9rem;
}

/* 페이지네이션 */
.pagination {
    margin-top: 2rem;
    justify-content: center;
}

.pagination .page-item .page-link {
    color: var(--accent-color);
    padding: 0.5rem 0.75rem;
    border-color: #dee2e6;
    font-size: 0.9rem;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.pagination .page-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(126, 79, 34, 0.25);
}

.pagination .page-link:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
    z-index: 3;
}

.pagination .page-item.active .page-link:hover {
    background-color: var(--primary-color);
    color: #fff;
}

/* 주문 없음 안내 */
.no-orders-container {
    text-align: center;
    padding: 3rem 0;
}

.no-orders-content {
    max-width: 400px;
    margin: 0 auto;
}

.no-orders-icon {
    font-size: 4rem;
    color: #adb5bd;
    margin-bottom: 1.5rem;
}

.no-orders-text {
    color: #6c757d;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* 반응형 스타일 */
@media (max-width: 767.98px) {
    .order-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .order-prices {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .total-price {
        font-size: 1.05rem;
    }

    .order-content {
        padding: 1.25rem 1rem;
    }

    .content-wrapper {
        padding: 0;
    }

    .filter-container {
        padding: 1rem;
        margin: 0 0 1rem 0;
        border-radius: 0;
    }

    .order-status {
        margin-left: 0;
    }

    .product-main {
        font-size: 1rem;
    }

    /* 상품별 행: 모바일 카드형 */
    .order-header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .order-payment-link {
        font-size: 0.85rem;
    }

    .order-item-row {
        flex-wrap: wrap;
        padding: 1rem;
        gap: 0.75rem;
    }

    .oi-image {
        width: 64px;
        height: 64px;
    }

    .oi-info {
        flex: 1;
        min-width: calc(100% - 80px);
    }

    .oi-name {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .oi-price-qty {
        align-items: flex-start;
        flex-direction: row;
        gap: 0.5rem;
        width: 100%;
        min-width: 0;
    }

    .oi-status {
        min-width: auto;
    }

    .oi-actions {
        flex-direction: row;
        width: 100%;
        gap: 0.5rem;
        min-width: 0;
    }

    .oi-actions .btn {
        flex: 1;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .order-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .order-footer-summary {
        flex-wrap: wrap;
        gap: 0.25rem 0.5rem;
    }

    .order-footer-actions {
        width: 100%;
    }

    .order-footer-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    /* 페이지네이션 모바일 최적화 */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    
    .pagination .page-link {
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
        min-width: 1.5rem;
        height: 2rem;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 페이지 넘버 버튼은 작게, 화살표 버튼은 조금 더 크게 */
    .pagination .page-item:first-child .page-link,
    .pagination .page-item:last-child .page-link,
    .pagination .page-item:nth-child(2) .page-link,
    .pagination .page-item:nth-last-child(2) .page-link {
        padding: 0.375rem 0.5rem;
    }
}

/* 중간 크기 모바일 화면 대응 (401-575px) */
@media (min-width: 401px) and (max-width: 575.98px) {
    .pagination .page-link {
        padding: 0.375rem 0.5rem;
        font-size: 0.85rem;
        min-width: 2rem;
        height: 2rem;
    }
}

@media (max-width: 400px) {
    /* 숨김 설정 제거하고 크기 최적화로 변경 */
    .pagination .page-item .page-link {
        padding: 0.25rem 0.375rem;
        font-size: 0.8rem;
    }
    
    /* 첫 페이지, 마지막 페이지 아이콘은 더 작게 */
    .pagination .page-item:first-child .page-link,
    .pagination .page-item:last-child .page-link,
    .pagination .page-item:nth-child(2) .page-link,
    .pagination .page-item:nth-last-child(2) .page-link {
        padding: 0.25rem 0.35rem;
    }
}

@media (max-width: 360px) {
    /* 320px 환경 대응 */
    .pagination .page-item .page-link {
        padding: 0.25rem 0.3rem;
        font-size: 0.75rem;
    }
    
    .pagination .page-item:first-child .page-link,
    .pagination .page-item:last-child .page-link,
    .pagination .page-item:nth-child(2) .page-link,
    .pagination .page-item:nth-last-child(2) .page-link {
        padding: 0.25rem 0.3rem;
    }
}

@media (max-width: 575.98px) {
    .order-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.875rem 1rem;
        gap: 0.5rem;
    }

    .order-payment-link {
        align-self: flex-end;
    }

    .order-number {
        margin-top: 0.5rem;
    }

    .order-products {
        flex-direction: column;
    }

    .product-title {
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }

    .order-meta {
        gap: 0.5rem;
    }

    .order-content {
        padding: 1rem;
    }

    .order-actions {
        justify-content: stretch;
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .order-actions .btn {
        flex: 1 1 calc(50% - 0.5rem);
        font-size: 0.82rem;
        padding: 0.375rem 0.5rem;
        white-space: nowrap;
        margin-left: 0.25rem;
        margin-right: 0.25rem;
        margin-bottom: 0.5rem;
        min-width: 0;
    }

    .order-actions .btn:nth-child(odd) {
        margin-left: 0;
    }

    .order-actions .btn:nth-child(even) {
        margin-right: 0;
    }

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

    .pagination .page-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }
}

.order-products {
    display: flex;
}

.order-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 주문 액션 버튼 스타일 개선 */
.order-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 0.75rem 1.25rem;
    background-color: #f9f9fa;
    border-top: 1px solid #eee;
}

.order-actions .btn {
    margin-left: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    min-width: 80px;
    text-align: center;
}

.order-actions .btn:first-child {
    margin-left: 0;
}

/* 태블릿 뷰 (768px 이하) */
@media (max-width: 767.98px) {
    .order-header, .order-content {
        padding: 0.75rem 1rem;
    }
    
    .order-meta {
        gap: 1.25rem;
    }
}

/* 모바일 뷰 (576px 이하) */
@media (max-width: 576px) {
    .order-header, .order-content {
        padding: 0.75rem 1rem;
    }
    
    .order-meta {
        gap: 1.25rem;
    }
}

/* 접는 메뉴 스타일링 */
.sidebar-toggle-btn {
    padding: 0.2rem 0.5rem;
    transition: all 0.3s;
    width: auto;
}

.sidebar-toggle-btn[aria-expanded="true"] i {
    transform: rotate(180deg);
}

/* P1 #25 (리뷰): 필터 조회 로딩 오버레이 — form submit 즉시 표시. 페이지 네비게이션 직전 시각 피드백. */
.filter-loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.6);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
}
