/* Custom CSS for Vending Machine Management Platform */

/* 字体对比度修复 - 确保所有文字在各种背景下都有足够的对比度 */
.text-contrast-fix {
    color: #212529 !important; /* 深色文字，确保在浅色背景下可读 */
}

.bg-dark .text-contrast-fix,
.bg-dark *:not(.text-white):not(.text-light):not(.text-success):not(.text-danger):not(.text-warning):not(.text-info):not(.text-primary) {
    color: #ffffff !important; /* 深色背景下使用白色文字 */
}

/* 修复特定的Bootstrap样式冲突 */
.text-muted {
    color: #6c757d !important;
}

.bg-dark .text-muted {
    color: #adb5bd !important; /* 深色背景下使用更亮的灰色 */
}

.text-secondary {
    color: #6c757d !important;
}

.bg-dark .text-secondary {
    color: #adb5bd !important;
}

/* 诊断结果区域特殊处理 */
#diagnosisResults {
    background-color: #343a40 !important;
    color: #ffffff !important;
}

#diagnosisResults * {
    color: #ffffff !important;
}

#diagnosisResults .text-success {
    color: #28a745 !important;
}

#diagnosisResults .text-danger {
    color: #dc3545 !important;
}

/* 全网站字体对比度增强 */
.card-body .text-muted,
.card-body .text-secondary {
    color: #495057 !important; /* 使用更深的灰色以增强对比度 */
}

/* 表格中的文字对比度修复 */
.table .text-secondary {
    color: #495057 !important;
}

/* 小文本的对比度修复 */
small.text-muted,
.small.text-muted {
    color: #495057 !important;
}

/* Alert组件内的文字对比度 */
.alert .text-muted {
    color: #495057 !important;
}

/* 状态徽章和指示器的对比度 */
.badge.bg-secondary {
    background-color: #495057 !important;
}

/* 进度条文本的对比度 */

/* 响应式表格修复 */
.table-responsive {
    min-height: 200px;
}

@media (max-width: 768px) {
    .table-responsive table {
        min-width: 700px;
    }
    
    .card-body {
        padding: 1rem 0.5rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        margin-bottom: 0.25rem;
    }
}

/* 容器响应式布局优化 */
.container-fluid {
    max-width: 100%;
    overflow-x: auto;
}

/* 表格行动作按钮组优化 */
.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    margin-right: 0.25rem;
}

/* 管理员布局响应式支持 */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    background-color: #ffffff;
    border-right: 1px solid #dee2e6;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 20px;
    transition: margin-left 0.3s ease;
}

.main-content.sidebar-expanded {
    margin-left: 250px;
}

.sidebar.collapsed + .main-content {
    margin-left: 0;
}

/* 展开按钮 */
#expandButton {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    display: none;
    background-color: #0d6efd;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
}

/* 移动端响应式布局 */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 280px;
        z-index: 1050;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 15px 10px;
        width: 100%;
    }
    
    .main-content.sidebar-expanded {
        margin-left: 0 !important;
    }
    
    /* 移动端显示汉堡菜单按钮 */
    .mobile-menu-toggle {
        display: block !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1055;
        background-color: #0d6efd;
        color: white;
        border: none;
        border-radius: 6px;
        padding: 10px 12px;
        font-size: 18px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    }
    
    /* 移动端侧边栏遮罩层 */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: block;
    }
    
    /* 移动端卡片间距调整 */
    .card {
        margin-bottom: 1rem;
    }
    
    .row > [class*="col-"] {
        margin-bottom: 1rem;
    }
    
    /* 移动端表格优化 */
    .table-responsive {
        border: none;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem;
        font-size: 0.875rem;
    }
    
    /* 移动端按钮组优化 */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        margin-bottom: 0.5rem;
        width: 100%;
    }
    
    /* 移动端标题调整 */
    h1 {
        font-size: 1.5rem;
    }
    
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .d-flex.justify-content-between > * {
        margin-bottom: 0.5rem;
    }
}

/* 平板端适配 */
@media (min-width: 769px) and (max-width: 991px) {
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
    }
    
    .main-content.sidebar-expanded {
        margin-left: 220px;
    }
}

/* 侧边栏样式 */
.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background-color: #ffffff;
}

.sidebar ul {
    padding: 0;
    margin: 0;
}

.sidebar ul li {
    list-style: none;
}

.sidebar ul li a {
    display: block;
    padding: 0.75rem 1rem;
    color: #495057;
    text-decoration: none;
    border-bottom: 1px solid #f1f3f4;
    transition: all 0.2s ease;
}

.sidebar ul li a:hover {
    background-color: #e9ecef;
    color: #0d6efd;
}

.sidebar ul li a.active {
    background-color: #0d6efd;
    color: white;
}

.sidebar ul li a i {
    width: 20px;
    margin-right: 10px;
}

/* 侧边栏和主内容区域响应式 */
@media (max-width: 992px) {
    .d-flex.sidebar-container {
        flex-direction: column;
    }
    
    main.flex-grow-1 {
        width: 100%;
        margin-left: 0 !important;
    }
}

/* 卡片组件响应式优化 */
.card {
    margin-bottom: 1.5rem;
}

.card-header h5 {
    margin-bottom: 0;
    font-size: 1.1rem;
}

/* 页面标题响应式 */
@media (max-width: 576px) {
    .h3 {
        font-size: 1.5rem;
    }
    
    .d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .d-flex.justify-content-between > div:last-child {
        margin-top: 1rem;
        width: 100%;
    }
    
    .btn {
        margin-bottom: 0.5rem;
    }
}
.progress .progress-bar {
    color: #ffffff !important;
}

/* 模态框中的文字对比度 */
.modal-body .text-muted {
    color: #495057 !important;
}

/* General Styles */
body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Login Page Styles */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-page .card {
    border: none;
    border-radius: 15px;
}

.login-page .card-body {
    border-radius: 15px;
}

.login-page .input-group-text {
    background-color: #f8f9fa;
    border-right: none;
}

.login-page .form-control {
    border-left: none;
}

.login-page .form-control:focus {
    box-shadow: none;
    border-color: #ced4da;
}

/* Admin Layout */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: #ffffff;
    color: #495057;
    padding: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
    border-right: 1px solid #dee2e6;
}

.sidebar.collapsed {
    transform: translateX(-210px);
}

.sidebar.collapsed .sidebar-header h4 {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed a span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    background-color: #ffffff;
}

.sidebar ul {
    padding: 0;
    margin: 0;
}

.sidebar li {
    border-bottom: 1px solid #f1f3f4;
}

.sidebar a {
    display: block;
    padding: 0.75rem 1rem;
    color: #495057;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sidebar a:hover {
    background-color: #e9ecef;
    color: #0d6efd;
}

.sidebar a.active {
    background-color: #0d6efd;
    color: white;
}

.sidebar a i {
    width: 20px;
    margin-right: 10px;
}

.main-content {
    flex: 1;
    margin-left: 250px;
    padding: 2rem;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

body.sidebar-collapsed .main-content {
    margin-left: 40px;
}

/* Partner Layout */
.partner-layout {
    min-height: 100vh;
    background-color: #f8f9fa;
}

.partner-layout .navbar {
    border-bottom: 2px solid #e9ecef;
}

.partner-layout .navbar-brand {
    font-weight: bold;
    color: #2c3e50 !important;
}

.partner-layout .nav-link {
    color: #495057 !important;
    font-weight: 500;
    transition: color 0.3s ease;
}

.partner-layout .nav-link:hover,
.partner-layout .nav-link.active {
    color: #007bff !important;
}

/* Card Enhancements */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.15s ease-in-out;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    border-radius: 10px 10px 0 0 !important;
}

/* Button Enhancements */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(45deg, #007bff, #0056b3);
    border: none;
}

.btn-success {
    background: linear-gradient(45deg, #28a745, #1e7e34);
    border: none;
}

.btn-danger {
    background: linear-gradient(45deg, #dc3545, #c82333);
    border: none;
}

.btn-warning {
    background: linear-gradient(45deg, #ffc107, #e0a800);
    border: none;
}

.btn-info {
    background: linear-gradient(45deg, #17a2b8, #138496);
    border: none;
}

/* Table Enhancements */
.table {
    border-radius: 10px;
    overflow: hidden;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    color: #495057;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.025);
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.1);
}

/* Form Enhancements */
.form-control {
    border-radius: 8px;
    border: 1px solid #ced4da;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-select {
    border-radius: 8px;
}

/* Badge Enhancements */
.badge {
    border-radius: 6px;
    font-weight: 500;
}

/* Alert Enhancements */
.alert {
    border: none;
    border-radius: 10px;
    border-left: 4px solid;
}

.alert-success {
    border-left-color: #28a745;
}

.alert-danger {
    border-left-color: #dc3545;
}

.alert-warning {
    border-left-color: #ffc107;
}

.alert-info {
    border-left-color: #17a2b8;
}

/* Status Dot for Navigation */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
}

/* Progress Bar Enhancements */
.progress {
    border-radius: 10px;
    height: 10px;
}

.progress-bar {
    border-radius: 10px;
}

/* Modal Enhancements */
.modal-content {
    border: none;
    border-radius: 15px;
}

.modal-header {
    border-bottom: 1px solid #dee2e6;
    border-radius: 15px 15px 0 0;
}

.modal-footer {
    border-top: 1px solid #dee2e6;
    border-radius: 0 0 15px 15px;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* KPI Cards */
.kpi-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    transition: transform 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-5px);
}

.kpi-card h3 {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 0;
}

.kpi-card p {
    margin: 0;
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    .sidebar a {
        padding: 0.75rem 1rem;
    }
    
    .sidebar a:hover {
        padding-left: 1rem;
    }
}

/* Utility Classes */
.text-gradient {
    background: linear-gradient(45deg, #007bff, #0056b3);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.shadow-custom {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.border-radius-custom {
    border-radius: 15px !important;
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-in-left {
    animation: slideInLeft 0.5s ease-in;
}

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

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .modal {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
        color: #ffffff;
    }
    
    .card {
        background-color: #1e1e1e;
        color: #ffffff;
    }
    
    .table {
        color: #ffffff;
    }
    
    .form-control,
    .form-select {
        background-color: #2d2d2d;
        border-color: #404040;
        color: #ffffff;
    }
    
    .form-control:focus,
    .form-select:focus {
        background-color: #2d2d2d;
        border-color: #80bdff;
        color: #ffffff;
    }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus States */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* High Contrast Support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000000;
    }
    
    .btn {
        border: 2px solid #000000;
    }
}
