/* ===== WPG Agent Hub ===== */
:root {
    --navy: #235789;
    --navy-light: #2d6a9e;
    --blue: #235789;
    --blue-light: #3a7ab0;
    --accent: #9C1C1F;
    --wpg-grey: #59656F;
    --green: #2ecc71;
    --green-bg: #e8f8f0;
    --red: #e74c3c;
    --red-bg: #fdf0ef;
    --gray-50: #f8f9fc;
    --gray-100: #f0f2f7;
    --gray-200: #e2e6ee;
    --gray-300: #ccd2de;
    --gray-500: #7a8599;
    --gray-700: #4a5568;
    --gray-900: #1a202c;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(26,39,68,0.08);
    --shadow-md: 0 4px 12px rgba(26,39,68,0.1);
    --shadow-lg: 0 8px 24px rgba(26,39,68,0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== TOP BAR ===== */
.topbar {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--white);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
    color: var(--white);
}

.topbar-brand .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-weight: 800;
    font-size: 0.9rem;
}

.topbar-nav { display: flex; gap: 8px; align-items: center; }

.topbar-nav a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.topbar-nav a:hover, .topbar-nav a.active {
    background: rgba(255,255,255,0.12);
    color: var(--white);
}

/* ===== LAYOUT ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px;
}

.page-header {
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--navy);
}
.page-header p {
    color: var(--gray-500);
    margin-top: 4px;
}

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--gray-200);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--gray-100);
}
.card-header i {
    font-size: 1.4rem;
    color: var(--blue);
}
.card-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--navy);
}
.card-header .badge {
    margin-left: auto;
    background: var(--gray-100);
    color: var(--gray-500);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.card-header .badge.done { background: var(--green-bg); color: var(--green); }

/* ===== WELCOME HERO ===== */
.welcome-hero {
    background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
    color: var(--white);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.welcome-hero::after {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}
.welcome-hero h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.welcome-hero .subtitle {
    opacity: 0.85;
    font-size: 0.95rem;
    margin-bottom: 20px;
}
.progress-bar-wrap {
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
    max-width: 500px;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 20px;
    transition: width 0.6s ease;
    min-width: 2%;
}
.progress-label {
    font-size: 0.85rem;
    margin-top: 8px;
    opacity: 0.9;
}

/* ===== CHECKLIST ===== */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}
.checklist-item:last-child { border-bottom: none; }

.checklist-item .check-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.checklist-item .check-btn:hover { border-color: var(--blue); }
.checklist-item.completed .check-btn {
    background: var(--green);
    border-color: var(--green);
    color: var(--white);
}
.checklist-item.completed .check-label { text-decoration: line-through; color: var(--gray-500); }

.checklist-item .check-label { flex: 1; font-size: 0.95rem; }
.checklist-item .check-owner {
    font-size: 0.75rem;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}
.checklist-item .check-owner.day-one {
    background: #fff3e0;
    color: #e65100;
}
.checklist-item.disabled .check-btn {
    cursor: default;
    opacity: 0.5;
}

/* ===== TRAINING ===== */
.course-block { margin-bottom: 16px; }
.course-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}
.course-header:hover { background: var(--gray-100); }
.course-header i { color: var(--blue); font-size: 1.2rem; }
.course-header .course-name { font-weight: 600; flex: 1; }
.course-header .course-progress {
    font-size: 0.8rem;
    color: var(--gray-500);
}
.course-modules { padding: 0 0 0 44px; display: none; }
.course-modules.open { display: block; }
.module-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}
.module-item:last-child { border-bottom: none; }

/* ===== PROFILE FORM ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
    color: var(--gray-700);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--white);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59,111,182,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-primary {
    background: var(--blue);
    color: var(--white);
}
.btn-primary:hover { background: var(--blue-light); }
.btn-navy {
    background: var(--navy);
    color: var(--white);
}
.btn-navy:hover { background: var(--navy-light); }
.btn-danger {
    background: var(--red);
    color: var(--white);
}
.btn-danger:hover { opacity: 0.9; }
.btn-success {
    background: var(--green);
    color: var(--white);
}
.btn-success:hover { opacity: 0.9; }
.btn-outline {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}
.btn-outline:hover { border-color: var(--gray-300); background: var(--gray-50); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-xs { padding: 4px 8px; font-size: 0.78rem; }

/* ===== WARNINGS ===== */
.warning-list {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.warning-list .warning-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #f57f17;
    margin-bottom: 6px;
}
.warning-list li {
    font-size: 0.88rem;
    color: #795548;
    margin-left: 20px;
}

/* ===== GOAL CARDS ===== */
.goals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}
.goal-card {
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}
.goal-card .goal-metric { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 8px; }
.goal-card .goal-numbers { font-size: 1.6rem; font-weight: 700; color: var(--navy); }
.goal-card .goal-numbers span { font-size: 0.9rem; color: var(--gray-500); font-weight: 400; }
.goal-card .goal-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 6px;
    margin-top: 10px;
    overflow: hidden;
}
.goal-card .goal-bar-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 6px;
    transition: width 0.6s;
}

/* ===== DOCUMENT LIST ===== */
.doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}
.doc-item:last-child { border-bottom: none; }
.doc-item i { color: var(--blue); font-size: 1.3rem; }
.doc-item .doc-info { flex: 1; }
.doc-item .doc-title { font-weight: 600; font-size: 0.95rem; }
.doc-item .doc-desc { font-size: 0.82rem; color: var(--gray-500); }

/* ===== APP LINKS ===== */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.app-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--gray-900);
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}
.app-link:hover {
    border-color: var(--blue);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.app-link i { font-size: 1.4rem; color: var(--blue); }
.app-link .app-name { font-weight: 600; font-size: 0.9rem; }
.app-link .app-desc { font-size: 0.78rem; color: var(--gray-500); }

/* ===== AGENT LIST (admin) ===== */
.agent-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    margin-bottom: 10px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}
.agent-row:hover { box-shadow: var(--shadow-md); border-color: var(--blue); }
.agent-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--blue);
    font-size: 1.1rem;
    flex-shrink: 0;
    overflow: hidden;
}
.agent-avatar img { width: 100%; height: 100%; object-fit: cover; }
.agent-info { flex: 1; }
.agent-name { font-weight: 600; }
.agent-meta { font-size: 0.82rem; color: var(--gray-500); }
.agent-progress-mini {
    width: 120px;
    text-align: right;
}
.agent-progress-mini .pct { font-weight: 700; font-size: 1.1rem; color: var(--navy); }
.agent-progress-mini .bar {
    height: 5px;
    background: var(--gray-200);
    border-radius: 5px;
    margin-top: 4px;
    overflow: hidden;
}
.agent-progress-mini .bar-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 5px;
}

/* ===== FLASH MESSAGES ===== */
.flash {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.flash.success { background: var(--green-bg); color: #1b7a3d; border: 1px solid #a3e4be; }
.flash.error { background: var(--red-bg); color: #c0392b; border: 1px solid #f5c6cb; }

/* ===== MAGIC LINK BOX ===== */
.magic-link-box {
    background: var(--gray-50);
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin: 12px 0;
    word-break: break-all;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--blue);
    cursor: pointer;
    position: relative;
}
.magic-link-box:hover::after {
    content: 'Click to copy';
    position: absolute;
    top: -28px;
    right: 0;
    background: var(--navy);
    color: var(--white);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: inherit;
}

/* ===== HEADSHOT PREVIEW ===== */
.headshot-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gray-200);
    margin-bottom: 10px;
}

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}
th { font-weight: 600; color: var(--gray-500); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== LOGIN ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
}
.login-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-card .brand-mark {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-weight: 800;
    font-size: 1.3rem;
    margin-bottom: 16px;
}
.login-card h1 { font-size: 1.3rem; color: var(--navy); margin-bottom: 4px; }
.login-card .sub { color: var(--gray-500); font-size: 0.9rem; margin-bottom: 24px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .container { padding: 16px 12px; }
    .welcome-hero { padding: 24px 20px; }
    .welcome-hero h1 { font-size: 1.3rem; }
    .form-row { grid-template-columns: 1fr; }
    .goals-grid { grid-template-columns: 1fr 1fr; }
    .app-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
    .topbar-brand span { display: none; }
    .agent-row { flex-wrap: wrap; }
    .agent-progress-mini { width: 100%; text-align: left; margin-top: 8px; }
    .card { padding: 18px 16px; }
}

@media (max-width: 480px) {
    .goals-grid { grid-template-columns: 1fr; }
    .topbar-nav a { padding: 6px 8px; font-size: 0.8rem; }
}

/* ===== UTILITIES ===== */
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mb-2 { margin-bottom: 12px; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.inline-form { display: inline; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }

/* ===== HUB ADDITIONS ===== */
.app-link-primary {
    background: var(--white);
    border-color: var(--blue);
    box-shadow: var(--shadow-sm);
}
.app-link-primary i { color: var(--accent); }

.section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.section-label .badge {
    background: var(--gray-100);
    color: var(--gray-700);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}

.type-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-700);
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: none;
    letter-spacing: 0;
}

.radio-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.radio-option {
    display: block;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 400 !important;
}
.radio-option:has(input:checked) { border-color: var(--blue); background: var(--gray-50); }
.radio-option input { margin-right: 8px; }
.radio-option span { font-weight: 600; color: var(--gray-900); }
.radio-option small { display: block; color: var(--gray-500); font-size: 0.8rem; margin-top: 4px; line-height: 1.4; }

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 10px;
    font-weight: 500 !important;
    cursor: pointer;
}
.checkbox-label input { width: 16px; height: 16px; }

.select-xs {
    padding: 4px 8px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.8rem;
    background: var(--white);
    color: var(--gray-700);
}
.gap-1 { gap: 6px; }

.card-collapsed { padding: 0; overflow: hidden; }
.collapse-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
}
.collapse-toggle:hover { background: var(--gray-50); }
.collapse-toggle i { font-size: 1.3rem; }
.collapse-toggle .arrow { margin-left: auto; color: var(--gray-500); font-size: 0.8rem; }
.collapse-body { display: none; padding: 0 20px 4px; }
.collapse-body.open { display: block; }
.collapse-body .card { box-shadow: none; border: 1px solid var(--gray-200); }

@media (max-width: 640px) {
    .radio-row { grid-template-columns: 1fr; }
}

/* ===== TRAINING LINKS ===== */
.link-chip { color: var(--blue); font-size: 0.85rem; text-decoration: none; word-break: break-all; }
.link-chip:hover { text-decoration: underline; }
.edit-panel { display: none; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 14px 16px; margin: 6px 0 12px; }
.edit-panel.open { display: block; }
.add-module-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.add-module-form input { padding: 6px 12px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 0.9rem; font-family: inherit; }
@media (max-width: 640px) { .add-module-form { grid-template-columns: 1fr; } }

/* ===== USEFUL WEBSITES ===== */
.site-filter { margin-left: auto; padding: 6px 12px; border: 1px solid var(--gray-200); border-radius: 999px; font-size: 0.85rem; font-family: inherit; width: 200px; max-width: 45%; }
.site-filter:focus { outline: none; border-color: var(--blue); }
.site-title-link { color: var(--gray-900); text-decoration: none; }
.site-title-link:hover { color: var(--blue); text-decoration: underline; }

/* ===== WEBSITE CATEGORY EDITING ===== */
.group-heading { display: flex; align-items: center; gap: 8px; }
.group-heading .section-label { margin-bottom: 0; }
.group-heading .btn { margin-left: 4px; }
.new-category-input { margin-top: 8px; display: none; }
.new-category-input.open { display: block; }
