/* ========================================
   全局样式
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* ========================================
   顶部标题
   ======================================== */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.auth-status {
    font-size: 14px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-weight: 500;
}

.auth-status.logged-in {
    background: rgba(16, 185, 129, 0.3);
}

.auth-status.local-mode {
    background: rgba(59, 130, 246, 0.3);
}

/* ========================================
   登录遮罩层
   ======================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.4s ease-out;
}

.login-box h2 {
    text-align: center;
    color: #667eea;
    font-size: 24px;
    margin-bottom: 10px;
}

.login-tip {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 25px;
}

.login-input {
    width: 100%;
    padding: 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.login-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-actions {
    display: flex;
    gap: 10px;
}

.login-actions .btn {
    flex: 1;
    padding: 12px;
    font-size: 15px;
    border-radius: 8px;
}

.login-error {
    color: #ef4444;
    font-size: 13px;
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background: #fee2e2;
    border-radius: 6px;
}

/* ========================================
   三栏布局：站点管理 | 配置编辑 | 推送日志
   ======================================== */
.main-layout {
    display: grid;
    grid-template-columns: 350px 1fr 350px;
    gap: 20px;
    align-items: start;
}

/* ========================================
   左侧边栏（站点管理）
   ======================================== */
.sidebar {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========================================
   中间内容区（配置编辑）
   ======================================== */
.main-content {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* ========================================
   右侧日志面板
   ======================================== */
.log-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    overflow: hidden;
}

.log-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
    flex-shrink: 0;
}

.log-panel-header h2 {
    font-size: 16px;
    color: #333;
    margin: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f3f4f6;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 16px;
    margin: 0;
    color: #333;
}

.sidebar-header .btn {
    padding: 8px 16px;
    font-size: 14px;
}

.sidebar-actions {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.sidebar-actions .btn {
    border: 1px solid #d1d5db;
}

/* 站点表格 */
.sites-table {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fafbfc;
    min-height: 0;
}

.site-row {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background 0.2s;
}

.site-row:hover {
    background: #f9fafb;
}

.site-row:last-child {
    border-bottom: none;
}

.site-checkbox {
    margin-right: 10px;
    cursor: pointer;
}

.site-info {
    flex: 1;
    min-width: 0;
}

.site-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-domain {
    font-size: 12px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-actions {
    display: flex;
    gap: 5px;
}

.site-actions button {
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid #d1d5db;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.site-actions button:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.site-actions button:first-child {
    background: #10b981;
    color: white;
    border-color: #059669;
}

.site-actions button:first-child:hover {
    background: #059669;
    border-color: #047857;
}

/* 日志区域（紧凑版 - 左侧边栏，已废弃） */
.log-section {
    border-top: 1px solid #e5e7eb;
    padding-top: 15px;
    margin-top: auto;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
}

.btn-text {
    background: none;
    border: none;
    color: #667eea;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

.btn-text:hover {
    text-decoration: underline;
}

.log-area-compact {
    max-height: 120px;
    overflow-y: auto;
    font-size: 12px;
    background: #f9fafb;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.log-area-full {
    flex: 1;
    overflow-y: auto;
    font-size: 12px;
    background: #f9fafb;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    min-height: 0;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #f3f4f6;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.success { color: #059669; }
.log-entry.error { color: #dc2626; }
.log-entry.info { color: #6b7280; }

/* ========================================
   配置编辑区域
   ======================================== */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f3f4f6;
    flex-shrink: 0;
}

.content-header h2 {
    font-size: 20px;
    color: #333;
}

.content-actions {
    display: flex;
    gap: 10px;
}

/* 配置区块（内嵌版） */
.config-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-btn {
    display: none;
    background: #667eea;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-btn:hover {
    background: #5568d3;
}

@media (max-width: 768px) {
    .toggle-btn {
        display: inline-block;
    }
}

.hint {
    display: block;
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 12px;
}

/* 推广码行 */
.promo-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    width: 100%;
}

.promo-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.promo-item label {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 5px;
}

.promo-item input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.promo-item input:focus {
    outline: none;
    border-color: #667eea;
}

/* 域名网格 */
.domain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    width: 100%;
}

.domain-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.domain-item label {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 6px;
}

.domain-item textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.5;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.domain-item textarea:focus {
    outline: none;
    border-color: #667eea;
}

.domain-item textarea::placeholder {
    color: #9ca3af;
    font-size: 12px;
}

/* ========================================
   按钮样式
   ======================================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-info {
    background: #3b82f6;
    color: white;
}

.btn-info:hover {
    background: #2563eb;
}

/* ========================================
   模态框
   ======================================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
    animation: slideDown 0.3s;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    color: #333;
}

.close {
    font-size: 28px;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #333;
    font-size: 14px;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* ========================================
   Toast 通知
   ======================================== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10001;
    animation: fadeInOut 1s;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* ========================================
   自定义确认框
   ======================================== */
.confirm-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;
    opacity: 0;
    transition: opacity 0.2s;
}

.confirm-overlay.show {
    opacity: 1;
}

.confirm-box {
    background: white;
    border-radius: 12px;
    padding: 30px;
    min-width: 360px;
    max-width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.2s;
}

.confirm-overlay.show .confirm-box {
    transform: scale(1);
}

.confirm-message {
    font-size: 16px;
    color: #333;
    margin-bottom: 25px;
    line-height: 1.5;
    text-align: center;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-buttons .btn {
    min-width: 100px;
    padding: 10px 20px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   响应式布局
   ======================================== */
@media (max-width: 1200px) {
    .main-layout {
        grid-template-columns: 320px 1fr;
    }
    
    .domain-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 15px 20px;
    }
    
    header h1 {
        font-size: 20px;
    }
    
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar, .log-panel {
        position: static;
        height: auto;
        margin-bottom: 20px;
    }
    
    /* 站点列表只显示2行 */
    .sites-table {
        max-height: calc(2 * 60px);
        overflow-y: auto;
    }
    
    /* 日志只显示3行 */
    .log-area-full {
        max-height: calc(3 * 30px);
        overflow-y: auto;
    }
    
    /* 推广码区域默认收缩 */
    .promo-section-collapsed .promo-row {
        display: none;
    }
    
    .promo-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .content-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .content-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .promo-row {
        grid-template-columns: 1fr;
    }
    
    .sidebar-actions {
        gap: 5px;
    }
    
    .sidebar-actions .btn {
        flex: 1;
        padding: 6px 8px;
        font-size: 11px;
    }
}
