/* ==========================================================
   APPLICATION LAYOUT
========================================================== */

.app {

    display: flex;

    min-height: 100vh;

    background: var(--background);

}

/* ==========================================================
   SIDEBAR
========================================================== */

.sidebar {

    --sidebar-logo-height: 40px;

    /* icon is the full logo's tallest part (ratio 1.0 = 96px / 96px) */
    --sidebar-icon-height: calc(var(--sidebar-logo-height) * 1);

    width: 248px;

    min-width: 248px;

    background: var(--sidebar-bg);

    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);

    border-right: 1px solid var(--hairline);

    display: flex;

    flex-direction: column;

    justify-content: space-between;

    position: sticky;

    top: 0;

    height: 100vh;

    overflow-y: auto;

}

@supports not (backdrop-filter: blur(1px)) {

    .sidebar {

        background: var(--surface);

    }

}

/* ==========================================================
   LOGO
========================================================== */

.logo {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 10px;

    padding: 18px 20px;

    border-bottom: 1px solid var(--border);

}

.logo-icon,
.logo-lockup {

    min-width: 0;

}

/* ==========================================================
   SIDEBAR TOGGLE
========================================================== */

.sidebar-toggle {

    display: flex;

    align-items: center;

    justify-content: center;

    width: 26px;

    height: 26px;

    flex-shrink: 0;

    margin-left: auto;

    border: 1px solid var(--border);

    border-radius: var(--radius-sm);

    background: var(--surface);

    color: var(--text-light);

    cursor: pointer;

    transition: var(--transition);

}

.sidebar-toggle:hover {

    border-color: var(--primary);

    color: var(--primary);

    background: var(--primary-light);

}

.sidebar-toggle .toggle-icon {

    font-style: normal;

    font-size: 15px;

    line-height: 1;

    transition: transform .2s ease;

}

.sidebar.collapsed .sidebar-toggle .toggle-icon {

    transform: rotate(180deg);

}

.logo-lockup,
.logo-icon {

    height: var(--sidebar-logo-height);

    width: auto;

    display: block;

    flex-shrink: 0;

}

.logo-icon {

    display: none;

    height: var(--sidebar-icon-height);

}

/* ==========================================================
   NAVIGATION
========================================================== */

.navigation {

    display: flex;

    flex-direction: column;

    gap: 2px;

    padding: 16px 12px;

    flex: 1;

}

.nav-item {

    display: flex;

    align-items: center;

    gap: 11px;

    padding: 9px 12px;

    border-radius: var(--radius-sm);

    color: var(--text-2);

    font-weight: 500;

    font-size: 13.5px;

    transition: var(--transition);

}

.nav-item:hover {

    background: var(--surface-hover);

    color: var(--text-1);

}

.nav-item.active {

    background: var(--gradient);

    color: #fff;

    font-weight: 600;

    box-shadow: 0 4px 12px rgba(23, 101, 245, .25);

}

/* Nav icons: Phosphor SVGs used as a CSS mask so the colour follows
   currentColor. Regular weight when idle, fill weight when active. */
.nav-icon {

    width: 18px;

    height: 18px;

    flex: none;

    background-color: currentColor;

    color: var(--text-2);

    -webkit-mask-size: contain;
    mask-size: contain;

    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;

    -webkit-mask-position: center;
    mask-position: center;

    transition: var(--transition);

}

.nav-item:hover .nav-icon {

    color: var(--text-1);

}

.nav-item.active .nav-icon {

    color: #fff;

}

.nav-icon-squares-four {

    -webkit-mask-image: url("../../assets/icons/nav/squares-four.svg");
    mask-image: url("../../assets/icons/nav/squares-four.svg");

}

.nav-item.active .nav-icon-squares-four {

    -webkit-mask-image: url("../../assets/icons/nav/squares-four-fill.svg");
    mask-image: url("../../assets/icons/nav/squares-four-fill.svg");

}

.nav-icon-check-square {

    -webkit-mask-image: url("../../assets/icons/nav/check-square.svg");
    mask-image: url("../../assets/icons/nav/check-square.svg");

}

.nav-item.active .nav-icon-check-square {

    -webkit-mask-image: url("../../assets/icons/nav/check-square-fill.svg");
    mask-image: url("../../assets/icons/nav/check-square-fill.svg");

}

.nav-icon-users {

    -webkit-mask-image: url("../../assets/icons/nav/users.svg");
    mask-image: url("../../assets/icons/nav/users.svg");

}

.nav-item.active .nav-icon-users {

    -webkit-mask-image: url("../../assets/icons/nav/users-fill.svg");
    mask-image: url("../../assets/icons/nav/users-fill.svg");

}

.nav-icon-kanban {

    -webkit-mask-image: url("../../assets/icons/nav/kanban.svg");
    mask-image: url("../../assets/icons/nav/kanban.svg");

}

.nav-item.active .nav-icon-kanban {

    -webkit-mask-image: url("../../assets/icons/nav/kanban-fill.svg");
    mask-image: url("../../assets/icons/nav/kanban-fill.svg");

}

.nav-icon-wallet {

    -webkit-mask-image: url("../../assets/icons/nav/wallet.svg");
    mask-image: url("../../assets/icons/nav/wallet.svg");

}

.nav-item.active .nav-icon-wallet {

    -webkit-mask-image: url("../../assets/icons/nav/wallet-fill.svg");
    mask-image: url("../../assets/icons/nav/wallet-fill.svg");

}

.nav-icon-chat-circle {

    -webkit-mask-image: url("../../assets/icons/nav/chat-circle.svg");
    mask-image: url("../../assets/icons/nav/chat-circle.svg");

}

.nav-item.active .nav-icon-chat-circle {

    -webkit-mask-image: url("../../assets/icons/nav/chat-circle-fill.svg");
    mask-image: url("../../assets/icons/nav/chat-circle-fill.svg");

}

.nav-icon-bell {

    -webkit-mask-image: url("../../assets/icons/nav/bell.svg");
    mask-image: url("../../assets/icons/nav/bell.svg");

}

.nav-item.active .nav-icon-bell {

    -webkit-mask-image: url("../../assets/icons/nav/bell-fill.svg");
    mask-image: url("../../assets/icons/nav/bell-fill.svg");

}

.nav-icon-buildings {

    -webkit-mask-image: url("../../assets/icons/nav/buildings.svg");
    mask-image: url("../../assets/icons/nav/buildings.svg");

}

.nav-item.active .nav-icon-buildings {

    -webkit-mask-image: url("../../assets/icons/nav/buildings-fill.svg");
    mask-image: url("../../assets/icons/nav/buildings-fill.svg");

}

.nav-icon-gear {

    -webkit-mask-image: url("../../assets/icons/nav/gear.svg");
    mask-image: url("../../assets/icons/nav/gear.svg");

}

.nav-item.active .nav-icon-gear {

    -webkit-mask-image: url("../../assets/icons/nav/gear-fill.svg");
    mask-image: url("../../assets/icons/nav/gear-fill.svg");

}

/* Real unread/open counts — see initSidebarBadges() in app.js
   (Tasks: open task count; Messages/Notifications: real
   unread counts from their own data). Hidden entirely at 0
   rather than showing an empty "0" pill. */
.nav-item-badge {

    margin-left: auto;

    min-width: 20px;

    height: 20px;

    padding: 0 6px;

    border-radius: 999px;

    background: var(--surface-hover);

    color: var(--text-1);

    font-size: 11px;
    font-weight: 700;

    display: flex;
    align-items: center;
    justify-content: center;

}

.nav-item-badge.alert {

    background: var(--danger);
    color: #fff;

}

/* ==========================================================
   SIDEBAR USER
========================================================== */

.sidebar-user {

    display: flex;

    align-items: center;

    gap: 11px;

    padding: 14px 16px;

    border-top: 1px solid var(--hairline);

    text-decoration: none;

    color: inherit;

    cursor: pointer;

    transition: var(--transition);

}

.sidebar-user:hover {

    background: var(--border-soft);

}

.user-avatar {

    width: 38px;

    height: 38px;

    border-radius: 50%;

    background: var(--primary-light);

    color: var(--primary-dark);

    display: flex;

    align-items: center;

    justify-content: center;

    font-weight: 700;

    font-size: 13.5px;

    flex-shrink: 0;

    overflow: hidden;

}

/* ==========================================================
   THEME TOGGLE (Dark Mode)
   Sits below .sidebar-user on every page (identical markup
   duplicated per page's <body>, same as the rest of the
   sidebar — see PROJECT_MAP.md). Wired up in js/shared/app.js
   (initializeTheme()), which applies `data-theme="dark"` on
   <html> and persists the choice in localStorage.
========================================================== */

.theme-toggle-row {

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 12px 16px;

    font-size: 13px;
    color: var(--text-2);

}

.theme-toggle-row .theme-toggle-label {

    display: flex;
    align-items: center;
    gap: 8px;

}

.theme-toggle {

    position: relative;

    width: 38px;
    height: 21px;

    flex-shrink: 0;

    /* var(--border) alone was too close to the sidebar background
       to read as a switch in light mode — a visible border gives the
       off-state track an edge regardless of theme. */
    border: 1px solid var(--text-faint);
    border-radius: 999px;

    background: var(--border);

    cursor: pointer;

    transition: var(--transition);

}

.theme-toggle::after {

    content: "";

    position: absolute;

    top: 2px;
    left: 2px;

    width: 17px;
    height: 17px;

    border-radius: 50%;

    background: var(--surface);

    box-shadow: 0 1px 2px rgba(16, 24, 40, .25);

    transition: var(--transition);

}

.theme-toggle.on {

    background: var(--primary);
    border-color: var(--primary);

}

.theme-toggle.on::after {

    transform: translateX(17px);

}

/* ==========================================================
   AVATAR IMAGES
   Shared by the sidebar user avatar and the larger profile
   avatar in Settings > Profile whenever a picture (rather
   than initials) is being displayed.
========================================================== */

.user-avatar img,
.avatar-lg img {

    width: 100%;

    height: 100%;

    border-radius: 50%;

    object-fit: cover;

    display: block;

}

.user-info {

    min-width: 0;

}

.user-info h4 {

    /* Explicit rather than relying on the generic h4{color} rule
       cascading through .sidebar-user's `color: inherit` — was
       rendering as the link/visited color in some browsers instead
       of the theme's normal text color. */
    color: var(--text);

    font-size: 13.5px;

    font-weight: 600;

    margin-bottom: 2px;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;

}

.user-info p {

    font-size: 11.5px;

    color: var(--text-light);

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;

}

/* ==========================================================
   COLLAPSED SIDEBAR
   (toggled via #sidebarToggle, js/app.js)
========================================================== */

.sidebar.collapsed {

    width: 80px;

    min-width: 80px;

}

.sidebar.collapsed .logo {

    position: relative;

    justify-content: center;

    padding: 18px 12px;

}

.sidebar.collapsed .logo-lockup,
.sidebar.collapsed .user-info {

    display: none;

}

.sidebar.collapsed .logo-icon {

    display: block;

}


.sidebar.collapsed .sidebar-user {

    justify-content: center;

}

/* Collapsed: same treatment as .sidebar-user above — the "Dark Mode"
   label was left uncollapsed, so it wrapped onto its own line and
   pushed the switch below it in the narrow 80px rail instead of
   sitting beside the icon. */
.sidebar.collapsed .theme-toggle-row {

    justify-content: center;

    padding: 12px 8px;

}

.sidebar.collapsed .theme-toggle-row .theme-toggle-label {

    display: none;

}

/* Collapsed: the toggle button is pulled out of the flex flow and
   overlaid directly on top of the logo icon (same 36px/9px-radius box)
   instead of sitting beside it, so the logo icon is the only thing
   that's centered. It stays invisible/unclickable until the logo is
   hovered, then fades in as a dark overlay with the arrow on top —
   clicking it re-expands the sidebar via the same #sidebarToggle
   handler used when expanded (js/app.js). */
.sidebar.collapsed .sidebar-toggle {

    position: absolute;

    inset: 0;
    margin: auto;

    width: calc(var(--sidebar-icon-height) * 1.22);
    height: var(--sidebar-icon-height);

    border: none;
    border-radius: var(--radius-sm);

    background: rgba(0, 0, 0, .55);
    color: #fff;

    opacity: 0;
    pointer-events: none;

    transition: opacity .15s ease;

}

.sidebar.collapsed .logo:hover .sidebar-toggle {

    opacity: 1;
    pointer-events: auto;

}

.sidebar.collapsed .navigation {

    align-items: center;

    padding: 16px 10px;

}

.sidebar.collapsed .nav-item {

    position: relative;

    justify-content: center;

    width: 44px;

    padding: 10px;

    overflow: hidden;

    white-space: nowrap;

    font-size: 0;

}

/* Collapsed: the count badge no longer fits inline next to the icon
   in a 44px-wide item (it was overlapping the icon), so it's pulled
   out of flow and pinned as a small corner dot on the icon instead —
   same "real unread/open count" data (setNavBadge() in app.js),
   just a more compact presentation when there's no room for a pill. */
.sidebar.collapsed .nav-item-badge {

    position: absolute;

    top: 4px;
    right: 4px;

    margin-left: 0;

    min-width: 16px;
    height: 16px;

    padding: 0 4px;

    font-size: 10px;
    line-height: 16px;

}

/* ==========================================================
   MAIN CONTENT
========================================================== */

.main-content {

    flex: 1;

    display: flex;

    flex-direction: column;

    padding: 28px 32px;


}

/* ==========================================================
   PAGE HEADER
========================================================== */

.page-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 24px;

    margin-bottom: 22px;

}

.page-header h1 {

    font-size: 22px;
    font-weight: 600;

}

.page-header p {

    font-size: 13px;

    margin-top: 3px;

}

.header-actions {

    display: flex;

    align-items: center;

    gap: 10px;

    flex-wrap: wrap;

}

/* ==========================================================
   SPLIT LAYOUT
   (Messages / Settings)
========================================================== */

.split-layout {

    display: grid;

    grid-template-columns: 320px 1fr;

    gap: 20px;

    flex: 1;

}

/* ==========================================================
   SETTINGS PAGE
========================================================== */

.settings-container {

    display: grid;

    grid-template-columns: 230px 1fr;

    gap: 20px;

    flex: 1;

}

.settings-sidebar {

    background: var(--surface);

    border-radius: var(--radius);

    border: none;

    padding: 18px;

    height: fit-content;

    box-shadow: var(--shadow-card);

}

.settings-sidebar h2 {

    margin-bottom: 16px;

    font-size: 15px;

}

.settings-sidebar nav {

    display: flex;

    flex-direction: column;

    gap: 4px;

}

.settings-sidebar nav a {

    padding: 9px 12px;

    border-radius: var(--radius-sm);

    font-size: 13.5px;

    transition: var(--transition);

    color: var(--text-light);

}

.settings-sidebar nav a:hover {

    background: var(--border-soft);

}

.settings-sidebar nav a.active {

    background: var(--primary-light);

    color: var(--primary-dark);

    font-weight: 600;

}

.settings-content {

    background: var(--surface);

    border-radius: var(--radius);

    border: none;

    padding: 24px;

    box-shadow: var(--shadow-card);

}

/* ==========================================================
   MESSAGES PAGE
========================================================== */

.messages-layout {

    display: grid;

    grid-template-columns: 320px 1fr;

    gap: 20px;

    flex: 1;

}

.conversation-panel {

    background: var(--surface);

    border: none;

    border-radius: var(--radius);

    display: flex;

    flex-direction: column;

    overflow: hidden;

    box-shadow: var(--shadow-card);

}

.chat-window {

    background: var(--surface);

    border: none;

    border-radius: var(--radius);

    overflow: hidden;

    box-shadow: var(--shadow-card);

}

/* ==========================================================
   KANBAN LAYOUT
========================================================== */

.kanban-board,
.lead-board {

    display: grid;

    grid-template-columns: repeat(4, 1fr);

    gap: 18px;

}

.kanban-column,
.lead-column {

    background: var(--surface);

    border: none;

    border-radius: var(--radius-lg);

    display: flex;

    flex-direction: column;

    min-height: 600px;

    box-shadow: var(--shadow-card);

}

.kanban-header,
.lead-column-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    padding: 14px 16px;

    border-bottom: 1px solid var(--border);

    font-size: 13.5px;

}

.task-list,
.lead-list {

    flex: 1;

    padding: 14px;

    overflow-y: auto;

}

/* ==========================================================
   CONTENT CONTAINERS
========================================================== */

.content-card {

    background: var(--surface);

    border-radius: var(--radius);

    border: none;

    padding: 20px;

    box-shadow: var(--shadow-card);

}

/* ==========================================================
   RESPONSIVE
========================================================== */

@media (max-width: 1400px) {

    .kanban-board,
    .lead-board {

        grid-template-columns: repeat(2, 1fr);

    }

}

@media (max-width: 1100px) {

    .sidebar {

        width: 84px;

        min-width: 84px;

    }

    .logo {

        padding: 18px 12px;

    }

    .logo-lockup {

        display: none;

    }

    .logo-icon {

        display: block;

    }

    .navigation {

        align-items: center;

    }

    .nav-item {

        justify-content: center;

        padding: 12px;

        overflow: hidden;

        white-space: nowrap;

        font-size: 0;

    }

    .sidebar-user {

        justify-content: center;

        padding: 14px 8px;

    }

    .user-info {

        display: none;

    }

    .settings-container,
    .messages-layout,
    .split-layout {

        grid-template-columns: 1fr;

    }

}

@media (max-width: 768px) {

    .main-content {

        padding: 18px;

    }

    .page-header {

        flex-direction: column;

        align-items: flex-start;

    }

    .kanban-board,
    .lead-board {

        grid-template-columns: 1fr;

    }

}

@media (max-width: 480px) {

    .main-content {

        padding: 14px;

    }

    .logo {

        padding: 14px;

    }

}