/* -----------------------------------------------------------------------------
   App widgets
   -----------------------------------------------------------------------------
   Colour tokens, buttons, cards, tables, alerts, badges and form controls live
   in brand.css and components.css. This file only holds the few app-specific
   widgets that have no Bootstrap equivalent. It loads before Bootstrap, so a
   Bootstrap rule at equal specificity wins over anything here.
*/

:root {
    /* Elevation and overlays */
    --shadow-sm: rgba(0, 0, 0, 0.1);
    --shadow-md: rgba(0, 0, 0, 0.15);
    --shadow-lg: rgba(0, 0, 0, 0.2);
    --shadow-xl: rgba(0, 0, 0, 0.3);
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --overlay-bg-strong: rgba(0, 0, 0, 0.6);

    /* Legacy aliases still read by base.css, assignments.css and a few templates */
    --control-border: var(--fd-input-border);
    --control-focus-ring: var(--fd-focus-ring);

    /* Toggle switches */
    --switch-track-bg: var(--fd-input-border);
    --switch-track-disabled-bg: var(--fd-bg-alt);
    --switch-knob-disabled-bg: var(--fd-text-muted);

    /* Sidebar navigation */
    --sidebar-nav-focus-bg: rgba(255, 255, 255, 0.12);
    --sidebar-nav-active-bg: rgba(255, 255, 255, 0.15);

    /* Theme toggle control (rule lives in darkmode.css but is not theme-scoped) */
    --theme-toggle-hover-bg: rgba(128, 128, 128, 0.12);

    /* Animated dropdown menu */
    --dropdown-button-bg: var(--fd-bg-alt);
    --dropdown-button-hover-bg: var(--fd-border);
    --dropdown-button-active-bg: var(--fd-border);
    --dropdown-button-label-fg: var(--fd-text-muted);
    --dropdown-row-border: var(--fd-border);
    --dropdown-row-hover-bg: var(--fd-bg-alt);
    --dropdown-row-active-bg: var(--fd-bg-alt);
    --dropdown-border-stroke: var(--fd-border);
}

/* -----------------------------------------------------------------------------
   Left sidebar focus and active states
   Primary sidebar layout lives in base.css.
   -----------------------------------------------------------------------------
*/
#sidebarToggle:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 2px;
}

#left-nav .nav-link:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: -2px;
    background-color: var(--sidebar-nav-focus-bg) !important;
}

#left-nav .nav-link.active,
#left-nav .nav-link[aria-current="page"] {
    background-color: var(--sidebar-nav-active-bg) !important;
    border-left: 3px solid var(--fd-primary);
}

#left-nav.collapsed .nav-link.active,
#left-nav.collapsed .nav-link[aria-current="page"] {
    border-left: none;
    border-bottom: 3px solid var(--fd-primary);
}

/* -----------------------------------------------------------------------------
   Responsive helpers
   -----------------------------------------------------------------------------
*/
.responsive-btn {
    width: 100%;
    max-width: 300px;
}

@media (min-width: 768px) {
    .responsive-btn {
        white-space: nowrap;
    }
}

/* Long free text wraps instead of widening its container. */
.transaction-description,
.address-block {
    overflow-wrap: break-word;
    max-width: 100%;
}

/* -----------------------------------------------------------------------------
   Revenue Trends chart tweaks
   ----------------------------------------------------------------------------- */
.revenue-trends-chart {
    position: relative;
    width: 100%;
    min-height: 220px;
}
.revenue-trends-chart canvas {
    width: 100% !important;
    height: 100% !important;
}
@media (max-width: 767px) {
    .revenue-trends-chart {
        min-height: 190px;
    }
}

/* -----------------------------------------------------------------------------
   Animated Dropdown Menu Styles
   ----------------------------------------------------------------------------- */

/* Dropdown button/trigger */
.dropdown-button {
    background: var(--dropdown-button-bg);
    border-radius: 50%;
    cursor: pointer;
    height: 26px;
    width: 26px;
    z-index: 1;
    position: relative;
    display: inline-block;
    border: none;
    transition: background 0.2s ease;
}

.dropdown-button:after {
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--fd-primary);
    content: ' ';
    height: 0;
    left: 8px;
    position: relative;
    top: -8px;
    width: 0;
}

.dropdown-button:hover {
    background: var(--dropdown-button-hover-bg);
}

.dropdown-button:active {
    background: var(--dropdown-button-active-bg);
}

.dropdown-button-label {
    color: var(--dropdown-button-label-fg);
    left: -64px;
    position: relative;
    font-size: 18px;
}

/* Dropdown menu container */
.dropdown-menu-animated {
    border-radius: 8px;
    height: auto;
    min-height: 100px;
    margin-top: 8px;
    position: absolute;
    width: 273px;
    z-index: 1000;
}

.dropdown-menu-animated .dropdown-shadow {
    left: -50px;
    opacity: 0;
    position: absolute;
    top: -46px;
    transition: opacity 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
    pointer-events: none;
}

.dropdown-menu-animated .dropdown-container {
    position: absolute;
    top: 0;
    left: 0;
}

.dropdown-menu-animated .dropdown-border1,
.dropdown-menu-animated .dropdown-border2 {
    fill: var(--fd-bg-surface);
    fill-opacity: 0;
    stroke: var(--fd-text);
    transition: stroke 400ms cubic-bezier(0.4, 0.0, 0.2, 1),
        stroke-dasharray 400ms cubic-bezier(0.4, 0.0, 0.2, 1),
        stroke-dashoffset 400ms cubic-bezier(0.4, 0.0, 0.2, 1),
        fill-opacity 400ms 40ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.dropdown-menu-animated .dropdown-border1 {
    stroke-dasharray: 480 480;
    stroke-dashoffset: -480px;
}

.dropdown-menu-animated .dropdown-border2 {
    stroke-dasharray: 0 480;
    stroke-dashoffset: 0;
}

.dropdown-menu-animated .dropdown-contents {
    left: 20px;
    opacity: 0;
    position: relative;
    top: 48px;
    transition: opacity 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
    width: 234px;
}

.dropdown-menu-animated .dropdown-row {
    align-items: center;
    border-bottom: 1px solid var(--dropdown-row-border);
    cursor: pointer;
    display: flex;
    height: 46px;
    padding: 0 5px;
    user-select: none;
    -moz-user-select: none;
    color: var(--fd-text);
    text-decoration: none;
    background: transparent;
    transition: background 0.2s ease;
}

.dropdown-menu-animated .dropdown-row:last-child {
    border-bottom: none;
}

.dropdown-menu-animated .dropdown-row:hover {
    background: var(--dropdown-row-hover-bg);
    color: var(--fd-link);
}

.dropdown-menu-animated .dropdown-row:active {
    background: var(--dropdown-row-active-bg);
}

/* Expanded state */
.dropdown-expanded .dropdown-shadow {
    opacity: 1;
}

.dropdown-expanded .dropdown-border1 {
    fill-opacity: 1;
    stroke: var(--dropdown-border-stroke);
    stroke-dasharray: 480 480;
    stroke-dashoffset: 0;
}

.dropdown-expanded .dropdown-border2 {
    fill-opacity: 1;
    stroke: var(--dropdown-border-stroke);
    stroke-dasharray: 480 480;
    stroke-dashoffset: 0;
}

.dropdown-expanded .dropdown-contents {
    opacity: 1;
    transition: opacity 400ms 100ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Responsive adjustments for dropdown */
@media (max-width: 576px) {
    .dropdown-menu-animated {
        width: 90vw;
        max-width: 273px;
    }

    .dropdown-menu-animated .dropdown-contents {
        width: calc(100% - 40px);
    }
}

/* -----------------------------------------------------------------------------
   Help Tooltip Icon - Reusable Component
   ----------------------------------------------------------------------------- */
.help-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.25rem;
    color: var(--fd-text-muted);
    cursor: help;
    transition: color 0.2s ease;
}

.help-tooltip-icon:hover {
    color: var(--fd-link);
}

.help-tooltip-icon svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* -----------------------------------------------------------------------------
   URL Link Confirmation Modal
   ----------------------------------------------------------------------------- */
.url-confirmation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.url-confirmation-modal {
    background-color: var(--fd-bg-surface);
    color: var(--fd-text);
    border: 1px solid var(--fd-border);
    border-radius: var(--fd-radius-lg);
    box-shadow: 0 4px 16px var(--shadow-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.url-confirmation-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--fd-text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.url-confirmation-close:hover {
    color: var(--fd-danger-text);
}

.url-confirmation-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--fd-text);
    margin-bottom: 1rem;
}

.url-confirmation-url {
    background-color: var(--fd-bg-alt);
    padding: 0.75rem;
    border-radius: var(--fd-radius-sm);
    word-break: break-all;
    margin-bottom: 1.5rem;
    font-family: monospace;
    font-size: 0.9rem;
}

.url-confirmation-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Notes textarea with clickable URLs */
.notes-display {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    line-height: 1.6;
}

.notes-display .clickable-url {
    color: var(--fd-link);
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s ease;
}

.notes-display .clickable-url:hover {
    color: var(--fd-link-hover);
}

/* -----------------------------------------------------------------------------
   Android WebView Detection - Hide Google/Passkey/MFA options
   These elements are hidden when the page loads in a brand's Android app WebView
   (com.freelancerdashboard, app.bizing)
   ----------------------------------------------------------------------------- */
body.webview-app .webview-hide {
    display: none !important;
}

/* Notification settings grid (client_management/crm_settings.html). The row
   labels are <th scope="row"> so screen readers announce each type with its
   checkbox. Cancel the site-wide th and Bootstrap table backgrounds for those
   cells so the grid sits on the card like the rest of the form. Scoped to the
   grid's id so no other table changes. */
#notification-grid {
    --bs-table-bg: transparent;
    --bs-table-hover-bg: transparent;
    table-layout: auto;
}
#notification-grid thead th {
    text-align: left;
}
#notification-grid thead th.text-center,
#notification-grid thead th:not(:first-child) {
    text-align: center;
    width: 5rem;
}
#notification-grid tbody th {
    background: transparent;
    color: inherit;
    text-transform: none;
    letter-spacing: normal;
    font-size: inherit;
}
#notification-grid tbody tr:hover {
    background-color: transparent;
}
#notification-grid .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
}
/* One divider colour under every cell. The site's th and td rules use two
   different greys, which left the line broken under the checkbox column. */
#notification-grid tbody th,
#notification-grid tbody td {
    vertical-align: middle;
    padding: 0.6rem 0.5rem;
    border-top: 0;
    border-bottom: 1px solid var(--fd-border);
}
