/**
 * Ultimate Watermark — Layout Styles
 *
 * Header, content, footer scaffolding shared across every admin page.
 * All colors, radii and shadows pull from the tokens declared in admin.css.
 *
 * @package UltimateWatermark
 * @since   2.0.9
 */

/* =========================================================================
   Page shell
   ========================================================================= */

.ultimate-watermark-layout {
    min-height: calc(100vh - 32px);
    background: var(--uw-bg);
    display: flex;
    flex-direction: column;
    font-family: var(--uw-font-sans);
    color: var(--uw-text);
    /* Symmetric breathing room on the right; WP provides left padding. */
    margin: 20px 20px 0 0;
    padding: 0;
    border-radius: var(--uw-radius-lg);
    overflow: hidden;
    box-shadow: var(--uw-shadow-sm);
}

@media screen and (max-width: 782px) {
    .ultimate-watermark-layout {
        margin: 0 10px 0 0;
        min-height: calc(100vh - 46px);
        border-radius: var(--uw-radius-md);
    }
}

/* =========================================================================
   Header (unified — brand + nav row, optional page-title row)
   ========================================================================= */

.ultimate-watermark-header {
    background: var(--uw-surface);
    border-bottom: 1px solid var(--uw-border);
    box-shadow: var(--uw-shadow-xs);
    position: sticky;
    z-index: var(--uw-z-sticky);
}

@media screen and (max-width: 782px) {
    .ultimate-watermark-header {
        top: 46px;
    }
}

/* Single-row header bar — brand mark, page title, nav, actions */
.header-bar {
    width: 100%;
    padding: 0 var(--uw-space-6);
    display: flex;
    align-items: center;
    gap: var(--uw-space-4);
    min-height: 56px;
}

/* Brand mark — logo + plugin name + version, links to Dashboard */
.header-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
    border-radius: var(--uw-radius-sm);
    transition: opacity 0.15s ease;
    color: inherit;
}

.header-brand:hover,
.header-brand:focus {
    opacity: 0.92;
    text-decoration: none;
    color: inherit;
}

.header-brand:focus-visible {
    outline: none;
    box-shadow: var(--uw-shadow-focus);
}

.brand-logo {
    width: 32px;
    height: 32px;
    background: var(--uw-gradient);
    border-radius: var(--uw-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 10px rgba(var(--uw-primary-rgb), 0.28);
    flex-shrink: 0;
}

.brand-logo svg {
    width: 18px;
    height: 18px;
    display: block;
}

.brand-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    line-height: 1.1;
}

.brand-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--uw-text);
    letter-spacing: -0.005em;
    white-space: nowrap;
}

.brand-version {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    font-weight: 600;
    color: var(--uw-text-faint);
    letter-spacing: 0.02em;
    line-height: 1;
}

.pro-version-badge {
    background: var(--uw-primary);
    color: #fff;
    padding: 1px 7px;
    border-radius: var(--uw-radius-pill);
    font-weight: 700;
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(var(--uw-primary-rgb), 0.25);
}

/* Vertical divider between brand and page title */
.header-divider {
    width: 1px;
    height: 28px;
    background: var(--uw-border);
    flex-shrink: 0;
    margin: 0 var(--uw-space-1);
}

/* Navigation */
.header-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--uw-radius-md);
    text-decoration: none;
    color: var(--uw-text-muted);
    font-weight: 500;
    font-size: var(--uw-font-body-size);
    transition: background-color 0.15s ease, color 0.15s ease;
    line-height: 1;
}

.nav-item:hover,
.nav-item:focus {
    background: var(--uw-primary-soft);
    color: var(--uw-primary);
    text-decoration: none;
}

.nav-item:focus-visible {
    outline: none;
    box-shadow: var(--uw-shadow-focus);
}

.nav-item.active,
.nav-item[aria-current="page"] {
    background: var(--uw-primary-soft);
    color: var(--uw-primary);
    font-weight: 600;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* Page title block — sits inline next to the brand mark in the header bar */
.page-title-block {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.page-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--uw-text);
    line-height: 1.2;
    margin: 0;
    letter-spacing: -0.005em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-subtitle {
    font-size: 11px;
    color: var(--uw-text-subtle);
    line-height: 1.3;
    margin: 1px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Push nav to the right edge of the header bar */
.header-bar > .header-nav { margin-left: auto; }
.header-bar > .page-title-block ~ .header-nav { margin-left: 0; }

/* =========================================================================
   Page toolbar — sits directly below the sticky header.
   Holds primary page actions (selects, refresh button, Save, etc.)
   right-aligned for clean visual rhythm.
   ========================================================================= */

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--uw-space-2);
    padding: var(--uw-space-3) var(--uw-space-6);
    background: var(--uw-surface);
    border-bottom: 1px solid var(--uw-border);
}

.page-toolbar .page-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--uw-space-2);
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Make every direct child of .page-actions match the canonical 38-px button
   height so selects/refresh/save buttons line up flush. */
.page-toolbar .page-actions > .btn,
.page-toolbar .page-actions > .uw-btn,
.page-toolbar .page-actions > button.button,
.page-toolbar .page-actions > a.button,
.page-toolbar .page-actions > select,
.page-toolbar .page-actions > .analytics-select,
.page-toolbar .page-actions > input[type="search"],
.page-toolbar .page-actions > input[type="text"] {
    height: 38px;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 1;
    margin: 0;
    vertical-align: middle;
}

.page-toolbar .page-actions > .analytics-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--uw-space-2);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.page-toolbar .page-actions > .analytics-actions > * {
    height: 38px;
    margin: 0;
}

@media (max-width: 600px) {
    .page-toolbar {
        padding: var(--uw-space-3) var(--uw-space-4);
    }

    .page-toolbar .page-actions,
    .page-toolbar .page-actions > .analytics-actions {
        width: 100%;
        justify-content: stretch;
    }

    .page-toolbar .page-actions > .btn,
    .page-toolbar .page-actions > .uw-btn,
    .page-toolbar .page-actions > .analytics-actions > .btn,
    .page-toolbar .page-actions > .analytics-actions > .uw-btn {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 1024px) {
    .nav-label {
        display: none;
    }

    .nav-item {
        padding: 8px 10px;
    }
}

@media (max-width: 782px) {
    .header-bar {
        padding: var(--uw-space-2) var(--uw-space-4);
        flex-wrap: wrap;
        gap: var(--uw-space-3);
        min-height: 48px;
    }

    .page-title-block {
        flex: 1 1 100%;
        order: 3;
    }

    .header-nav {
        order: 2;
    }

    .page-actions {
        order: 4;
        flex: 1 1 100%;
    }

    .page-actions .btn,
    .page-actions .uw-btn {
        flex: 1;
        justify-content: center;
    }

    .page-title { font-size: 14px; }
    .page-subtitle { display: none; }

    .header-divider { display: none; }
}

/* =========================================================================
   Content
   ========================================================================= */

.ultimate-watermark-content {
    flex: 1;
    width: 100%;
    margin-top: 20px;
    padding: var(--uw-space-6);
}

@media (max-width: 600px) {
    .ultimate-watermark-content {
        margin-top: 16px;
        padding: var(--uw-space-4);
    }
}

/* =========================================================================
   Footer
   ========================================================================= */

.ultimate-watermark-footer {
    background: var(--uw-surface);
    border-top: 1px solid var(--uw-border);
    margin-top: var(--uw-space-6);
}

.footer-container {
    width: 100%;
    margin: 0;
    padding: var(--uw-space-4) var(--uw-space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--uw-space-4);
    flex-wrap: wrap;
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    gap: var(--uw-space-2);
    color: var(--uw-text-muted);
    font-size: 13px;
    font-weight: 500;
}

.footer-brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--uw-primary);
}

.footer-brand-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.footer-brand-text {
    font-weight: 600;
    color: var(--uw-text);
}

.copyright {
    color: var(--uw-text-faint);
    font-size: 12px;
    font-weight: 500;
    margin-left: 6px;
    padding-left: 10px;
    border-left: 1px solid var(--uw-border);
    line-height: 1.4;
}

.footer-links {
    display: inline-flex;
    align-items: center;
    gap: var(--uw-space-1);
    flex-wrap: wrap;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    color: var(--uw-text-subtle);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--uw-radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.footer-link:hover,
.footer-link:focus {
    background: var(--uw-primary-soft);
    color: var(--uw-primary);
    text-decoration: none;
}

.footer-link svg {
    width: 14px;
    height: 14px;
    display: block;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .footer-container {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--uw-space-3);
    }

    .copyright {
        margin-left: 0;
        padding-left: 0;
        border-left: 0;
    }
}
