/* ========================================
   CoreAPI Modal Styles
   ======================================== */

.coreapi-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.coreapi-overlay.visible {
    opacity: 1;
}

.coreapi-modal {
    background: var(--color-surface);
    border-radius: 12px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s ease;
}

.coreapi-overlay.visible .coreapi-modal {
    transform: scale(1) translateY(0);
}

/* Full-screen on mobile */
.coreapi-overlay--fullscreen {
    align-items: stretch;
    padding: 0;
}

.coreapi-modal--fullscreen {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
}

.coreapi-modal--fullscreen .coreapi-form {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.coreapi-modal--fullscreen .coreapi-actions {
    margin-top: auto;
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

/* Modal header */
.coreapi-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.coreapi-modal-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: var(--color-text);
}

.coreapi-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.2s;
}

.coreapi-close:hover {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

/* Form */
.coreapi-form {
    padding: 1.5rem;
}

.coreapi-form .form-group {
    margin-bottom: 1rem;
}

.coreapi-form .form-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.coreapi-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

/* Error/Success messages */
.coreapi-error {
    background: var(--color-error-bg, rgba(239, 68, 68, 0.1));
    color: var(--color-error);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--color-error);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.coreapi-success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #16a34a;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

/* ========================================
   Floating Action Button (FAB)
   For no-header pages
   ======================================== */

.core-fab {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 150;
}

/* Trigger button (avatar) */
.core-fab-trigger {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--color-primary);
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 2;
}

.core-fab-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.core-fab.open .core-fab-trigger {
    background: var(--color-text-muted, #666);
}

.core-fab-avatar {
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    pointer-events: none;
    line-height: 1;
}

/* Menu — stacks upward from trigger */
.core-fab-menu {
    position: absolute;
    bottom: calc(100% + 0.75rem);
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    pointer-events: none;
}

.core-fab.open .core-fab-menu {
    pointer-events: auto;
}

/* Individual FAB items */
.core-fab-item {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    text-decoration: none;
    transition: all 0.2s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
    position: relative;
    opacity: 0;
    transform: scale(0) translateY(20px);
}

.core-fab.open .core-fab-item {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Stagger delays */
.core-fab.open .core-fab-item:nth-last-child(1) {
    transition-delay: 0s;
}

.core-fab.open .core-fab-item:nth-last-child(2) {
    transition-delay: 0.05s;
}

.core-fab.open .core-fab-item:nth-last-child(3) {
    transition-delay: 0.1s;
}

.core-fab.open .core-fab-item:nth-last-child(4) {
    transition-delay: 0.15s;
}

.core-fab-item:hover {
    background: var(--color-primary);
    color: white;
    transform: scale(1.1);
    text-decoration: none;
}

.core-fab-item--danger:hover {
    background: var(--color-error);
    color: white;
}

/* Tooltip labels — appear to the LEFT */
.core-fab-item::after {
    content: attr(data-label);
    position: absolute;
    right: calc(100% + 0.6rem);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--color-border);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.core-fab-item:hover::after {
    opacity: 1;
}

/* Mobile */
@media (max-width: 640px) {
    .core-fab {
        bottom: 1rem;
        right: 1rem;
    }

    .core-fab-trigger {
        width: 48px;
        height: 48px;
    }

    .core-fab-item {
        width: 38px;
        height: 38px;
    }
}