/* ===================================================================
   SSL Deploy Panel — BaoTa-inspired styles
   =================================================================== */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
        "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
    line-height: 1.6;
}

a {
    color: #20a53a;
    text-decoration: none;
}
a:hover {
    color: #178a2e;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 220px;
    background: #001529;
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
    font-size: 28px;
}

.brand-name {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.brand-version {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.65);
    transition: all 0.2s;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
    color: #fff;
    background: rgba(32, 165, 58, 0.15);
    border-left-color: #20a53a;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.engine-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
}

.status-dot.online {
    background: #20a53a;
    box-shadow: 0 0 6px rgba(32, 165, 58, 0.6);
}

/* --- Main wrapper --- */
.main-wrapper {
    margin-left: 220px;
    min-height: 100vh;
}

/* --- Topbar --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    display: none;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    color: #333;
}

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 13px;
    color: #666;
}

/* --- Content area --- */
.content {
    padding: 24px;
}

/* --- Stat cards --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px 24px;
    border-left: 4px solid #ddd;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.stat-card.border-blue {
    border-left-color: #1890ff;
}
.stat-card.border-green {
    border-left-color: #20a53a;
}
.stat-card.border-orange {
    border-left-color: #fa8c16;
}
.stat-card.border-red {
    border-left-color: #f5222d;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: #999;
    margin-top: 4px;
}

/* --- Panel / Card --- */
.panel {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-body {
    padding: 20px 24px;
}

/* --- Tables --- */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.table th {
    font-weight: 600;
    color: #666;
    font-size: 13px;
    background: #fafafa;
}

.table tbody tr:hover {
    background: #f9fbfc;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
    white-space: nowrap;
}

.badge-success {
    background: #e6f7ee;
    color: #20a53a;
}
.badge-warning {
    background: #fff7e6;
    color: #fa8c16;
}
.badge-danger {
    background: #fff1f0;
    color: #f5222d;
}
.badge-info {
    background: #e6f7ff;
    color: #1890ff;
}
.badge-default {
    background: #f5f5f5;
    color: #999;
}

/* --- Toggle switch --- */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 22px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: #20a53a;
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    line-height: 1.5;
}

.btn:hover {
    opacity: 0.85;
}

.btn-primary {
    background: #20a53a;
    color: #fff;
    border-color: #20a53a;
}

.btn-primary:hover {
    background: #178a2e;
    border-color: #178a2e;
    opacity: 1;
}

.btn-danger {
    background: #f5222d;
    color: #fff;
    border-color: #f5222d;
}

.btn-default {
    background: #fff;
    color: #333;
    border-color: #d9d9d9;
}

.btn-default:hover {
    color: #20a53a;
    border-color: #20a53a;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
    color: #333;
}

.form-input:focus {
    outline: none;
    border-color: #20a53a;
    box-shadow: 0 0 0 2px rgba(32, 165, 58, 0.15);
}

.form-input[readonly] {
    background: #f5f5f5;
    color: #999;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    padding-top: 24px;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #20a53a;
}

.required {
    color: #f5222d;
}

.search-input {
    width: 240px;
}

/* ── Site Selector ─────────────────────────────────────── */
.site-selector-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

.site-selector-header .checkbox-label {
    padding-top: 0;
    margin: 0;
    white-space: nowrap;
}

.site-count {
    font-size: 13px;
    color: #888;
    white-space: nowrap;
}

.site-selected-count {
    font-size: 13px;
    color: #20a53a;
    margin-left: auto;
    white-space: nowrap;
}

.site-search {
    position: relative;
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
}

.site-search .form-input {
    width: 100%;
    padding-right: 32px;
}

.site-search .search-icon {
    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    pointer-events: none;
}

.site-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}

.site-list .site-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.site-list .site-item:hover {
    background: #f5f7fa;
}

.site-list .site-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #20a53a;
    flex-shrink: 0;
}

.site-list .site-item .site-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.site-list .site-item .site-icon.ssl-on {
    color: #20a53a;
}

.site-list .site-item .site-icon.ssl-off {
    color: #f5222d;
}

.site-list .site-item .site-domain {
    flex: 1;
    font-size: 14px;
    color: #333;
}

/* ── Domain section labels (LE page) ─────────────────── */
.domain-section-label {
    font-size: 13px;
    font-weight: 600;
    color: #f5222d;
    padding: 10px 4px 4px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 2px;
}

.domain-section-label.domain-section-certed {
    color: #20a53a;
    margin-top: 12px;
}

.domain-item-certed {
    opacity: 0.65;
}

.domain-check-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- SAN domain list --- */
.san-cell {
    max-width: 400px;
}

.san-domain {
    display: block;
    color: #20a53a;
    font-size: 13px;
    line-height: 1.8;
    text-decoration: none;
}

a.san-domain:hover {
    color: #178a2e;
    text-decoration: underline;
}

/* --- Upload zone --- */
.upload-zone {
    border: 2px dashed #d9d9d9;
    border-radius: 8px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
    margin-bottom: 16px;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: #20a53a;
    background: rgba(32, 165, 58, 0.03);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.upload-link {
    color: #20a53a;
    cursor: pointer;
    font-weight: 500;
}

.upload-hint {
    color: #999;
    font-size: 12px;
    margin-top: 8px;
}

/* --- File list --- */
.file-list {
    margin-bottom: 16px;
}

.file-list h4 {
    font-size: 14px;
    color: #555;
    margin-bottom: 8px;
}

.file-list ul {
    list-style: none;
}

.file-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #fafafa;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 13px;
}

.file-list li .file-remove {
    color: #f5222d;
    cursor: pointer;
    border: none;
    background: none;
    font-size: 16px;
}

/* --- Progress bar --- */
.upload-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #20a53a;
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    font-size: 13px;
    color: #666;
    min-width: 36px;
}

/* --- Tabs --- */
.tab-header {
    display: flex;
    border-bottom: 1px solid #f0f0f0;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #20a53a;
}

.tab-btn.active {
    color: #20a53a;
    border-bottom-color: #20a53a;
    font-weight: 500;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* --- Log output --- */
.log-output {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 16px;
    border-radius: 6px;
    max-height: 480px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* --- Action bar --- */
.action-bar {
    display: flex;
    gap: 12px;
    padding-top: 16px;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: #999;
    font-size: 14px;
}

/* --- Text utilities --- */
.text-success {
    color: #20a53a;
}
.text-danger {
    color: #f5222d;
}
.text-warning {
    color: #fa8c16;
}

/* --- Flash messages --- */
.flash-container {
    padding: 12px 24px 0;
}

.flash {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 14px;
    animation: flashIn 0.3s ease;
}

.flash-success {
    background: #e6f7ee;
    color: #20a53a;
    border: 1px solid #b7eb8f;
}

.flash-danger {
    background: #fff1f0;
    color: #f5222d;
    border: 1px solid #ffa39e;
}

.flash-warning {
    background: #fff7e6;
    color: #fa8c16;
    border: 1px solid #ffd591;
}

.flash-info {
    background: #e6f7ff;
    color: #1890ff;
    border: 1px solid #91d5ff;
}

.flash-close {
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
}

.flash-close:hover {
    opacity: 1;
}

@keyframes flashIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    border: none;
    background: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* --- Cert detail modal --- */
.cert-detail-info {
    background: #e6f7ee;
    border: 1px solid #b7eb8f;
    border-radius: 6px;
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    font-size: 14px;
    color: #333;
}

.cert-info-tag b {
    color: #20a53a;
    margin: 0 2px;
}

.cert-detail-content {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.cert-detail-col {
    flex: 1;
    min-width: 0;
}

.cert-detail-col h4 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.cert-textarea {
    width: 100%;
    height: 280px;
    padding: 12px;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    background: #fafafa;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #333;
    resize: vertical;
    word-break: break-all;
}

.cert-textarea:focus {
    outline: none;
    border-color: #20a53a;
}

@media (max-width: 768px) {
    .cert-detail-content {
        flex-direction: column;
    }
}

/* --- Login page --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #001529 0%, #003a5c 100%);
}

.login-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 8px;
    padding: 40px 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 24px;
    color: #333;
    margin-bottom: 4px;
}

.login-header p {
    color: #999;
    font-size: 13px;
}

/* --- Sidebar overlay (mobile) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

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

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .search-input {
        width: 100%;
    }

    .topbar {
        padding: 0 16px;
    }

    .content {
        padding: 16px;
    }

    .panel-body {
        padding: 16px;
    }

    .checkbox-label {
        padding-top: 0;
    }
}

@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
}
