:root {
    --sidebar-bg: #111827;
    --sidebar-text: #9ca3af;
    --sidebar-active: #374151; /* Dark grey for active */
    --primary-blue: #3b82f6;
    --danger-red: #ef4444;
    --sidebar-width: 200px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: #f3f4f6;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-brand {
    padding: 0.75rem;
    color: white;
    font-size: 1.1rem;
    font-weight: bold;
    border-bottom: 1px solid #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    color: var(--sidebar-text);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: background-color 0.2s;
    font-size: 0.9rem;
}

.nav-link:hover, .nav-link.active {
    background-color: var(--sidebar-active);
    color: white;
}

.nav-link.active {
    border-left: 3px solid var(--primary-blue);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-bar {
    background: white;
    padding: 0.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
    height: 50px;
    flex-shrink: 0;
}

.content-area {
    padding: 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 50px);
}

/* Dashboard Grid - 上半部分面板区域 */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    flex: 0 0 65%;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    :root {
        --sidebar-width: 180px;
    }
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    .sidebar.active {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    .content-area {
        padding: 0.5rem;
        height: calc(100vh - 50px);
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
}

/* Panel - 填满网格单元格 */
.panel {
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    min-height: 0;
    height: 100%;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem;
}

.panel-body.p-0 {
    padding: 0;
}

.panel-body.p-3 {
    padding: 0.75rem;
}

.panel-header {
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid #f3f4f6;
    background-color: #f9fafb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* Enhanced Form Styling */
.section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 700;
    margin-bottom: 0.4rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid #e5e7eb;
}

.form-group-sm {
    margin-bottom: 0.4rem;
}
.form-group-sm label {
    font-size: 0.7rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.1rem;
    display: block;
}
.form-control-sm-custom, .form-select-sm-custom {
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
    border: 1px solid #d1d5db;
    border-radius: 0.3rem;
    width: 100%;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.form-control-sm-custom:focus, .form-select-sm-custom:focus {
    border-color: var(--primary-blue);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.strategy-table th {
    background-color: #eff6ff;
    color: #1e40af;
    font-size: 0.7rem;
    text-align: center;
    padding: 0.4rem 0.25rem;
}
.strategy-table td input {
    text-align: center;
    font-weight: 600;
    color: #2563eb;
    font-size: 0.8rem;
}

/* Custom Table for Panels */
.custom-table {
    font-size: 0.8rem;
}
.custom-table th {
    font-size: 0.75rem;
    padding: 0.4rem 0.5rem;
    background-color: #f9fafb;
    font-weight: 600;
    white-space: nowrap;
}
.custom-table td {
    padding: 0.35rem 0.5rem;
    vertical-align: middle;
}

/* Scoped Utility */
.text-red { color: var(--danger-red); }
.bg-blue { background-color: var(--primary-blue); color: white; }
.bg-red { background-color: var(--danger-red); color: white; }

.btn-xs {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

/* Log Area - 下半部分日志区域 */
.log-area {
    background: #1f2937;
    flex: 1 1 auto;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
    margin-top: 0.75rem;
    color: #e5e7eb;
    font-family: 'Consolas', 'Monaco', monospace;
    overflow: hidden;
}

.log-area h6 {
    flex-shrink: 0;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.log-area .log-content {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    display: flex;
    flex-direction: column;
    padding-right: 8px;
    line-height: 1.4;
    font-size: 12px;
}

.log-area .log-content > div {
    padding: 1px 0;
    word-wrap: break-word;
    white-space: pre-wrap;
    word-break: break-all;
    flex-shrink: 0;
}

/* 自定义滚动条样式 */
.log-area .log-content::-webkit-scrollbar {
    width: 8px;
}

.log-area .log-content::-webkit-scrollbar-track {
    background: #374151;
    border-radius: 4px;
}

.log-area .log-content::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 4px;
}

.log-area .log-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Input spinners and toggles override */
.number-input-group {
    display: flex;
    align-items: center;
}
.number-input-group button {
    border: 1px solid #d1d5db;
    background: #f9fafb;
    padding: 0 0.5rem;
    cursor: pointer;
}
.number-input-group input {
    text-align: center;
    border-left: none;
    border-right: none;
    width: 50px;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
}
.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary-blue);
}
input:checked + .slider:before {
    transform: translateX(14px);
}

/*
   刷新按钮美化样式
*/
#refreshBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-weight: 500;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 80px;
}

#refreshBtn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

#refreshBtn:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    transform: translateY(-2px);
}

#refreshBtn:hover::before {
    left: 100%;
}

#refreshBtn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

#refreshBtn #refreshIcon {
    transition: transform 0.3s ease;
}

#refreshBtn:hover #refreshIcon:not(.refresh-spin) {
    transform: rotate(180deg);
}

/* 刷新按钮旋转动画 */
.refresh-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/*
   优化: 字体加载策略
   优先使用系统字体，避免Web字体加载阻塞
*/
img {
    max-width: 100%;
    height: auto;
}

/* Sortable Table Styles */
.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px !important;
    user-select: none;
}

.sortable:hover {
    background-color: #f1f5f9; /* Light gray on hover */
}

/* Default sort icon (neutral) */
.sortable::after {
    content: '↕'; /* Unicode up/down arrow */
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
    font-size: 0.8rem;
    font-family: sans-serif;
}

/* Active sort icons */
.sortable.sort-asc::after {
    content: '↑'; /* Up arrow */
    color: var(--primary-blue);
    opacity: 1;
    font-weight: bold;
}

.sortable.sort-desc::after {
    content: '↓'; /* Down arrow */
    color: var(--primary-blue);
    opacity: 1;
    font-weight: bold;
}

/* ========== Toast 提示框样式 ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 280px;
    max-width: 400px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: toastSlideIn 0.3s ease-out;
    pointer-events: auto;
    font-size: 14px;
    line-height: 1.4;
}

.toast.toast-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.toast.toast-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.toast.toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.toast.toast-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.toast-message {
    opacity: 0.95;
    word-break: break-word;
}

.toast-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.toast-close:hover {
    opacity: 1;
}

.toast.toast-hiding {
    animation: toastSlideOut 0.3s ease-in forwards;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========== 订单信息卡片样式 ========== */
.order-list-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.order-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.order-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.order-card-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e5e7eb;
}

.order-number {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
}

.order-card-body {
    padding: 16px;
}

.order-info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.order-info-row:last-child {
    margin-bottom: 0;
}

.order-info-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.order-value {
    font-size: 14px;
    color: #1f2937;
}

.order-remark {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.order-card-footer {
    background: #f9fafb;
    padding: 10px 16px;
    border-top: 1px solid #e5e7eb;
}

/* 订单列表滚动条 */
.order-list-wrapper::-webkit-scrollbar {
    width: 6px;
}

.order-list-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.order-list-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.order-list-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ========== 确认对话框样式 ========== */
.confirm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease-out;
}

.confirm-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 420px;
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

.confirm-modal-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.confirm-modal-header i {
    font-size: 20px;
}

.confirm-modal-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.confirm-modal-body {
    padding: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.confirm-modal-body .info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed #e5e7eb;
    font-size: 13px;
}

.confirm-modal-body .info-item:last-child {
    border-bottom: none;
}

.confirm-modal-body .info-label {
    color: #6b7280;
    font-weight: 500;
}

.confirm-modal-body .info-value {
    color: #1f2937;
    font-weight: 600;
    text-align: right;
    max-width: 200px;
    word-break: break-all;
}

.confirm-modal-footer {
    padding: 16px 20px;
    background: #f9fafb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #e5e7eb;
}

.confirm-modal-footer .btn-cancel {
    padding: 8px 20px;
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.confirm-modal-footer .btn-cancel:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.confirm-modal-footer .btn-confirm {
    padding: 8px 20px;
    border: none;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.confirm-modal-footer .btn-confirm:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========== 订单列表表格样式 ========== */
.order-table-wrapper {
    max-height: 350px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.order-table thead {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    position: sticky;
    top: 0;
    z-index: 1;
}

.order-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.order-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
    vertical-align: middle;
}

.order-table tbody tr:hover {
    background: #f8fafc;
}

.order-table tbody tr:last-child td {
    border-bottom: none;
}

.order-table .order-id-cell {
    font-family: monospace;
    font-size: 11px;
    color: #6b7280;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-table .btn-stop {
    padding: 4px 10px;
    font-size: 11px;
    border: none;
    background: #ef4444;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.order-table .btn-stop:hover {
    background: #dc2626;
}

.order-table .btn-stop:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.order-table .status-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.order-table .status-running {
    background: #dcfce7;
    color: #166534;
}

.order-table .status-stopped {
    background: #fef3c7;
    color: #92400e;
}

.order-table .status-completed {
    background: #e0e7ff;
    color: #3730a3;
}

/* 订单表格滚动条 */
.order-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.order-table-wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.order-table-wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.order-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
