/* ======================================
   마켓 통합 대시보드 - 메인 스타일시트
   ====================================== */

:root {
    --sidebar-width: 250px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #3b82f6;
    --topbar-height: 60px;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --blue: #3b82f6;
    --green: #10b981;
    --yellow: #f59e0b;
    --red: #ef4444;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --orange: #f97316;
    --shopee-color: #EE4D2D;
    --ebay-color: #0064D2;
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ── 사이드바 ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

.sidebar-logo i {
    font-size: 1.4rem;
    color: var(--blue);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

.sidebar-nav {
    list-style: none;
    padding: 10px 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    padding: 15px 20px 5px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #475569;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 400;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.sidebar-nav li.active a {
    background: rgba(59, 130, 246, 0.15);
    color: var(--blue);
    border-left-color: var(--blue);
    font-weight: 500;
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #94a3b8;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.status-dot.offline {
    background: var(--text-muted);
}

/* ── 사이드바 서브메뉴 ── */
.has-submenu > a {
    position: relative;
}

.has-submenu .submenu-arrow {
    margin-left: auto;
    font-size: 0.65rem;
    transition: transform 0.25s ease;
}

.has-submenu.open .submenu-arrow {
    transform: rotate(90deg);
}

.submenu {
    list-style: none;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0,0,0,0.15);
}

.has-submenu.open .submenu {
    max-height: 300px;
}

.submenu li a {
    padding: 8px 20px 8px 42px !important;
    font-size: 0.83rem !important;
    gap: 8px !important;
}

.submenu li a span:first-child {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

/* ── 관리 폼 스타일 ── */
.manage-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 24px;
    margin-bottom: 20px;
}

.manage-card .card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.manage-card .card-title i {
    color: var(--blue);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    font-size: 0.88rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text-primary);
    background: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: #fff;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-primary-custom {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 24px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary-custom:hover { background: #2563eb; }

.btn-secondary-custom {
    background: #e2e8f0;
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    padding: 9px 24px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary-custom:hover { background: #cbd5e1; }

.btn-danger-custom {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-danger-custom:hover { background: #dc2626; }

.btn-sm-custom {
    padding: 5px 12px;
    font-size: 0.78rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
}

.btn-edit { background: #dbeafe; color: #1e40af; }
.btn-edit:hover { background: #bfdbfe; }
.btn-delete { background: #fee2e2; color: #991b1b; }
.btn-delete:hover { background: #fecaca; }

/* flash 메시지 */
.flash-msg {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.88rem;
    font-weight: 500;
}
.flash-msg.success { background: #dcfce7; color: #166534; }
.flash-msg.error { background: #fee2e2; color: #991b1b; }
.flash-msg.info { background: #dbeafe; color: #1e40af; }

/* ── 메인 콘텐츠 ── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.page-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.content-wrapper {
    padding: 25px;
}

/* ── KPI 카드 ── */
.kpi-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.kpi-card .kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #ffffff;
    margin-bottom: 12px;
}

.kpi-card .kpi-icon.blue { background: var(--blue); }
.kpi-card .kpi-icon.green { background: var(--green); }
.kpi-card .kpi-icon.yellow { background: var(--yellow); }
.kpi-card .kpi-icon.red { background: var(--red); }
.kpi-card .kpi-icon.purple { background: var(--purple); }
.kpi-card .kpi-icon.orange { background: var(--orange); }

.kpi-card .kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-card .kpi-change {
    font-size: 0.78rem;
    margin-top: 6px;
    font-weight: 500;
}

.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }

/* ── 차트 카드 ── */
.chart-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.chart-card .chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-card .chart-title i {
    color: var(--blue);
}

.chart-container {
    position: relative;
    width: 100%;
}

/* ── 테이블 ── */
.data-table {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.data-table .table-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.data-table .table-header h6 {
    font-weight: 600;
    margin: 0;
}

.data-table table {
    width: 100%;
    margin: 0;
}

.data-table table thead th {
    background: #f8fafc;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table table tbody td {
    padding: 12px 16px;
    font-size: 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.data-table table tbody tr:last-child td {
    border-bottom: none;
}

.data-table table tbody tr:hover {
    background: #f8fafc;
}

/* ── 뱃지/상태 ── */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    gap: 4px;
}

.status-badge.delivered { background: #dcfce7; color: #166534; }
.status-badge.shipped { background: #dbeafe; color: #1e40af; }
.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.cancelled { background: #fee2e2; color: #991b1b; }
.status-badge.returned { background: #f3e8ff; color: #6b21a8; }

.status-badge.good { background: #dcfce7; color: #166534; }
.status-badge.low { background: #fef3c7; color: #92400e; }
.status-badge.soldout { background: #fee2e2; color: #991b1b; }

/* ── 알림 패널 ── */
.alert-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.alert-item.warning { background: #fef3c7; color: #92400e; }
.alert-item.danger { background: #fee2e2; color: #991b1b; }
.alert-item.info { background: #dbeafe; color: #1e40af; }
.alert-item.success { background: #dcfce7; color: #166534; }

/* ── 필터 바 ── */
.filter-bar {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-bar label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.filter-bar select,
.filter-bar input {
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    color: var(--text-primary);
    background: #f8fafc;
}

.filter-bar select:focus,
.filter-bar input:focus {
    border-color: var(--blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-bar .btn-filter {
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-bar .btn-filter:hover {
    background: #2563eb;
}

/* ── 마켓 아이콘 ── */
.marketplace-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.83rem;
    font-weight: 500;
}

/* ── 유틸리티 ── */
.text-profit { color: var(--green); font-weight: 600; }
.text-loss { color: var(--red); font-weight: 600; }
.text-krw { font-weight: 600; }

.card-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* ── 수익 워터폴 ── */
.profit-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 15px;
}

.profit-flow .flow-item {
    text-align: center;
    padding: 12px 16px;
    border-radius: 10px;
    min-width: 100px;
}

.profit-flow .flow-item .flow-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

.profit-flow .flow-item .flow-value {
    font-size: 1rem;
    font-weight: 700;
}

.profit-flow .flow-arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.flow-item.revenue { background: #dbeafe; }
.flow-item.revenue .flow-value { color: var(--blue); }

.flow-item.cost { background: #fee2e2; }
.flow-item.cost .flow-value { color: var(--red); }

.flow-item.fee { background: #fef3c7; }
.flow-item.fee .flow-value { color: var(--yellow); }

.flow-item.shipping { background: #f3e8ff; }
.flow-item.shipping .flow-value { color: var(--purple); }

.flow-item.profit { background: #dcfce7; }
.flow-item.profit .flow-value { color: var(--green); }

/* ── 반응형 ── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .content-wrapper {
        padding: 15px;
    }

    .kpi-card .kpi-value {
        font-size: 1.2rem;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .profit-flow {
        flex-direction: column;
    }

    .profit-flow .flow-arrow {
        transform: rotate(90deg);
    }
}

@media (min-width: 769px) {
    .topbar .sidebar-toggle {
        display: none;
    }
}

/* ── 스크롤바 ── */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

/* ── 로딩 ── */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ── 빈 상태 ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.9rem;
}
