/* 📱 Mobile Optimized Styles for Express24-RP */
:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --primary: #38bdf8;
    --secondary: #10b981;
    --accent: #f43f5e;
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Pretendard', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding-bottom: 80px; /* For Bottom Nav */
    overflow-x: hidden;
}

/* Hide PC Elements in Mobile */
.pc-only, .sidebar {
    display: none !important;
}

/* Header */
.top-bar {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(15, 23, 42, 0.9);
    position: sticky;
    top: 0;
    z-index: 100;
}

.search-container input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--card-bg);
    color: white;
}

.user-profile {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    margin-top: 10px;
}

.date-navigator {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 12px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 18px;
}

#current-range-text {
    font-size: 13px;
    font-weight: 600;
}

/* Summary Cards */
.summary-section {
    padding: 15px;
}

.period-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.filter-btn {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: var(--card-bg);
    color: var(--text-sub);
    font-weight: 600;
}

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

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 15px;
}

.main-card {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(16, 185, 129, 0.2));
    border-color: rgba(56, 189, 248, 0.3);
}

.summary-card:nth-child(3) {
    grid-column: span 2;
}

.summary-card label {
    display: block;
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 5px;
}

.summary-card .value {
    font-size: 20px;
    font-weight: 700;
}

.main-card .value {
    font-size: 20px; /* Reduced to match others since it shares a line */
    color: var(--secondary);
}

.value-container {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.trend {
    font-size: 11px;
    font-weight: 700;
}

.trend.up { color: #4ade80; }
.trend.down { color: #fb7185; }

.value.red {
    color: var(--accent);
}

/* Freight List Helpers (Mobile) */
.card-route {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: rgba(56, 189, 248, 0.2);
    margin-bottom: 5px;
}

.owner-info-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tel-link {
    font-size: 11px;
    color: var(--text-sub);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Analysis Grid (Mobile: Stacked) */
.analysis-grid {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chart-container {
    height: 300px;
    padding: 15px;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.ranking-card {
    padding: 15px;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
}

.ranking-card h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--text-sub);
}

.rank-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.rank-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rank-name { font-size: 13px; }
.rank-value { font-size: 13px; color: var(--primary); font-weight: 600; }

.empty { text-align: center; color: var(--text-sub); font-size: 12px; padding: 10px 0; }

/* History List (Cards) */
.history-section {
    padding: 15px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

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

.freight-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-sub);
}

.card-route {
    font-size: 16px;
    font-weight: 700;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--glass-border);
    padding-top: 10px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.status-paid { background: rgba(16, 185, 129, 0.2); color: var(--secondary); }
.status-unpaid { background: rgba(244, 63, 94, 0.2); color: var(--accent); }

/* Pagination Controls (Mobile) */
.pagination-controls.mobile-only {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.pagination-controls.mobile-only .btn-pagination {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-sub);
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
}

.pagination-controls.mobile-only .btn-pagination:disabled {
    opacity: 0.3;
}

.pagination-controls.mobile-only .page-indicator {
    font-size: 12px;
    min-width: 80px;
    text-align: center;
    font-weight: 600;
}

/* Stats Tabs (Mobile) */
.stats-tabs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    margin-bottom: 20px;
    padding: 5px;
    -webkit-overflow-scrolling: touch;
}

.stats-tabs::-webkit-scrollbar { display: none; }

.tab-link {
    flex: 0 0 auto;
    padding: 8px 15px;
    font-size: 13px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sub);
    border: 1px solid var(--glass-border);
    white-space: nowrap;
}

.tab-link.active {
    background: var(--primary);
    color: white;
}

.stats-header {
    flex-direction: column;
    align-items: stretch !important;
}

.stats-controls {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
    margin-top: 10px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.stats-summary {
    grid-template-columns: 1fr !important;
}

.stats-table th, .stats-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--glass-border);
}

/* Sorting Styles */
th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 18px !important;
    transition: color 0.2s;
}

th.sortable:hover { color: var(--primary); }

th.sortable::after {
    content: "↕";
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.2;
    font-size: 10px;
}

th.sortable.asc::after { content: "▲"; opacity: 1; color: var(--primary); }
th.sortable.desc::after { content: "▼"; opacity: 1; color: var(--primary); }

.font-bold { font-weight: 700; }
.green { color: #10b981 !important; }
.red { color: #f43f5e !important; }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    z-index: 1000;
}

.mobile-nav-item {
    text-align: center;
    font-size: 11px;
    color: var(--text-sub);
    text-decoration: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

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

.mobile-nav-item i, .mobile-nav-item span {
    font-size: 18px;
    margin-bottom: 2px;
}

/* Floating Action Button for Mileage */
#add-mileage-btn {
    position: fixed;
    bottom: 85px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 30px;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
    font-weight: 700;
    z-index: 999;
}

#add-freight-btn {
    display: none; /* Mobile은 Floating 또는 Menu 내 배치 권장 */
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); /* 배경 투명도 낮춤 */
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.confirm-box {
    text-align: center;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.confirm-message {
    font-size: 15px;
    line-height: 1.5;
    margin: 15px 0;
    color: #cbd5e1;
}

.highlight-owner {
    color: var(--primary);
    font-weight: 700;
}

.status-paid-text {
    color: var(--secondary);
    font-weight: 700;
}

.status-unpaid-text {
    color: var(--accent);
    font-weight: 700;
}

/* Detail Modal (Mobile) */
.detail-box {
    width: 100%;
    margin: 10px;
    padding: 20px;
    border-radius: 20px;
    max-height: 85vh;
    overflow-y: auto;
    background: #1e293b !important; /* 가독성을 위한 불투명 배경 */
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.modal-header h3 { font-size: 18px; margin: 0; }

.detail-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-item label {
    font-size: 11px;
    color: var(--text-sub);
    margin-bottom: 2px;
}

.detail-item span {
    font-size: 14px;
}

.detail-item .highlight {
    font-size: 16px;
    font-weight: 700;
}

.detail-item .highlight-blue {
    font-size: 18px;
    font-weight: 800;
    color: var(--primary);
}

.detail-separator {
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-sub);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-sub);
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--card-bg);
    color: white;
    font-size: 16px;
}

.form-btn-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary {
    flex: 1;
    background: var(--primary);
    color: white;
    padding: 15px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
}

.btn-close {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-sub);
    padding: 15px;
    border-radius: 12px;
    font-weight: 700;
}

.view-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.view-header h2 {
    font-size: 20px;
    margin: 0;
}

.badge-cat {
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(56, 189, 248, 0.2);
    color: var(--primary);
    font-size: 11px;
}

.search-card {
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.search-card input, .search-card select {
    flex: 1;
    min-width: 120px;
    padding: 10px;
    border-radius: 10px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: white;
}

.date-range-filter {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 5px;
}

.date-range-filter input { width: 100%; }
.date-range-filter .btn-sm { padding: 10px; background: var(--primary); color: white; border: none; border-radius: 8px; font-weight: 700; }

.chart-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 15px;
}

.chart-container h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: var(--text-sub);
}

.chart-container.big, .chart-container.small {
    height: 300px;
}
