/**
 * Header/Footer Styles
 */

/* ============================================
   Header/Footer Layers
   ============================================ */

.header-layer,
.footer-layer {
    position: absolute;
    left: var(--margin-left, 56.69px);
    right: var(--margin-right, 56.69px);
    z-index: 5;
    padding: 4px 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.header-layer {
    top: 0;
    height: var(--margin-top, 75.59px);
}

.footer-layer {
    bottom: 0;
    height: var(--margin-bottom, 75.59px);
}

/* ============================================
   Header/Footer Blocks
   ============================================ */

.hf-block {
    position: relative;
    outline: none;
    min-height: 1.4em;
    line-height: 1.4;
    font-size: 10pt;
    color: var(--text-primary, #333);
    padding: 4px 8px;
    border-radius: 3px;
    transition: background-color 0.15s ease;
}

/* Placeholder when empty */
.hf-block:empty::before {
    content: attr(data-placeholder);
    color: var(--text-tertiary, #bbb);
    font-style: italic;
    pointer-events: none;
}

/* Hover state */
.hf-block:hover {
    background-color: rgba(74, 144, 217, 0.05);
}

/* Focus state */
.hf-block:focus {
    background-color: rgba(74, 144, 217, 0.08);
    box-shadow: inset 0 0 0 1px rgba(74, 144, 217, 0.3);
}

.hf-block p {
    margin: 0;
}

/* ============================================
   Inline Settings Handle (left of block)
   ============================================ */

.hf-block::after {
    content: '';
    position: absolute;
    left: -28px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='12' cy='5' r='1'/%3E%3Ccircle cx='12' cy='12' r='1'/%3E%3Ccircle cx='12' cy='19' r='1'/%3E%3C/svg%3E");
    background-size: 16px 16px;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.15s ease;
    border-radius: 3px;
}

.hf-block:hover::after,
.hf-block:focus::after {
    opacity: 0.6;
}

.hf-block:hover::after:hover {
    opacity: 1;
    background-color: rgba(74, 144, 217, 0.1);
}

/* ============================================
   Header/Footer Settings Popup
   ============================================ */

.hf-settings-popup {
    position: fixed;
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: var(--surface-primary, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 140px;
}

.hf-settings-popup.visible {
    display: flex;
}

.hf-settings-popup button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background: transparent;
    font-size: 12px;
    color: var(--text-primary, #333);
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
}

.hf-settings-popup button:hover {
    background: var(--surface-hover, #f5f5f5);
}

.hf-settings-popup button .icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color, #4a90d9);
    font-weight: 600;
}

.hf-settings-popup .divider {
    height: 1px;
    background: var(--border-color, #e0e0e0);
    margin: 4px 0;
}

/* Checkbox row */
.hf-checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-primary, #333);
    cursor: pointer;
    user-select: none;
}

.hf-checkbox-row:hover {
    background: var(--surface-hover, #f5f5f5);
}

.hf-checkbox-row input[type='checkbox'] {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--accent-color, #4a90d9);
}

/* ============================================
   Dark Theme
   ============================================ */

[data-theme='dark'] .hf-block {
    color: var(--text-primary, #eee);
}

[data-theme='dark'] .hf-block:empty::before {
    color: var(--text-tertiary, #666);
}

[data-theme='dark'] .hf-block:hover {
    background-color: rgba(92, 156, 230, 0.08);
}

[data-theme='dark'] .hf-block:focus {
    background-color: rgba(92, 156, 230, 0.12);
    box-shadow: inset 0 0 0 1px rgba(92, 156, 230, 0.4);
}

[data-theme='dark'] .hf-block::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='12' cy='5' r='1'/%3E%3Ccircle cx='12' cy='12' r='1'/%3E%3Ccircle cx='12' cy='19' r='1'/%3E%3C/svg%3E");
}

[data-theme='dark'] .hf-settings-popup {
    background: var(--surface-primary, #2a2a2a);
    border-color: var(--border-color, #444);
}

[data-theme='dark'] .hf-settings-popup button {
    color: var(--text-primary, #eee);
}

[data-theme='dark'] .hf-settings-popup button:hover {
    background: var(--surface-hover, #3a3a3a);
}

[data-theme='dark'] .hf-checkbox-row {
    color: var(--text-primary, #eee);
}

[data-theme='dark'] .hf-checkbox-row:hover {
    background: var(--surface-hover, #3a3a3a);
}

/* ============================================
   Print styles
   ============================================ */

@media print {
    .hf-block:empty {
        display: none;
    }

    .hf-block::after {
        display: none !important;
    }

    .hf-settings-popup {
        display: none !important;
    }

    .hf-block {
        color: #000 !important;
        background: none !important;
        box-shadow: none !important;
    }
}
