/* ============================================
   Common Styles Library
   共享样式库 - 所有页面通用的样式定义
   ============================================ */

/* CSS Variables - 全局变量 */
:root {
    /* Colors */
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --success-dark: #059669;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;

    /* Background Colors */
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --panel-bg: #f8fafc;

    /* Text Colors */
    --text-color: #333;
    --text-dark: #1e293b;
    --text-medium: #475569;
    --text-light: #64748b;
    --text-muted: #94a3b8;

    /* Border Colors */
    --border-color: #e5e7eb;
    --border-light: #f1f5f9;
    --border-medium: #cbd5e1;
    --border-dark: #e2e8f0;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 15px;
    --radius-xl: 20px;
}

/* Global Reset - 全局重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

/* Layout Utilities - 布局工具 */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

.panel {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    height: fit-content;
}

/* Header Component - 通用头部 */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 25px 30px;
    border-radius: var(--radius-lg);
    margin-bottom: 25px;
    box-shadow: var(--shadow-md);
}

.header h1 {
    margin: 0 0 5px 0;
    font-size: 1.8em;
    font-weight: 600;
}

.subtitle {
    margin: 5px 0 0;
    opacity: 0.9;
    font-size: 0.95em;
}

/* Section Titles - 章节标题 */
h2 {
    margin-top: 0;
    color: var(--text-dark);
    font-size: 1.2em;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.section-title {
    font-weight: 600;
    color: var(--text-medium);
    margin-bottom: 15px;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Card Component - 通用卡片 */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.card-body {
    padding: 15px 0;
}

.card-footer {
    padding-top: 15px;
    border-top: 1px solid var(--border-light);
}

/* Button Components - 按钮组件 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1em;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(102, 126, 234, 0.3);
}

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

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

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--success-dark) 100%);
    color: white;
}

.btn-secondary {
    background: var(--text-muted);
    color: white;
}

.btn-link {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: transform 0.2s;
}

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

/* Input Components - 输入框组件 */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-size: 0.85em;
    color: var(--text-light);
    font-weight: 500;
}

.input,
.input-group input,
.input-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: 0.95em;
    background: white;
    width: 100%;
    min-width: 0;
    transition: border-color 0.2s;
}

.input:focus,
.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--info-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Modal Component - 通用 Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    width: 90%;
    max-width: 800px;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.3s ease;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #334155;
    font-size: 1.25em;
}

.close-modal {
    color: var(--text-muted);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-light);
}

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

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Alert Components - 提示框 */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.95em;
}

.alert-info {
    background-color: #dbeafe;
    border-left: 4px solid var(--info-color);
    color: #1e40af;
}

.alert-warning {
    background-color: #fef3c7;
    border-left: 4px solid var(--warning-color);
    color: #92400e;
}

.alert-success {
    background-color: #d1fae5;
    border-left: 4px solid var(--success-color);
    color: #065f46;
}

.alert-danger {
    background-color: #fee2e2;
    border-left: 4px solid var(--danger-color);
    color: #991b1b;
}

/* Loading & Spinner - 加载动画 */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

/* Utility Classes - 工具类 */

/* Text Colors */
.text-primary {
    color: var(--primary-color);
}

.text-secondary {
    color: var(--secondary-color);
}

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.text-muted {
    color: var(--text-muted);
}

.text-dark {
    color: var(--text-dark);
}

/* Spacing Utilities */
.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

/* Animations - 动画库 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}
/* ============ Mobile Responsive (Common) ============ */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .header {
        padding: 20px;
        margin-bottom: 20px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .panel {
        padding: 20px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        max-height: 85vh;
    }

    .modal-header, 
    .modal-body, 
    .modal-footer {
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 15px;
        border-radius: var(--radius-md);
    }

    .header h1 {
        font-size: 1.3em;
    }

    .btn {
        width: 100%;
        margin-bottom: 8px;
    }
    
    .btn:last-child {
        margin-bottom: 0;
    }

    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin-left: 0;
    }
}
