/* Privacy Area Creator Modal */

.privacy-area-creator-root {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    pointer-events: none;
}

.privacy-area-creator-root[aria-hidden="false"] {
    display: flex;
    pointer-events: auto;
}

.privacy-area-creator-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
    cursor: pointer;
}

.privacy-area-creator-shell {
    position: relative;
    margin: auto;
    width: min(90vw, 520px);
    max-height: 90vh;
    background: var(--color-bg-shell);
    border: 1px solid var(--accent);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 22px -4px var(--accent-dim), 0 0 3px 1px var(--color-border-muted) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: pacSlideIn 0.3s ease-out;
}

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

/* Header */
.pac-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.pac-header h2 {
    margin: 0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--accent);
    text-shadow: none;
}

.pac-close-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: var(--radius-sm);
    background: rgba(var(--dark-color-rgb), 0.6);
    border: 1px solid var(--secondary-color);
    color: var(--primary-color);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
    font-size: 18px;
    line-height: 1;
    opacity: .9;
}
.pac-close-btn:hover, .pac-close-btn:focus-visible { background: rgba(var(--dark-color-rgb), 0.8); border-color: var(--primary-color); opacity: 1; transform: translateY(-1px); }

@media (max-width:560px){ .pac-header { padding-right:56px; position:relative; } .pac-close-btn { position:absolute; top:14px; right:14px; } }

/* Main Content */
.pac-main {
    padding: 14px 20px;
    overflow-y: auto;
    flex: 1;
    background: var(--color-bg-shell);
}

.pac-section {
    background: var(--color-bg-panel);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.pac-section:last-child { margin-bottom: 0; }

.pac-section h3 {
    margin: 0 0 6px 0;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.pac-instruction {
    margin: 0 0 16px 0;
    color: #b8b8b8;
    font-size: 0.85rem;
    line-height: 1.35;
}

/* Location Controls */
.pac-location-controls { margin-bottom: 16px; }

.pac-coord-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.pac-coord-row label {
    color: #d6d6d6;
    font-size: 0.85rem;
    min-width: 80px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.pac-coord-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-sm);
    background: var(--color-bg-panel-alt);
    color: var(--color-text-primary);
    font-size: 0.85rem;
    transition: border-color 0.2s ease;
}

.pac-coord-row input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.pac-coord-row input[readonly] {
    background: var(--color-bg-panel);
    color: #8f8f8f;
    cursor: not-allowed;
}

/* Map Controls */
.pac-map-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Buttons */
.pac-btn {
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    letter-spacing: 0.5px;
}

.pac-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pac-btn-primary {
    background: var(--color-cta-warn);
    color: #000;
    border: none;
    font-weight: 700;
}

.pac-btn-primary:hover:not(:disabled) {
    background: #e6c000;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 212, 0, 0.3);
}

.pac-btn-secondary {
    background: none;
    color: #d6d6d6;
    border: 1px solid var(--accent);
}

.pac-btn-secondary:hover:not(:disabled) {
    background: rgba(192, 132, 252, 0.1);
    border-color: var(--accent);
}

.pac-btn-save {
    background: var(--accent);
    color: #fff;
    border: none;
    font-weight: 700;
}

.pac-btn-save:hover:not(:disabled) {
    background: var(--accent-dim);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--accent-dim);
}

.pac-btn-delete {
    background: none;
    color: var(--color-error);
    border: 1px solid var(--color-error);
}

.pac-btn-delete:hover:not(:disabled) {
    background: rgba(255, 96, 96, 0.1);
}

.pac-btn-cancel {
    background: none;
    color: #d6d6d6;
    border: 1px solid var(--accent);
}

.pac-btn-cancel:hover {
    background: rgba(192, 132, 252, 0.1);
    border-color: var(--color-error);
    color: var(--color-error);
}

/* Processing note */
.pac-processing-note {
    margin: 0 20px;
    padding: 10px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
}

/* Footer */
.pac-footer {
    padding: 12px 20px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--color-bg-shell);
}

/* Status Indicators */
.pac-location-set {
    background: var(--accent) !important;
    color: #fff !important;
    font-weight: 700 !important;
}

.pac-location-set:hover:not(:disabled) {
    background: var(--accent-dim) !important;
}

/* Privacy info banner */
.pac-info-banner {
    background: rgba(192, 132, 252, 0.08);
    border: 1px solid rgba(192, 132, 252, 0.25);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Saving state — disables the form while the request is in-flight.
   The close button is intentionally excluded so users can dismiss the modal. */
.privacy-area-creator-shell.pac-saving .pac-main,
.privacy-area-creator-shell.pac-saving .pac-footer {
    opacity: 0.6;
    pointer-events: none;
}

.privacy-area-creator-shell.pac-saving .pac-processing-note {
    opacity: 1;
}

/* Loading State */
.pac-btn.loading {
    position: relative;
    color: transparent;
}

.pac-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: pacSpin 1s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
}

@keyframes pacSpin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Cursor overrides for drawing mode */
.rm-map-cursor-privacy-center,
.rm-map-cursor-privacy-center * {
    cursor: crosshair !important;
}

.rm-map-cursor-privacy-radius,
.rm-map-cursor-privacy-radius * {
    cursor: zoom-in !important;
}

/* Responsive */
@media (max-width: 768px) {
    .privacy-area-creator-shell {
        width: 95vw;
        margin: 20px auto;
        max-height: calc(100vh - 40px);
    }
    .pac-header, .pac-main, .pac-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    .pac-coord-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .pac-coord-row label { min-width: auto; }
    .pac-footer { flex-direction: column-reverse; }
    .pac-footer .pac-btn { width: 100%; }
    .pac-map-controls { flex-direction: column; }
    .pac-map-controls .pac-btn { width: 100%; }
}

.pac-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pac-list-item {
    display: flex;
    align-items: stretch;
    gap: 8px;
    background: var(--color-bg-panel-alt);
    border: 1px solid var(--color-border-muted);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.pac-list-item-edit {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    color: #d6d6d6;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.pac-list-item-edit:hover {
    background: rgba(123, 104, 238, 0.1);
}

.pac-list-item-edit strong {
    font-size: 0.95rem;
    color: #f0f0f0;
}

.pac-list-item-meta {
    font-size: 0.8rem;
    color: #9a9a9a;
}

.pac-list-item-delete {
    background: transparent;
    border: 0;
    border-left: 1px solid var(--color-border-muted);
    color: #d6d6d6;
    padding: 0 14px;
    cursor: pointer;
    font-size: 1.1rem;
}

.pac-list-item-delete:hover {
    background: rgba(220, 80, 80, 0.18);
    color: #ff8080;
}

.pac-list-empty {
    padding: 14px;
    text-align: center;
    color: #9a9a9a;
    font-size: 0.9rem;
    border: 1px dashed var(--color-border-muted);
    border-radius: var(--radius-sm);
}

#pac-new-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}
