/*
 * 广州公交 TransHub 通 — 橙色主题
 * 主色: #E8651C  →  辅色: #F0D76A
 */

/* ── CSS 变量 ── */
:root {
    --orange-deep: #C7510E;
    --orange: #E8651C;
    --orange-light: #F0803A;
    --golden: #F0D76A;
    --golden-light: #F7E89E;
    --gradient: linear-gradient(135deg, #E8651C 0%, #F0D76A 100%);
    --gradient-soft: linear-gradient(135deg, rgba(232,101,28,0.08) 0%, rgba(240,215,106,0.12) 100%);

    --bg: #FAF8F5;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1A1A2E;
    --text: #2D2D2D;
    --text-muted: #888888;
    --text-sidebar: #CCCCDD;
    --text-sidebar-active: #FFFFFF;
    --border: #E8E6E1;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.10);
    --radius: 10px;
    --radius-sm: 6px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}
a { text-decoration: none; color: inherit; }

/* ── 布局 ── */
.app-layout { display: flex; min-height: 100vh; }

/* ── 侧边栏 ── */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}
.sidebar-brand {
    padding: 24px 20px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    margin-bottom: 8px;
    object-fit: contain;
    background: #fff;
    padding: 4px;
}
.sidebar-title {
    display: block;
    font-size: 17px;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 1px;
}
.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 15px;
    color: var(--text-sidebar);
    transition: all 0.2s;
    border-left: 3px solid transparent;
    margin: 2px 0;
}
.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #FFFFFF;
}
.nav-item.active {
    background: linear-gradient(90deg, rgba(232,101,28,0.25) 0%, rgba(232,101,28,0.05) 100%);
    color: var(--text-sidebar-active);
    border-left-color: var(--orange);
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

/* ── 侧栏用户信息 ── */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin: 0;
}
.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient);
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name {
    font-size: 14px;
    color: #FFF;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 11px;
    color: var(--golden-light);
}

/* ── 侧栏分隔线 ── */
.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 8px 16px;
}
.nav-section-label {
    padding: 8px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.3);
}

/* ── 退出登录 ── */
.sidebar-logout {
    display: block;
    padding: 8px 0;
    color: rgba(255,255,255,0.5);
    transition: color 0.2s;
}
.sidebar-logout:hover { color: #FF6B6B; }

.sidebar-footer {
    padding: 14px 20px;
    font-size: 12px;
    text-align: center;
    color: rgba(255,255,255,0.3);
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ── 主内容区 ── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

/* ── 顶栏 ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(8px);
}
.topbar-title { font-size: 22px; font-weight: 700; color: var(--orange-deep); }
.topbar-actions { display: flex; gap: 8px; }

/* ── 页面内容 ── */
.page-content { padding: 28px 32px; flex: 1; }

/* ── Flash 消息 ── */
.flash-container {
    padding: 0 32px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: -8px;
    margin-top: 16px;
}
.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    animation: slideDown 0.3s ease;
}
.flash-success { background: #E6F7EE; color: #1B7A42; border: 1px solid #B7E4CF; }
.flash-error { background: #FDEAEA; color: #B71C1C; border: 1px solid #F5C6C6; }
.flash-close { background: none; border: none; font-size: 20px; cursor: pointer; color: inherit; opacity: 0.6; }
.flash-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── 统计卡片 ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.25s;
    border: 1px solid var(--border);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--orange-light);
}
.stat-icon { font-size: 36px; }
.stat-number { font-size: 30px; font-weight: 800; color: var(--orange-deep); line-height: 1.2; }
.stat-label { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ── 卡片 ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--gradient-soft);
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }
.card-note { border-left: 4px solid var(--golden); }

/* ── 表格 ── */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    background: var(--gradient-soft);
    padding: 12px 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--orange-deep);
    border-bottom: 2px solid var(--orange-light);
    white-space: nowrap;
}
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.table tbody tr:hover { background: rgba(232,101,28,0.03); }
.actions-cell { white-space: nowrap; display: flex; gap: 4px; }

/* ── 详情表格 ── */
.detail-table { width: 100%; }
.detail-table tr { border-bottom: 1px solid var(--border); }
.detail-table th {
    width: 120px;
    padding: 12px 16px;
    text-align: right;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--gradient-soft);
}
.detail-table td { padding: 12px 16px; font-size: 14px; }

/* ── 表单 ── */
.form-card { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group-wide { grid-column: 1 / -1; }
.form-group label { font-size: 14px; font-weight: 600; color: var(--text); }
.form-hint { font-size: 12px; color: var(--text-muted); }
.required { color: var(--orange); }

.input {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: #FAFAFA;
    transition: all 0.2s;
    font-family: inherit;
    width: 100%;
}
.input:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(232,101,28,0.1);
    background: #FFF;
}
textarea.input { resize: vertical; min-height: 80px; }

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* ── 搜索栏 ── */
.search-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px 20px;
}
.search-bar .input { flex: 1; min-width: 140px; max-width: 300px; }

/* ── 按钮 ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}
.btn-primary {
    background: var(--gradient);
    color: #FFF;
    border-color: transparent;
}
.btn-primary:hover { opacity: 0.92; box-shadow: 0 4px 14px rgba(232,101,28,0.35); }
.btn-secondary { background: #F0F0F0; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #E4E4E4; }
.btn-outline { background: transparent; color: var(--orange); border-color: var(--orange); }
.btn-outline:hover { background: rgba(232,101,28,0.08); }
.btn-danger { background: #FFF; color: #D32F2F; border-color: #EF9A9A; }
.btn-danger:hover { background: #FFF5F5; border-color: #D32F2F; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ── 徽章 ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-company { background: rgba(232,101,28,0.1); color: var(--orange-deep); }
.badge-warning { background: rgba(240,215,106,0.3); color: #8B6F00; }
.badge-count { background: var(--orange); color: #FFF; min-width: 24px; text-align: center; }
.badge-line { background: rgba(232,101,28,0.08); color: var(--orange); font-family: monospace; }

/* ── 链接 ── */
.link { color: var(--orange); font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ── 分页 ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0 4px;
    flex-wrap: wrap;
}
.pagination-info { font-size: 14px; color: var(--text-muted); }
.pagination .disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.pagination-ellipsis { padding: 6px 4px; color: var(--text-muted); font-size: 14px; }
.pagination-jump {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 12px;
    font-size: 13px;
    color: var(--text-muted);
}
.pagination-input {
    width: 52px;
    padding: 6px 8px;
    text-align: center;
    -moz-appearance: textfield;
}
.pagination-input::-webkit-inner-spin-button,
.pagination-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ── 车型车辆弹窗 ── */
.vehicle-count-badge { cursor: pointer; transition: transform 0.15s; }
.vehicle-count-badge:hover { transform: scale(1.1); }

/* ── 空状态 ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 15px;
}

/* ── 备注预览 ── */
.note-preview {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    cursor: default;
}

/* ── 车牌号样式 ── */
.plate-number {
    font-family: monospace;
    font-size: 15px;
    font-weight: 700;
    background: #F0F4FF;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 1px;
}

/* ── 模态框 ── */
.modal {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 90%;
}
.modal::backdrop { background: rgba(0,0,0,0.4); }
.modal-content { padding: 24px; }
.modal-content h3 { margin-bottom: 10px; color: var(--orange-deep); }
.modal-content p { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── 仪表盘 ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

.quick-actions { display: flex; flex-direction: column; gap: 10px; }

/* ── 详情页 ── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.detail-grid .card-note { grid-column: 1 / -1; }
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }

/* ── 公司卡片 ── */
.company-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.company-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    text-align: center;
    transition: all 0.2s;
}
.company-card:hover {
    border-color: var(--orange-light);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.company-icon { font-size: 40px; margin-bottom: 8px; }
.company-name { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.company-stats { display: flex; justify-content: center; gap: 24px; margin-bottom: 10px; }
.company-stat-num { font-size: 24px; font-weight: 800; color: var(--orange-deep); }
.company-stat-label { font-size: 12px; color: var(--text-muted); }
.company-code { font-size: 12px; color: var(--text-muted); font-family: monospace; margin-top: 6px; }

/* ── 响应式 ── */
@media (max-width: 768px) {
    .sidebar { width: 60px; min-width: 60px; }
    .sidebar-title, .sidebar-footer span, .nav-item span:not(.nav-icon) { display: none; }
    .sidebar-brand { padding: 16px 8px; }
    .sidebar-logo { width: 38px; height: 38px; border-radius: 10px; }
    .nav-item { justify-content: center; padding: 12px; }
    .page-content { padding: 16px; }
    .topbar { padding: 14px 16px; }
    .topbar-title { font-size: 18px; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── 可排序表头 ── */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.sortable:hover { background: rgba(232,101,28,0.12); }
.sort-icon { font-size: 10px; margin-left: 4px; }

/* ── 车辆搜索（备注表单）── */
.vehicle-search-wrapper { position: relative; }
.vehicle-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    background: #FFF;
    border: 1.5px solid var(--orange);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
}
.vehicle-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: #FFF;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    transition: background 0.15s;
}
.vehicle-search-item:hover { background: var(--gradient-soft); }
.vehicle-search-item strong { min-width: 80px; color: var(--orange-deep); }
.htmx-indicator { font-size: 12px; color: var(--text-muted); padding: 4px 0; display: inline-block; }
.selected-vehicle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #E6F7EE;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

/* ── 页脚备案 ── */
.site-footer {
    text-align: center;
    padding: 16px 32px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}
.site-footer a {
    font-size: 13px;
    color: var(--text-muted);
    transition: color 0.2s;
}
.site-footer a:hover {
    color: var(--orange);
}

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CCC; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #AAA; }

/* ── text-muted ── */
.text-muted { color: var(--text-muted); }
