/**
 * 统一船东门户样式
 *
 * 合并自：
 *   - assets/css/portal-nav.css（公开导航样式）
 *   - portal/header.php 内联样式（已登录导航）
 *   - apply/portal/header.php 内联样式
 *   - 各页面通用内联样式（dashboard, ships, certificates, applications 等）
 *
 * 组织结构：
 *   1. CSS 变量
 *   2. 基础重置
 *   3. 顶部导航栏
 *   4. 移动端底部导航
 *   5. 页面通用布局
 *   6. 卡片 & 统计
 *   7. 表格 & 列表
 *   8. 表单
 *   9. 状态徽章
 *  10. 通知
 *  11. 按钮
 *  12. 响应式 — 平板端
 *  13. 响应式 — 移动端
 */

/* ==========================================================================
   1. CSS 变量
   ========================================================================== */
:root {
    --portal-primary: #1a237e;
    --portal-primary-light: #283593;
    --portal-accent: #667eea;
    --portal-accent2: #764ba2;
    --portal-bg: #f5f7fa;
    --portal-white: #fff;
    --portal-text: #333;
    --portal-text-light: #666;
    --portal-text-muted: #999;
    --portal-border: #e2e8f0;
    --portal-border-light: #f0f0f0;
    --portal-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    --portal-shadow-lg: 0 5px 20px rgba(0, 0, 0, 0.1);
    --portal-radius: 12px;
    --portal-radius-sm: 8px;
    --portal-radius-xs: 4px;
    --portal-nav-height: 56px;
    --portal-bottom-nav-height: 60px;
    --portal-warning: #ffc107;
    --portal-info: #17a2b8;
    --portal-success: #28a745;
    --portal-danger: #dc3545;
}

/* ==========================================================================
   2. 基础重置
   ========================================================================== */
body {
    margin: 0;
    background: var(--portal-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--portal-text);
    -webkit-text-size-adjust: 100%;
}

/* ==========================================================================
   3. 顶部导航栏
   ========================================================================== */
.portal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--portal-primary) 0%, var(--portal-primary-light) 100%);
    padding: 0 20px;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
    min-height: var(--portal-nav-height);
}

.portal-brand {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    text-decoration: none;
    padding: 15px 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.portal-brand:hover {
    color: rgba(255, 255, 255, 0.85);
}

/* 汉堡按钮 — 仅移动端显示 */
.portal-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    flex-direction: column;
    gap: 5px;
}

.portal-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s;
}

/* 主菜单 */
.portal-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2px;
    flex: 1;
}

.portal-menu > li > a {
    display: block;
    padding: 18px 15px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    border-radius: var(--portal-radius-xs);
    white-space: nowrap;
}

.portal-menu > li > a:hover,
.portal-menu > li > a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

/* 下拉菜单 */
.portal-dropdown {
    position: relative;
}

.portal-dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.portal-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--portal-white);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-radius: var(--portal-radius-sm);
    min-width: 180px;
    padding: 8px 0;
    z-index: 1100;
}

.portal-dropdown-menu a {
    display: block;
    padding: 10px 20px;
    color: var(--portal-text) !important;
    text-decoration: none;
    font-size: 14px;
    background: none !important;
}

.portal-dropdown-menu a:hover {
    background: #f5f7fa !important;
    color: var(--portal-primary) !important;
}

.portal-dropdown:hover .portal-dropdown-menu,
.portal-dropdown.open .portal-dropdown-menu {
    display: block;
}

/* 右侧工具区 */
.portal-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    flex-shrink: 0;
}

.portal-user a,
.portal-user span {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    white-space: nowrap;
}

.portal-user a:hover {
    color: #fff;
}

.portal-lang-switch {
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--portal-radius-xs);
    font-size: 12px;
    font-weight: bold;
}

.portal-login-btn {
    padding: 7px 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    font-size: 13px;
    transition: all 0.2s ease;
}

.portal-login-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.5);
}

.portal-username {
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 12px;
    border-radius: 20px;
}

/* 遮罩 */
.portal-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.portal-menu-overlay.active {
    display: block;
}

/* ==========================================================================
   4. 移动端底部导航
   ========================================================================== */
.portal-bottom-nav {
    display: none; /* 桌面端隐藏 */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--portal-white);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    height: var(--portal-bottom-nav-height);
    justify-content: space-around;
    align-items: center;
    padding: 0;
}

.portal-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--portal-text-light);
    font-size: 10px;
    flex: 1;
    padding: 6px 0;
    min-height: 44px;
    transition: color 0.2s;
}

.portal-bottom-nav a.active {
    color: var(--portal-primary);
}

.bottom-nav-icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 2px;
}

.bottom-nav-label {
    font-size: 10px;
    line-height: 1.2;
}

/* "更多"上拉面板 */
.bottom-nav-more-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1100;
}

.bottom-nav-more-overlay.active {
    display: block;
}

.bottom-nav-more-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--portal-white);
    border-radius: 16px 16px 0 0;
    padding: 12px 20px 30px;
    z-index: 1200;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.bottom-nav-more-panel.open {
    transform: translateY(0);
}

.bottom-nav-more-handle {
    width: 40px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    margin: 0 auto 16px;
    cursor: pointer;
}

.bottom-nav-more-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.bottom-nav-more-grid a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--portal-text);
    padding: 12px 8px;
    border-radius: var(--portal-radius-sm);
    transition: background 0.2s;
    min-height: 44px;
}

.bottom-nav-more-grid a:hover {
    background: var(--portal-bg);
}

.more-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.more-label {
    font-size: 12px;
    color: var(--portal-text-light);
    text-align: center;
}

/* ==========================================================================
   5. 页面通用布局
   ========================================================================== */
.portal-content {
    padding: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.portal-page-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--portal-text);
}

.portal-page-desc {
    color: var(--portal-text-light);
    margin-bottom: 24px;
}

/* 欢迎横幅 */
.welcome-banner {
    background: linear-gradient(135deg, var(--portal-accent) 0%, var(--portal-accent2) 100%);
    color: #fff;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
}

.welcome-banner h1 {
    margin: 0 0 10px;
    font-size: 24px;
}

.welcome-banner p {
    margin: 0;
    opacity: 0.9;
}

/* 两列布局 */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ==========================================================================
   6. 卡片 & 统计
   ========================================================================== */
.stat-card,
.portal-card {
    background: var(--portal-white);
    padding: 25px;
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.stat-num {
    font-size: 32px;
    font-weight: bold;
    color: var(--portal-text);
}

.stat-label {
    color: var(--portal-text-light);
    font-size: 14px;
    margin-top: 5px;
}

/* 快速操作 */
.quick-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.quick-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    background: var(--portal-white);
    border-radius: 10px;
    text-decoration: none;
    color: var(--portal-text);
    box-shadow: var(--portal-shadow);
    transition: all 0.3s;
}

.quick-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--portal-shadow-lg);
}

.quick-btn .icon {
    font-size: 24px;
}

/* 证书类型卡片网格 */
.cert-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.cert-type-card {
    background: var(--portal-white);
    border-radius: var(--portal-radius);
    padding: 24px;
    box-shadow: var(--portal-shadow);
    transition: all 0.3s;
    text-decoration: none;
    color: var(--portal-text);
    display: block;
}

.cert-type-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--portal-shadow-lg);
}

/* 卡片列表（移动端表格替代） */
.card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-item {
    background: var(--portal-white);
    border-radius: var(--portal-radius-sm);
    padding: 16px;
    box-shadow: var(--portal-shadow);
}

.card-item-header {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--portal-text);
}

.card-item-body {
    font-size: 13px;
    color: var(--portal-text-light);
    margin-bottom: 10px;
}

.card-item-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==========================================================================
   7. 表格 & 列表
   ========================================================================== */
.portal-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--portal-white);
    border-radius: var(--portal-radius);
    overflow: hidden;
    box-shadow: var(--portal-shadow);
}

.portal-table th,
.portal-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--portal-border-light);
}

.portal-table th {
    background: var(--portal-bg);
    font-weight: 600;
    color: var(--portal-text-light);
    font-size: 13px;
}

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

.portal-table tr:hover td {
    background: #fafbfc;
}

/* 筛选栏 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar select,
.filter-bar input {
    padding: 8px 12px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-xs);
    font-size: 14px;
}

/* 章节标题 */
.section-title {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--portal-text);
}

/* 空状态 */
.empty-notice {
    text-align: center;
    padding: 40px;
    color: var(--portal-text-muted);
}

/* ==========================================================================
   8. 表单
   ========================================================================== */
.portal-form .form-group {
    margin-bottom: 20px;
}

.portal-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--portal-text);
}

.portal-form input[type="text"],
.portal-form input[type="email"],
.portal-form input[type="tel"],
.portal-form input[type="password"],
.portal-form input[type="number"],
.portal-form select,
.portal-form textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-xs);
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.portal-form input:focus,
.portal-form select:focus,
.portal-form textarea:focus {
    outline: none;
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ==========================================================================
   9. 状态徽章
   ========================================================================== */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.valid,
.status-badge.approved,
.status-badge.completed {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.pending,
.status-badge.reviewing {
    background: #e3f2fd;
    color: #1565c0;
}

.status-badge.expired,
.status-badge.rejected {
    background: #ffebee;
    color: #c62828;
}

.status-badge.expiring,
.status-badge.supplement {
    background: #fff8e1;
    color: #f57f17;
}

.status-badge.quote_sent {
    background: #f3e5f5;
    color: #7b1fa2;
}

/* ==========================================================================
   10. 通知
   ========================================================================== */
.notification-list {
    background: var(--portal-white);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
}

.notification-item {
    padding: 15px 20px;
    border-bottom: 1px solid var(--portal-border-light);
    display: flex;
    align-items: center;
    gap: 15px;
}

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

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.notification-icon.expiry {
    background: #fff3cd;
}

.notification-icon.app {
    background: #e3f2fd;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 500;
    color: var(--portal-text);
}

.notification-message {
    font-size: 13px;
    color: var(--portal-text-light);
    margin-top: 3px;
}

.notification-time {
    font-size: 12px;
    color: var(--portal-text-muted);
    flex-shrink: 0;
}

/* ==========================================================================
   11. 按钮
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--portal-radius-xs);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--portal-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--portal-primary-light);
}

.btn-accent {
    background: var(--portal-accent);
    color: #fff;
}

.btn-accent:hover {
    opacity: 0.9;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--portal-border);
    color: var(--portal-text);
}

.btn-outline:hover {
    background: var(--portal-bg);
}

.btn-success {
    background: var(--portal-success);
    color: #fff;
}

.btn-danger {
    background: var(--portal-danger);
    color: #fff;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* ==========================================================================
   12. 响应式 — 平板端 (768px – 1024px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .portal-content {
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .portal-menu > li > a {
        padding: 18px 10px;
        font-size: 13px;
    }
}

/* ==========================================================================
   13. 响应式 — 移动端 (< 768px)
   ========================================================================== */
@media (max-width: 767px) {

    /* --- 顶部导航 → 简化 --- */
    .portal-hamburger {
        display: flex;
    }

    .portal-menu {
        display: none;
        position: fixed;
        top: var(--portal-nav-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(26, 35, 126, 0.97);
        flex-direction: column;
        overflow-y: auto;
        padding: 10px 0;
        z-index: 1001;
    }

    .portal-nav.menu-open .portal-menu {
        display: flex;
    }

    .portal-menu > li > a {
        padding: 14px 24px;
        border-radius: 0;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* 移动端下拉 → 静态展开 */
    .portal-dropdown-menu {
        position: static;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 0;
        padding: 0;
        margin-left: 20px;
    }

    .portal-dropdown-menu a {
        color: rgba(255, 255, 255, 0.8) !important;
        padding: 12px 24px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .portal-dropdown-menu a:hover {
        background: rgba(255, 255, 255, 0.1) !important;
        color: #fff !important;
    }

    .portal-dropdown .portal-dropdown-menu {
        display: block;
    }

    .portal-user {
        display: none;
    }

    .portal-nav.menu-open .portal-user {
        display: flex;
        position: fixed;
        bottom: var(--portal-bottom-nav-height);
        left: 0;
        right: 0;
        background: var(--portal-primary);
        padding: 12px 24px;
        justify-content: center;
        gap: 16px;
        z-index: 1002;
    }

    /* --- 底部导航 → 显示 --- */
    .portal-bottom-nav {
        display: flex;
    }

    body {
        padding-bottom: var(--portal-bottom-nav-height);
    }

    /* --- 页面内容 --- */
    .portal-content {
        padding: 15px 12px;
    }

    .portal-page-title {
        font-size: 20px;
    }

    /* --- 欢迎横幅 --- */
    .welcome-banner {
        padding: 20px;
        border-radius: 10px;
    }

    .welcome-banner h1 {
        font-size: 18px;
    }

    /* --- 统计网格 → 2列 --- */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card,
    .portal-card {
        padding: 16px;
    }

    .stat-num {
        font-size: 24px;
    }

    .stat-icon {
        font-size: 28px;
    }

    /* --- 快速操作 → 3列 --- */
    .quick-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .quick-btn {
        flex-direction: column;
        text-align: center;
        padding: 12px 8px;
        font-size: 12px;
    }

    /* --- 两列 → 单列 --- */
    .two-col {
        grid-template-columns: 1fr;
    }

    /* --- 表单 → 单列全宽 --- */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* --- 表格 → 可横滑 --- */
    .portal-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- 响应式表格 → 卡片化 --- */
    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        display: block;
        margin-bottom: 12px;
        border: 1px solid var(--portal-border);
        border-radius: var(--portal-radius-sm);
        padding: 12px;
        background: var(--portal-white);
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        padding: 6px 0;
        border: none;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--portal-text-light);
        margin-right: 12px;
    }

    /* --- 证书类型卡片 → 单列 --- */
    .cert-type-grid {
        grid-template-columns: 1fr;
    }

    /* --- 按钮触摸优化 --- */
    .btn {
        min-height: 44px;
        font-size: 15px;
    }

    /* --- 输入框触摸优化（防 iOS 自动缩放） --- */
    input, select, textarea {
        min-height: 44px;
        font-size: 16px !important;
    }

    /* --- 筛选栏 → 全宽 --- */
    .filter-bar {
        flex-direction: column;
    }

    .filter-bar select,
    .filter-bar input {
        width: 100%;
    }

    /* --- 通知列表 --- */
    .notification-item {
        padding: 12px;
        gap: 10px;
    }

    .notification-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* --- 卡片列表（桌面端隐藏的移动替代） --- */
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block !important;
    }
}

/* 桌面端隐藏移动端元素 */
@media (min-width: 768px) {
    .mobile-only {
        display: none !important;
    }
}

/* ==========================================================================
   防止滚动（菜单打开时）
   ========================================================================== */
body.portal-menu-active {
    overflow: hidden;
}
