/* ========================================
   期货新手离线工具包 - 样式表
   ======================================== */

/* CSS 变量定义 - 主题色彩 */
:root {
    /* 主色调 */
    --primary-color: #1a365d;           /* 深蓝色 - 主色 */
    --secondary-color: #d4af37;         /* 金色 - 辅助色 */
    --accent-color: #2c5282;            /* 深蓝色变体 */
    
    /* 功能色 */
    --success-color: #10b981;           /* 绿色 - 盈利 */
    --danger-color: #ef4444;            /* 红色 - 亏损 */
    --warning-color: #f59e0b;           /* 黄色 - 警告 */
    --info-color: #3b82f6;              /* 蓝色 - 信息 */
    
    /* 中性色 */
    --dark-color: #1f2937;
    --light-color: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-600: #64748b;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* 背景色 */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    
    /* 文字色 */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    /* 边框色 */
    --border-color: #e2e8f0;
    --border-focus: var(--primary-color);
    
    /* 阴影 */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* 过渡动画 */
    --transition: all 0.3s ease;
}

/* 深色主题 */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #334155;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border-color: #334155;
    --border-focus: var(--secondary-color);
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
}

/* ========================================
   基础样式重置
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   导航栏样式
   ======================================== */
.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%) !important;
    box-shadow: var(--shadow-md);
    padding: 0.75rem 0;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: white !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: 0.375rem;
    transition: var(--transition);
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    color: white !important;
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

/* 主题切换开关 */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    margin-left: 1rem;
}

.theme-switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: rgba(255, 255, 255, 0.2);
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: var(--transition);
    border-radius: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
}

.slider:before {
    background-color: white;
    bottom: 4px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: var(--transition);
    width: 26px;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--secondary-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider .fas {
    color: white;
    font-size: 16px;
    z-index: 1;
}

/* ========================================
   主内容区样式
   ======================================== */
main {
    flex: 1;
    padding-bottom: 3rem;
}

/* 工具区块通用样式 */
.tool-section {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.tool-section.active {
    display: block;
}

.tool-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 0;
    border-bottom: 2px solid var(--border-color);
}

.tool-header h2 {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tool-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* ========================================
   首页英雄区样式
   ======================================== */
.hero-section {
    padding: 3rem 0;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-radius: 1rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.hero-section h1 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.feature-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.feature-item i {
    font-size: 1.5rem;
}

.feature-item span {
    font-weight: 600;
    color: var(--text-primary);
}

.hero-image {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* ========================================
   表单样式
   ======================================== */
.calculator-form {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.calculator-form:hover {
    box-shadow: var(--shadow-lg);
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-control,
.form-select {
    background-color: var(--bg-input);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 0.2rem rgba(26, 54, 93, 0.25);
    color: var(--text-primary);
}

.form-range {
    height: 8px;
    background-color: var(--gray-200);
    border-radius: 4px;
}

.form-range::-webkit-slider-thumb {
    background-color: var(--primary-color);
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
}

.form-range::-moz-range-thumb {
    background-color: var(--primary-color);
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
}

/* ========================================
   按钮样式
   ======================================== */
.btn {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: var(--transition);
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

.btn-primary:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background-color: transparent;
}

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

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--gray-300);
    background-color: transparent;
}

.btn-outline-secondary:hover {
    background-color: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--text-primary);
}

.btn-outline-success {
    color: var(--success-color);
    border-color: var(--success-color);
}

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

.btn-outline-danger {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-outline-danger:hover {
    background-color: var(--danger-color);
    color: white;
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ========================================
   结果卡片样式
   ======================================== */
.result-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    height: 100%;
    transition: var(--transition);
}

.result-card:hover {
    box-shadow: var(--shadow-lg);
}

.result-card h4 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
}

.result-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.result-item:hover {
    transform: translateX(4px);
}

.result-item.highlight {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    border-left: 4px solid var(--secondary-color);
}

.result-item.highlight strong {
    color: var(--secondary-color);
    font-size: 1.2rem;
}

.result-item span {
    color: var(--text-secondary);
    font-weight: 500;
}

.result-item strong {
    color: var(--text-primary);
    font-weight: 700;
}

/* ========================================
   表格样式
   ======================================== */
.table {
    background: var(--bg-card);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 0;
}

.table thead th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    font-weight: 600;
    padding: 1rem;
    border: none;
    text-align: center;
    vertical-align: middle;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: var(--bg-secondary);
    transform: scale(1.01);
}

.table tbody td {
    padding: 1rem;
    border-color: var(--border-color);
    color: var(--text-primary);
    text-align: center;
    vertical-align: middle;
}

.table-responsive {
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

/* ========================================
   日历样式
   ======================================== */
.calendar-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

#current-month {
    background: var(--primary-color);
    color: white;
    border: none;
    font-weight: 700;
    min-width: 150px;
}

.calendar-table .contract-tag {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    margin: 0.125rem;
    background: var(--primary-color);
    color: white;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.calendar-table .exchange-badge {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    background: var(--secondary-color);
    color: var(--dark-color);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ========================================
   搜索框样式
   ======================================== */
.search-box {
    max-width: 500px;
    margin: 0 auto 2rem;
}

.search-box .input-group-text {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.search-box .form-control {
    border-left: none;
}

.search-box .form-control:focus {
    box-shadow: none;
    border-color: var(--border-focus);
}

/* ========================================
   图表容器样式
   ======================================== */
.chart-container {
    position: relative;
    height: 200px;
    margin-top: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1rem;
}

/* ========================================
   底部样式
   ======================================== */
.footer {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    padding: 2rem 0;
    margin-top: auto;
}

.footer h6 {
    color: var(--secondary-color);
    font-weight: 700;
    margin-bottom: 1rem;
}

.footer .disclaimer {
    font-size: 0.875rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

.footer p {
    margin-bottom: 0.5rem;
}

/* ========================================
   动画效果
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 成功/失败动画 */
.result-positive {
    animation: pulse 0.6s ease-in-out;
}

.result-positive strong {
    color: var(--success-color) !important;
}

.result-negative {
    animation: shake 0.6s ease-in-out;
}

.result-negative strong {
    color: var(--danger-color) !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ========================================
   响应式设计
   ======================================== */

/* 平板设备 */
@media (max-width: 992px) {
    .hero-section {
        text-align: center;
        padding: 2rem 1rem;
    }
    
    .feature-list {
        grid-template-columns: 1fr;
    }
    
    .calculator-form,
    .result-card {
        margin-bottom: 2rem;
    }
    
    .tool-header h2 {
        font-size: 1.75rem;
    }
}

/* 手机设备 */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.9rem;
    }
    
    .hero-section {
        padding: 1.5rem 1rem;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .tool-header {
        padding: 1.5rem 0;
        margin-bottom: 1.5rem;
    }
    
    .tool-header h2 {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .calculator-form,
    .result-card {
        padding: 1.5rem;
    }
    
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .search-box {
        margin-bottom: 1.5rem;
    }
    
    .calendar-controls .btn-group {
        flex-direction: row;
        width: 100%;
    }
    
    .calendar-controls .btn {
        flex: 1;
        font-size: 0.85rem;
        padding: 0.5rem;
    }
    
    #current-month {
        min-width: auto;
        flex: 2;
    }
    
    .theme-switch-wrapper {
        margin-left: 0.5rem;
    }
    
    .footer {
        padding: 1.5rem 0;
    }
    
    .footer .disclaimer {
        font-size: 0.8rem;
    }
}

/* 小屏手机 */
@media (max-width: 480px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .hero-section h1 {
        font-size: 1.75rem;
    }
    
    .feature-item {
        padding: 0.75rem;
    }
    
    .feature-item i {
        font-size: 1.25rem;
    }
    
    .tool-header h2 {
        font-size: 1.25rem;
    }
    
    .calculator-form,
    .result-card {
        padding: 1.25rem;
    }
    
    .result-item {
        padding: 0.625rem 0.875rem;
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }
    
    .chart-container {
        height: 150px;
        padding: 0.5rem;
    }
}

/* ========================================
   打印样式
   ======================================== */
@media print {
    .navbar,
    .footer,
    .theme-switch-wrapper,
    .btn {
        display: none !important;
    }
    
    .tool-section {
        display: block !important;
        page-break-inside: avoid;
    }
    
    .calculator-form,
    .result-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    body {
        background: white;
        color: black;
    }
}
