/* 云服务器主样式表 - 响应式设计 */

:root {
    --primary-color: #198754;
    --primary-dark: #157347;
    --secondary-color: #20c997;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --light-bg: #f8f9fa;
    --white: #ffffff;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    background-color: var(--light-bg);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    padding-bottom: 80px; /* 为底部导航留空间 */
    padding-bottom: calc(80px + constant(safe-area-inset-bottom));
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* 基础布局（不依赖 Bootstrap CSS） */
.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
}

.navbar {
    display: flex;
    align-items: center;
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.row {
    display: flex;
    flex-wrap: wrap;
}

.col {
    flex: 1 0 0%;
}

/* 导航栏 */
.navbar-custom {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: var(--shadow-md);
    padding: 1rem 0;
}

.navbar-custom .navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white) !important;
}

.navbar-custom .nav-link {
    color: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.navbar-custom .nav-link:hover {
    color: var(--white);
}

/* 卡片样式 */
.card-custom {
    background: var(--white);
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    overflow: hidden;
}

.card-custom:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-clickable {
    cursor: pointer;
}

.card-clickable:active {
    transform: scale(0.98);
}

/* 余额卡片 */
.balance-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.balance-amount {
    font-size: 3rem;
    font-weight: 800;
    margin: 0.5rem 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.balance-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.balance-icon {
    font-size: 4rem;
    opacity: 0.3;
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
}

.balance-info {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.9rem;
}

/* 表单元素 */
.form-control,
.form-select {
    border-radius: 12px;
    border: 2px solid var(--border-color);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.15);
}

.form-control-lg {
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

/* 按钮 */
.btn {
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-success {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
}

.btn-success:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-success:active {
    transform: translateY(0);
}

.btn-outline-success,
.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-success:hover,
.btn-outline-primary:hover {
    background: var(--primary-color);
    color: var(--white);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + constant(safe-area-inset-bottom));
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
}

.bottom-nav .nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.bottom-nav .nav-link i {
    font-size: 1.5rem;
}

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

.bottom-nav .nav-link:hover {
    color: var(--primary-color);
}

.bottom-nav .nav-link small {
    font-size: 0.75rem;
}

/* 功能卡片网格 */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.feature-card {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: 16px;
    background: var(--white);
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.feature-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    color: var(--text-dark);
}

.feature-card i {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    display: block;
    color: var(--primary-color);
}

.feature-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.feature-card.disabled:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* 登录页面 */
.login-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.login-card {
    width: 100%;
    max-width: 450px;
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h3 {
    color: var(--primary-color);
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* 提示信息 */
.alert {
    border-radius: 12px;
    border: none;
    padding: 1rem 1.25rem;
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #856404;
}

.alert-info {
    background-color: rgba(13, 202, 240, 0.1);
    color: #055160;
}

/* 加载动画 */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* 输入组 */
.input-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.input-group .form-control {
    flex: 1 1 auto;
    min-width: 0; /* 关键：允许 flex 收缩但确保有最小空间 */
}

.input-group .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* 表单对齐：标签列固定、输入列对齐（移动端自动上下堆叠） */
.form-item {
    display: grid;
    grid-template-columns: 9.5rem 1fr;
    column-gap: 1rem;
    row-gap: 0.35rem;
    align-items: start; /* 改为 start 避免 input-group 被压缩 */
}

.form-item .form-label {
    margin: 0;
    padding-top: 0.75rem; /* 对齐输入框顶部 */
}

.form-item .form-control,
.form-item .form-select,
.form-item .input-group {
    width: 100%;
    min-width: 0; /* 确保 grid 子项能正确收缩 */
}

.form-item .form-text,
.form-item .invalid-feedback {
    grid-column: 2;
}

@media (max-width: 576px) {
    .form-item {
        grid-template-columns: 1fr;
    }
    .form-item .form-text,
    .form-item .invalid-feedback {
        grid-column: 1;
    }
}

@media (max-width: 360px) {
    .input-group {
        flex-direction: column;
    }
    .input-group .btn {
        width: 100%;
    }
}

/* 表单辅助文本 */
.form-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* 响应式设计 - 移动端 */
@media (max-width: 576px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .balance-amount {
        font-size: 2.5rem;
    }

    .balance-icon {
        font-size: 3rem;
        right: 1rem;
    }

    .login-card {
        padding: 1.5rem;
    }

    .login-header h3 {
        font-size: 1.75rem;
    }

    .btn-lg {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

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

    .feature-card {
        padding: 1.25rem 0.75rem;
    }

    .feature-card i {
        font-size: 2.5rem;
    }
}

/* 响应式设计 - 平板 */
@media (min-width: 577px) and (max-width: 768px) {
    .feature-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 响应式设计 - PC */
@media (min-width: 769px) {
    body {
        padding-bottom: 2rem;
    }

    .bottom-nav {
        display: none; /* PC端隐藏底部导航 */
    }

    .navbar-custom {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    /* PC端添加侧边导航 */
    .desktop-nav {
        display: block;
        position: fixed;
        left: 2rem;
        top: 50%;
        transform: translateY(-50%);
        background: var(--white);
        border-radius: 16px;
        padding: 1rem;
        box-shadow: var(--shadow-md);
    }

    .desktop-nav a {
        display: block;
        padding: 0.75rem;
        color: var(--text-muted);
        text-decoration: none;
        border-radius: 8px;
        margin-bottom: 0.5rem;
        transition: all 0.3s ease;
    }

    .desktop-nav a:hover,
    .desktop-nav a.active {
        background: var(--light-bg);
        color: var(--primary-color);
    }

    .desktop-nav i {
        font-size: 1.5rem;
    }

    .main-content {
        max-width: 900px;
        margin: 0 auto;
    }
}

/* 动画效果 */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 表单验证提示 */
.invalid-feedback {
    display: none;
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-control.is-invalid {
    border-color: var(--danger-color);
}

/* 支持直接兄弟、input-group 后、以及 form-item 布局 */
.form-control.is-invalid ~ .invalid-feedback,
.input-group:has(.form-control.is-invalid) ~ .invalid-feedback,
.form-item:has(.form-control.is-invalid) .invalid-feedback {
    display: block !important;
}

.form-control.is-valid {
    border-color: var(--primary-color);
}

/* 模态框样式（如果需要） */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

/* 过渡效果 */
.transition-all {
    transition: all 0.3s ease;
}

/* 工具类 */
.text-success {
    color: var(--primary-color) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.fw-bold {
    font-weight: 700 !important;
}

.mb-0 { margin-bottom: 0 !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.pt-3 { padding-top: 1rem !important; }

.d-flex { display: flex !important; }
.d-none { display: none !important; }
.justify-content-between { justify-content: space-between !important; }
.align-items-center { align-items: center !important; }
.text-center { text-align: center !important; }
.w-100 { width: 100% !important; }

.text-white { color: var(--white) !important; }
.text-secondary { color: var(--text-muted) !important; }
.text-decoration-none { text-decoration: none !important; }

.gap-3 { gap: 1rem !important; }

.m-0 { margin: 0 !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.p-4 { padding: 1.5rem !important; }

.ms-1 { margin-left: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }

.fs-4 { font-size: 1.5rem !important; }

@media (min-width: 576px) {
    .d-sm-inline { display: inline !important; }
}

@media (min-width: 768px) {
    .d-md-inline { display: inline !important; }
}
.me-2 { margin-right: 0.5rem !important; }

.fs-4 { font-size: 1.5rem !important; }

.d-none { display: none !important; }

@media (min-width: 576px) {
    .d-sm-inline { display: inline !important; }
}

@media (min-width: 768px) {
    .d-md-inline { display: inline !important; }
}
