/* =========================================================================
   REUSABLE UI COMPONENTS LIBRARY
   Focus: Soft shadows, rounded corners, pastel colors, emotionally safe feel.
   ========================================================================= */

/* 1. BUTTONS (Extended) */
.btn {
    /* Inherits heavily from styles.css */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-8);
}
.btn-lg {
    padding: var(--space-16) var(--space-48);
    font-size: var(--text-lg);
}
.btn-icon {
    padding: var(--space-12);
    border-radius: var(--radius-full);
    width: 48px;
    height: 48px;
}
.btn-ghost {
    background-color: transparent;
    color: var(--text-muted);
    box-shadow: none;
}
.btn-ghost:hover {
    background-color: var(--bg-surface-hover);
    color: var(--color-primary);
    transform: none; /* No lift */
}

/* 2. CARDS (Extended) */
.card-interactive {
    cursor: pointer;
    border: 2px solid transparent;
}
.card-interactive:hover, .card-interactive:focus-within {
    border-color: var(--color-tertiary); /* Soft primary tint border */
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.card-header {
    border-bottom: 2px solid var(--bg-surface-hover);
    padding-bottom: var(--space-16);
    margin-bottom: var(--space-16);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-footer {
    border-top: 2px solid var(--bg-surface-hover);
    padding-top: var(--space-16);
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
    gap: var(--space-12);
}

/* 3. INPUT FIELDS & FORMS */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    margin-bottom: var(--space-24);
}
.form-label {
    font-weight: var(--font-weight-semibold);
    color: var(--text-main);
    font-size: var(--text-sm);
}
.input-field {
    width: 100%;
    border: 2px solid var(--bg-surface-hover);
    border-radius: var(--radius-sm);
    padding: var(--space-16);
    font-family: var(--font-family-sans);
    font-size: var(--text-base);
    color: var(--text-main);
    background-color: var(--bg-page);
    transition: all var(--transition-normal);
}
.input-field:focus {
    outline: none;
    border-color: var(--color-secondary);
    background-color: var(--bg-surface);
    box-shadow: 0 0 0 4px rgba(205, 180, 219, 0.2);
}
.input-field::placeholder { color: var(--text-muted); }

/* Validation States */
.input-field.is-invalid {
    border-color: #ffd6d6;
    background-color: #fffafb;
}
.input-field.is-valid {
    border-color: var(--color-accent);
}

/* 4. SLIDERS (Range Inputs) */
.slider-container {
    display: flex;
    align-items: center;
    gap: var(--space-16);
    width: 100%;
}
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--bg-surface-hover);
    outline: none;
    transition: background var(--transition-normal);
}
.slider:hover {
    background: rgba(162, 210, 255, 0.3); /* Soft pastel blue tint */
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    border: 3px solid var(--bg-surface);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-md);
}
.slider::-moz-range-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    border: 3px solid var(--bg-surface);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.slider::-moz-range-thumb:hover {
    transform: scale(1.15);
    box-shadow: var(--shadow-md);
}

/* 5. MODALS & OVERLAYS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(73, 80, 87, 0.2); /* Very soft backdrop */
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.modal-content {
    position: relative;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-48);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.95);
    transition: transform var(--transition-normal);
}
.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}
/* Safe Entry Overlay Layout */
.entry-content {
    background: var(--bg-surface);
    padding: var(--space-48);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    text-align: center;
    max-width: 500px;
    width: 90%;
    transform: translateY(20px);
    transition: all var(--transition-normal);
}

.safe-entry-overlay.active .entry-content {
    transform: translateY(0);
}

/* =========================================================================
   CALMING LOADING STATES
   ========================================================================= */
.loading-breathe {
    /* Uses the accent lavender gently to tint */
    background: linear-gradient(90deg,
        rgba(205, 180, 219, 0.1) 0%,
        rgba(205, 180, 219, 0.4) 50%,
        rgba(205, 180, 219, 0.1) 100%
    );
    background-size: 200% 100%;
    /* 4-second soft wave over a frantic 0.8s spin */
    animation: calmingWave 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}

.loading-breathe * {
    visibility: hidden;
}

@keyframes calmingWave {
    0% { background-position: 100% 0; opacity: 0.5; }
    50% { background-position: -100% 0; opacity: 1; }
    100% { background-position: 100% 0; opacity: 0.5; }
}

/* =========================================================================
   SOFT TOAST NOTIFICATION
   ========================================================================= */
.toast-notification {
    position: fixed;
    bottom: calc(var(--space-64) + var(--space-48)); /* Above mobile nav */
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-surface);
    color: var(--text-main);
    padding: var(--space-12) var(--space-24);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    font-weight: var(--font-weight-semibold);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: var(--space-8);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
    z-index: 1000;
}

.toast-notification.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 768px) {
    .toast-notification {
        bottom: var(--space-32);
        left: calc(var(--space-64) * 4); /* Offset sidebar gently */
    }
}
.modal-close {
    position: absolute;
    top: var(--space-16);
    right: var(--space-16);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-xl);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal-close:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}

/* 6. NAVIGATION TABS / PILLS */
.nav-pills {
    display: inline-flex;
    gap: var(--space-8);
    background: var(--bg-surface-hover);
    padding: var(--space-8);
    border-radius: var(--radius-full);
    overflow-x: auto;
}
.nav-pill {
    padding: var(--space-8) var(--space-24);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-weight: var(--font-weight-semibold);
    text-decoration: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.nav-pill:hover {
    color: var(--text-main);
}
.nav-pill.active {
    background: var(--bg-surface);
    color: var(--color-secondary); /* Lavender accent */
    box-shadow: var(--shadow-sm);
}

/* 7. BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-4) var(--space-12);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-bold);
}
.badge-primary {
    background-color: var(--color-primary);
    color: var(--text-main);
}
.badge-accent {
    background-color: var(--color-accent);
    color: #3b6b50;
}

/* 8. SAFE ENTRY OVERLAY */
.safe-entry-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-page);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease, transform 0.8s ease;
}
.safe-entry-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.safe-entry-overlay.fade-out {
    opacity: 0;
    transform: scale(1.05); /* Slight soft zoom out as it disappears */
    pointer-events: none;
}
.safe-entry-overlay .entry-content {
    text-align: center;
    padding: var(--space-32);
    max-width: 600px;
}
