/* ── CSS Variables ── */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Container ── */
.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 120px; }

/* ── Profile Section ── */
.profile-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    display: flex;
    gap: 32px;
    align-items: center;
    margin-bottom: 24px;
}
.profile-photo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-light);
    flex-shrink: 0;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--primary);
}
.profile-photo img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.profile-info h1 { font-size: 28px; margin-bottom: 8px; }
.profile-info .info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 24px;
    margin-top: 12px;
}
.profile-info .info-item { color: var(--text-secondary); font-size: 14px; }
.profile-info .info-item span { color: var(--text); font-weight: 500; }

/* ── Section Headers ── */
.section-title {
    font-size: 20px;
    font-weight: 600;
    margin: 32px 0 16px;
    padding-left: 12px;
    border-left: 4px solid var(--primary);
}

/* ── Summary ── */
.summary-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
    white-space: pre-line;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* ── Skills ── */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.skill-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    border-left: 4px solid var(--primary);
}
.skill-card .skill-category {
    font-weight: 600;
    font-size: 15px;
    color: var(--primary-dark);
    margin-bottom: 8px;
}
.skill-card .skill-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* ── Accordion ── */
.accordion { margin-bottom: 24px; }
.accordion-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
}
.accordion-header {
    padding: 18px 24px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s;
}
.accordion-header:hover { background: #f8fafc; }
.accordion-header .header-info { flex: 1; }
.accordion-header .header-info .time-range {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 4px;
}
.accordion-header .header-info .main-info {
    font-weight: 600;
    font-size: 16px;
}
.accordion-header .header-info .sub-info {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 2px;
}
.accordion-header .chevron {
    width: 24px;
    height: 24px;
    transition: transform 0.3s;
    color: var(--text-light);
    flex-shrink: 0;
    margin-left: 16px;
}
.accordion-item.active .chevron { transform: rotate(180deg); }
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}
.accordion-body {
    padding: 0 24px 20px;
    border-top: 1px solid var(--border);
}
.accordion-body .detail-section { margin-top: 16px; }
.accordion-body .detail-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-dark);
    margin-bottom: 6px;
}
.accordion-body .detail-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-line;
}

/* ── Chat Widget ── */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 0;
    border-radius: 24px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,99,235,0.4);
    z-index: 1000;
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    padding: 0 20px;
    white-space: nowrap;
}
.fab-inner svg { flex-shrink: 0; width: 24px; height: 24px; }
.chat-fab:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(37,99,235,0.5); }
.fab-label { font-size: 15px; font-weight: 600; }
.chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 420px;
    height: 560px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.chat-panel.open { display: flex; }
.chat-header {
    padding: 16px 20px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}
.chat-header button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    line-height: 1;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.message-bubble {
    max-width: 82%;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.message-user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}
.message-assistant {
    align-self: flex-start;
    background: #f1f5f9;
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-input-area input[type="text"] {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.chat-input-area input[type="text"]:focus { border-color: var(--primary); }
.chat-input-area input[type="text"]:disabled::placeholder { font-size: 12px; }
.chat-input-area .btn-send, .chat-input-area .btn-upload {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.chat-input-area .btn-send {
    background: var(--primary);
    color: white;
}
.chat-input-area .btn-send:hover { background: var(--primary-dark); }
.chat-input-area .btn-upload {
    background: var(--bg);
    color: var(--text-secondary);
}
.chat-input-area .btn-upload:hover { background: var(--border); }
.file-preview {
    padding: 4px 16px 8px;
    font-size: 12px;
    color: var(--text-secondary);
    display: none;
    align-items: center;
    gap: 8px;
}
.file-preview.show { display: flex; }
.file-preview .remove-file {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
}
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 10px 16px;
    background: #f1f5f9;
    border-radius: 16px;
    font-size: 14px;
    color: var(--text-light);
}
.typing-indicator.show { display: block; }

/* ── Login Page ── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
    background: white;
    border-radius: 16px;
    padding: 48px 40px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-card h1 { font-size: 28px; margin-bottom: 8px; color: var(--text); }
.login-card p { color: var(--text-secondary); margin-bottom: 32px; }
.login-card input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.2s;
}
.login-card input:focus { border-color: var(--primary); }
.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.login-card .btn-primary:hover { background: var(--primary-dark); }
.login-card .error-msg {
    color: var(--danger);
    font-size: 14px;
    margin-top: 12px;
    display: none;
}

/* ── Admin Layout ── */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 250px;
    background: #1e293b;
    color: white;
    padding: 24px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}
.admin-sidebar .logo {
    padding: 0 24px 24px;
    font-size: 20px;
    font-weight: 700;
    border-bottom: 1px solid #334155;
    margin-bottom: 16px;
}
.admin-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #94a3b8;
    font-size: 14px;
    transition: all 0.2s;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active {
    color: white;
    background: #334155;
}
.admin-sidebar nav a .icon { font-size: 18px; width: 24px; text-align: center; }
.admin-content {
    margin-left: 250px;
    flex: 1;
    padding: 32px;
    background: var(--bg);
    min-height: 100vh;
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}
.admin-header h2 { font-size: 24px; }

/* ── Admin Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    text-align: center;
}
.stat-card .stat-value { font-size: 36px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* ── Admin Forms & Tables ── */
.admin-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card-bg);
    color: var(--text);
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: #f8fafc;
}
.data-table tr:hover { background: #f8fafc; }
.data-table .actions { display: flex; gap: 6px; }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: white;
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Token badge ── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

.nav-badge {
    display: inline-block;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ── Toast ── */
.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    z-index: 9999;
    animation: slideIn 0.3s ease;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Preset Buttons ── */
.preset-buttons { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.preset-buttons .btn { font-size: 13px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .profile-card { flex-direction: column; text-align: center; padding: 24px; }
    .profile-info .info-grid { grid-template-columns: 1fr; }
    .skills-grid { grid-template-columns: 1fr; }
    .chat-panel { width: calc(100vw - 16px); right: 8px; bottom: 80px; height: 70vh; }
    .admin-sidebar { display: none; }
    .admin-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
}
