/* ============================================
   统一全局样式 Web版 - 青少年友好配色
   版本：11.0 - 修复iPad适配问题，统一所有容器类型的响应式规则
============================================ */

:root {
    --primary-color: #5FB878;
    --primary-light: #8BCF9A;
    --primary-dark: #3E9B5A;
    --secondary-color: #FFB347;
    --secondary-light: #FFCF8A;
    --accent-color: #9B59B6;
    --success-color: #5FB878;
    --warning-color: #FFB347;
    --danger-color: #E86A5A;
    --info-color: #6EB5A0;
    --bg-body: #F0F7F0;
    --bg-card: #FFFFFF;
    --bg-hover: #FAFDFA;
    --bg-modal: rgba(44, 62, 47, 0.6);
    --text-primary: #2C3E2F;
    --text-secondary: #6B8C6B;
    --text-light: #9AB89A;
    --text-disabled: #C5D6C5;
    --border-light: #E5F0E5;
    --border-medium: #D0E4D0;
    --gradient-header: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    --gradient-card: linear-gradient(135deg, #FFFFFF, #FDFFFD);
    --tab-height: 60px;
    --container-max-width: 100%;
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-body);
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

/* ============================================
   应用容器 - 统一宽度
============================================ */
.app-container, .auth-container, .detail-container, .history-container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    background-color: var(--bg-card);
    position: relative;
    box-shadow: 0 0 20px rgba(95, 184, 120, 0.1);
    border-radius: 44px 44px 0 0;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: var(--tab-height);
}

/* ============================================
   顶部导航栏
============================================ */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 40px 28px;
    background: var(--gradient-header);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    flex-shrink: 0;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 1px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.2);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s;
}

.user-info:active {
    background: rgba(255,255,255,0.3);
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-avatar {
    font-size: 18px;
}

/* ============================================
   其他页面头部样式 - 保持统一的视觉效果
============================================ */
.detail-header, .history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 40px 20px;
    background: var(--gradient-header);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.detail-header h1, .history-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.back-btn {
    background: none;
    border: none;
    font-size: 30px;
    cursor: pointer;
    padding: 0;
    width: 70px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border-radius: 50%;
    transition: background 0.2s;
}

.back-btn:active {
    background: rgba(255,255,255,0.2);
}

/* ============================================
   内容区域
============================================ */
.content-area {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background-color: var(--bg-card);
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) var(--bg-card);
    width: 100%;
}

.content-area::-webkit-scrollbar {
    width: 4px;
    background-color: var(--bg-card);
}

.content-area::-webkit-scrollbar-track {
    background-color: var(--bg-card);
    border-radius: 2px;
}

.content-area::-webkit-scrollbar-thumb {
    background-color: var(--primary-light);
    border-radius: 2px;
}

.content-area::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-color);
}

/* ============================================
   Tab栏 - 固定在底部
============================================ */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    padding: 8px 0;
    z-index: 200;
    background-color: var(--bg-card);
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-light);
    background: none;
    border: none;
    font-size: inherit;
}

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

.tab-icon {
    font-size: 22px;
    margin-bottom: 4px;
}

.tab-label {
    font-size: 11px;
}

/* 分类标题样式 */
.section-title {
    padding: 12px 20px 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title:first-of-type {
    border-top: none;
}

.section-icon {
    font-size: 16px;
}

.section-count {
    font-size: 12px;
    font-weight: normal;
    color: var(--text-secondary);
    margin-left: auto;
}

/* 统一卡片样式 */
.hotline-card, .rating-card, .history-item, .rating-history-item {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 12px;
    margin-left: 20px;
    margin-right: 20px;
    box-shadow: 0 2px 12px rgba(95, 184, 120, 0.08);
    border: 1px solid var(--border-light);
    transition: transform 0.2s, box-shadow 0.2s;
}

.hotline-card:active, .rating-card:active,
.history-item:active, .rating-history-item:active {
    transform: scale(0.98);
    box-shadow: 0 4px 8px rgba(95, 184, 120, 0.12);
}

.card-row1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-left {
    flex: 1;
}

.card-buttons {
    display: flex;
    gap: 8px;
}

.hotline-name, .history-name, .history-hotline-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.hotline-phone, .history-phone {
    font-size: 13px;
    color: var(--primary-color);
    margin-top: 4px;
}

.btn-rating, .btn-call {
    padding: 8px 12px;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-rating {
    background-color: var(--secondary-color);
    color: white;
}

.btn-rating:active {
    background-color: var(--warning-color);
}

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

.btn-call:active {
    background-color: var(--primary-dark);
}

.card-row2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.service-time {
    display: flex;
    align-items: center;
    gap: 4px;
}

.called-badge {
    display: inline-block;
    background-color: #E8F5E9;
    color: var(--primary-color);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 8px;
}

.bottom-tip {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 13px;
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-light);
    font-size: 14px;
}

/* 搜索栏 */
.search-bar {
    display: flex;
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
}

.search-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-medium);
    border-radius: 25px;
    font-size: 14px;
    background: var(--bg-body);
    outline: none;
    transition: all 0.2s;
    color: var(--text-primary);
    pointer-events: auto;
    z-index: 1;
}

.search-input:focus {
    border-color: var(--primary-color);
    background: var(--bg-card);
    box-shadow: 0 0 0 2px rgba(95, 184, 120, 0.2);
}

.search-btn {
    padding: 0 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    pointer-events: auto;
}

.search-btn:active {
    background: var(--primary-dark);
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-modal);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(95, 184, 120, 0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    font-size: 14px;
}

.load-more {
    text-align: center;
    padding: 20px;
}

.btn-load-more {
    background: var(--bg-body);
    border: 1px solid var(--border-medium);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-load-more:active {
    background: var(--border-light);
}

.error-message {
    background-color: #FFEFED;
    color: var(--danger-color);
    padding: 12px;
    border-radius: 8px;
    margin: 12px 20px;
    font-size: 14px;
    text-align: center;
}

/* 弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 20px;
    width: 100%;
    max-width: 340px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(95, 184, 120, 0.2);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:active {
    color: var(--text-secondary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
}

.btn-cancel, .btn-submit {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-cancel {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}

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

.btn-cancel:active, .btn-submit:active {
    opacity: 0.8;
}

/* 列表容器 */
.list-container {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 20px;
}

#ratingList {
    padding-top: 12px;
}

/* ============================================
   iPad 专用修复 - 统一所有容器类型，铺满全屏
============================================ */
@media (min-width: 768px) {
    html, body {
        min-height: 100vh;
        height: auto;
    }

    body {
        min-height: 100vh;
        height: auto;
    }

    .app-container, .auth-container, .detail-container, .history-container {
        min-height: 100vh;
        height: auto;
    }

    .content-area {
        min-height: 300px;
    }
}

/* iPad 竖屏模式 - 铺满全屏 */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .app-container, .auth-container, .detail-container, .history-container {
        max-width: 100%;
        border-radius: 0;
    }

    .tab-bar {
        max-width: 100%;
    }

    .hotline-card, .rating-card, .history-item, .rating-history-item {
        margin-left: 24px;
        margin-right: 24px;
        padding: 18px;
    }

    .section-title {
        padding-left: 24px;
        padding-right: 24px;
        font-size: 17px;
    }

    .search-bar {
        padding-left: 24px;
        padding-right: 24px;
    }

    .app-title {
        font-size: 24px;
    }

    .tab-icon {
        font-size: 26px;
    }

    .tab-label {
        font-size: 13px;
    }

    .hotline-name {
        font-size: 18px;
    }

    .btn-rating, .btn-call {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* iPad 横屏模式 - 铺满全屏 */
@media (min-width: 1024px) and (orientation: landscape) {
    .app-container, .auth-container, .detail-container, .history-container {
        max-width: 100%;
        border-radius: 0;
    }

    .tab-bar {
        max-width: 100%;
    }

    .hotline-card, .rating-card, .history-item, .rating-history-item {
        margin-left: 28px;
        margin-right: 28px;
    }

    .section-title {
        padding-left: 28px;
        padding-right: 28px;
    }

    .search-bar {
        padding-left: 28px;
        padding-right: 28px;
    }
}

/* iPad Pro 12.9英寸 - 铺满全屏 */
@media (min-width: 1025px) {
    .app-container, .auth-container, .detail-container, .history-container {
        max-width: 100%;
        border-radius: 0;
    }

    .tab-bar {
        max-width: 100%;
    }

    .hotline-card, .rating-card, .history-item, .rating-history-item {
        margin-left: 32px;
        margin-right: 32px;
        padding: 20px;
    }

    .section-title {
        padding-left: 32px;
        padding-right: 32px;
        font-size: 18px;
    }
}

/* ============================================
   小屏幕响应式适配
============================================ */
@media (max-width: 500px) {
    .app-container, .auth-container, .detail-container, .history-container {
        max-width: 100%;
        border-radius: 24px 24px 0 0;
    }

    .tab-bar {
        max-width: 100%;
    }

    .app-header {
        padding: 30px 20px;
    }

    .detail-header, .history-header {
        padding: 30px 20px;
    }

    .app-title {
        font-size: 18px;
    }

    .btn-rating, .btn-call {
        padding: 6px 10px;
        font-size: 12px;
    }

    .hotline-name, .history-name {
        font-size: 15px;
    }

    .tab-icon {
        font-size: 20px;
    }

    .tab-label {
        font-size: 10px;
    }

    .hotline-card, .rating-card, .history-item, .rating-history-item {
        margin-left: 16px;
        margin-right: 16px;
    }

    .section-title {
        padding-left: 16px;
        padding-right: 16px;
    }

    .search-bar {
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (max-width: 380px) {
    .card-buttons {
        gap: 6px;
    }

    .btn-rating, .btn-call {
        padding: 5px 8px;
        font-size: 11px;
    }

    .tab-bar {
        padding: 6px 0;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .tab-icon {
        font-size: 18px;
    }

    .hotline-card, .rating-card, .history-item, .rating-history-item {
        margin-left: 12px;
        margin-right: 12px;
    }

    .section-title {
        padding-left: 12px;
        padding-right: 12px;
    }
}