/*
Theme Name: CoP Hub Theme
Theme URI: https://aphrc.org
Author: Gideon Kiprotich
Author URI: https://aphrc.org
Description: A purpose-built theme for the Community of Practice Hub plugin. Features a sticky navigation bar with notification bell, user dropdown, search, and CoP page links. Clean, modern design aligned with the #75b83d brand palette.
Version: 2.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: cop-hub-theme
*/

/* ========================================================================
   CSS VARIABLES
   ======================================================================== */
:root {
    --copt-primary: #75b83d;
    --copt-primary-dark: #5a9a2b;
    --copt-primary-light: #a8d47a;
    --copt-accent: #e8f5d8;
    --copt-bg: #f5f7fa;
    --copt-bg-card: #ffffff;
    --copt-text: #1e293b;
    --copt-text-light: #64748b;
    --copt-text-muted: #94a3b8;
    --copt-border: #e2e8f0;
    --copt-border-light: #f1f5f9;
    --copt-shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --copt-shadow-md: 0 4px 12px rgba(0,0,0,.06);
    --copt-shadow-lg: 0 8px 24px rgba(0,0,0,.08);
    --copt-nav-height: 64px;
    --copt-sidebar-width: 300px;
    --copt-radius: 8px;
    --copt-radius-lg: 12px;
    --copt-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --copt-font-display: 'Sora', 'DM Sans', sans-serif;
    --copt-transition: .2s ease;
}

/* ========================================================================
   RESET & BASE
   ======================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--copt-font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--copt-text);
    background: var(--copt-bg);
    padding-top: var(--copt-nav-height);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
html { overflow-x: hidden; }
a { color: var(--copt-primary-dark); text-decoration: none; transition: color var(--copt-transition); }
a:hover { color: var(--copt-primary); }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { font-family: var(--copt-font-display); font-weight: 700; line-height: 1.3; }

/* ========================================================================
   TOP NAVIGATION BAR
   ======================================================================== */
.copt-navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    height: var(--copt-nav-height);
    background: var(--copt-bg-card);
    border-bottom: 1px solid var(--copt-border);
    box-shadow: var(--copt-shadow-sm);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    gap: 8px;
}

/* WP Admin bar offset */
.admin-bar .copt-navbar { top: 32px; }
.admin-bar body { padding-top: calc(var(--copt-nav-height) + 32px); }

/* Logo area */
.copt-nav-brand {
    display: flex; align-items: center; gap: 6px;
    text-decoration: none; flex-shrink: 0;
}
.copt-nav-brand img {
    height: 44px; width: auto; object-fit: contain;
}
.copt-nav-brand-text {
    font-family: var(--copt-font-display);
    font-size: 17px; font-weight: 800;
    color: var(--copt-text);
    white-space: nowrap;
}
.copt-nav-brand:hover .copt-nav-brand-text { color: var(--copt-primary); }

/* Nav links (CoP pages) — centered between logo and right controls */
.copt-nav-links {
    display: flex; align-items: center; gap: 2px;
    justify-content: center;
    flex: 1;
}
.copt-nav-link {
    padding: 7px 14px;
    font-size: 15px; font-weight: 600;
    color: var(--copt-text-light);
    border-radius: var(--copt-radius);
    transition: all var(--copt-transition);
    white-space: nowrap;
    text-decoration: none;
}
.copt-nav-link:hover { color: var(--copt-text); background: var(--copt-border-light); }
.copt-nav-link.active { color: var(--copt-primary-dark); background: var(--copt-accent); }

/* Nav search */
.copt-nav-search {
    position: relative; flex-shrink: 0;
}
.copt-nav-search input {
    width: 200px; padding: 7px 12px 7px 34px;
    border: 1px solid var(--copt-border); border-radius: 20px;
    font-size: 13px; font-family: var(--copt-font);
    background: var(--copt-bg); color: var(--copt-text);
    transition: all var(--copt-transition); outline: none;
}
.copt-nav-search input:focus {
    width: 260px; border-color: var(--copt-primary);
    box-shadow: 0 0 0 3px rgba(123,193,72,.15);
}
.copt-nav-search-icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    font-size: 14px; color: var(--copt-text-muted); pointer-events: none;
}

/* Nav right: notif bell + user */
.copt-nav-right {
    display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}

/* Notification bell in nav */
.copt-nav-notif {
    position: relative; width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; cursor: pointer;
    transition: background var(--copt-transition);
    border: none; background: transparent; font-size: 18px;
}
.copt-nav-notif:hover { background: var(--copt-border-light); }
.copt-nav-notif-badge {
    position: absolute; top: 2px; right: 2px;
    background: #ef4444; color: #fff;
    font-size: 10px; font-weight: 800;
    min-width: 16px; height: 16px;
    border-radius: 8px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--copt-bg-card);
    line-height: 1;
}

/* User dropdown in nav */
.copt-nav-user {
    position: relative; display: flex; align-items: center;
    gap: 8px; cursor: pointer; padding: 4px 10px 4px 4px;
    border-radius: 24px; transition: background var(--copt-transition);
    border: none; background: transparent;
    font-family: var(--copt-font);
}
.copt-nav-user:hover { background: var(--copt-border-light); }
.copt-nav-user-avatar {
    width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--copt-border);
}
.copt-nav-user-name {
    font-size: 13px; font-weight: 600; color: var(--copt-text);
    max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copt-nav-user-arrow {
    font-size: 10px; color: var(--copt-text-muted);
    transition: transform var(--copt-transition);
}
.copt-nav-user.open .copt-nav-user-arrow { transform: rotate(180deg); }

/* User dropdown menu */
.copt-user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 220px; background: var(--copt-bg-card);
    border: 1px solid var(--copt-border); border-radius: var(--copt-radius-lg);
    box-shadow: var(--copt-shadow-lg); overflow: hidden;
    display: none; z-index: 100;
}
.copt-user-dropdown.open { display: block; }
.copt-user-dropdown-header {
    padding: 14px 16px; border-bottom: 1px solid var(--copt-border-light);
    display: flex; align-items: center; gap: 10px;
}
.copt-user-dropdown-header img { width: 40px; height: 40px; border-radius: 50%; }
.copt-user-dropdown-header-info { min-width: 0; }
.copt-user-dropdown-header-name { font-size: 14px; font-weight: 700; color: var(--copt-text); }
.copt-user-dropdown-header-email { font-size: 11px; color: var(--copt-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copt-user-dropdown a {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; font-size: 13px; font-weight: 500;
    color: var(--copt-text-light); transition: all var(--copt-transition);
    text-decoration: none;
}
.copt-user-dropdown a:hover { background: var(--copt-bg); color: var(--copt-text); }
.copt-user-dropdown a.copt-logout { color: #ef4444; border-top: 1px solid var(--copt-border-light); }
.copt-user-dropdown a.copt-logout:hover { background: #fef2f2; }

/* Mobile menu toggle */
.copt-nav-toggle {
    display: none; width: 38px; height: 38px;
    align-items: center; justify-content: center;
    border: none; background: transparent; font-size: 22px;
    cursor: pointer; border-radius: 50%;
    transition: background var(--copt-transition);
}
.copt-nav-toggle:hover { background: var(--copt-border-light); }

/* ========================================================================
   LAYOUT: CONTENT + SIDEBAR
   ======================================================================== */
.copt-layout {
    max-width: 1360px; margin: 0 auto;
    padding: 24px 40px 48px;
    display: grid;
    grid-template-columns: 1fr var(--copt-sidebar-width);
    gap: 28px;
    min-height: calc(100vh - var(--copt-nav-height) - 60px);
}
.copt-content { min-width: 0; }

/* Sidebar */
.copt-sidebar {
    display: flex; flex-direction: column; gap: 20px;
}
.copt-sidebar-widget {
    background: var(--copt-bg-card);
    border: 1px solid var(--copt-border-light);
    border-radius: var(--copt-radius-lg);
    padding: 20px;
    box-shadow: var(--copt-shadow-sm);
}
.copt-sidebar-widget-title {
    font-family: var(--copt-font-display);
    font-size: 14px; font-weight: 700;
    color: var(--copt-text); margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--copt-accent);
}

/* Full-width pages (no sidebar) */
.copt-layout-full {
    max-width: 1360px; margin: 0 auto;
    padding: 24px 40px 48px;
}

/* ========================================================================
   FOOTER
   ======================================================================== */
.copt-footer {
    background: var(--copt-bg-card);
    border-top: 1px solid var(--copt-border);
    padding: 24px;
    text-align: center;
    font-size: 13px; color: var(--copt-text-muted);
}
.copt-footer a { color: var(--copt-primary-dark); }
.copt-footer a:hover { text-decoration: underline; }

/* ========================================================================
   WIDGET: ACTIVE MEMBERS
   ======================================================================== */
.copt-active-member {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 0; font-size: 13px;
}
.copt-active-member img { width: 32px; height: 32px; border-radius: 50%; }
.copt-active-member-name { font-weight: 600; color: var(--copt-text); }
.copt-active-member-meta { font-size: 11px; color: var(--copt-text-muted); }

/* ========================================================================
   WIDGET: GROUPS LIST
   ======================================================================== */
.copt-sidebar-group {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 0; text-decoration: none;
}
.copt-sidebar-group img { width: 32px; height: 32px; border-radius: 50%; }
.copt-sidebar-group-name { font-size: 13px; font-weight: 600; color: var(--copt-text); }
.copt-sidebar-group-count { font-size: 11px; color: var(--copt-text-muted); }

/* ========================================================================
   RESPONSIVE
   ======================================================================== */
@media (max-width: 1024px) {
    .copt-layout { grid-template-columns: 1fr; }
    .copt-sidebar { display: none; }
    :root { --copt-sidebar-width: 0px; }
}

@media (max-width: 768px) {
    :root { --copt-nav-height: 56px; }
    .copt-navbar { padding: 0 14px; gap: 8px; }
    .copt-nav-links { display: none; }
    .copt-nav-links.open {
        display: flex; flex-direction: column;
        position: fixed; top: var(--copt-nav-height); left: 0; right: 0;
        background: var(--copt-bg-card);
        border-bottom: 1px solid var(--copt-border);
        box-shadow: var(--copt-shadow-lg);
        padding: 8px; gap: 2px; z-index: 999;
    }
    .admin-bar .copt-nav-links.open { top: calc(var(--copt-nav-height) + 32px); }
    .copt-nav-link { padding: 12px 16px; border-radius: var(--copt-radius); font-size: 14px; }
    .copt-nav-toggle { display: flex; }
    .copt-nav-search { display: none; }
    .copt-nav-user-name { display: none; }
    .copt-layout, .copt-layout-full { padding: 16px 14px 32px; }
    .copt-nav-brand-text { font-size: 15px; }
}

@media (max-width: 480px) {
    .copt-navbar { padding: 0 10px; }
    .copt-nav-brand-text { display: none; }
    .copt-layout, .copt-layout-full { padding: 12px 10px 24px; }
}

/* Admin bar responsive override */
@media (max-width: 782px) {
    .admin-bar .copt-navbar { top: 46px; }
    .admin-bar body { padding-top: calc(var(--copt-nav-height) + 46px); }
}
