/* TIL (Today I Learned) Save Button Styles - Modern Dark & Sleek */

.til-save-button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;

    padding: 14px 28px !important;
    margin: 20px auto !important;

    background: linear-gradient(135deg, #1e293b 0%, #334155 100%) !important;
    border: 1px solid rgba(148, 163, 184, 0.3) !important;
    border-radius: 16px !important;

    font-size: 15px !important;
    font-weight: 600 !important;
    color: #f1f5f9 !important;
    letter-spacing: 0.3px !important;

    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);

    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;

    /* Initial hidden state for popup animation */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}

/* Shimmer effect on hover */
.til-save-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transition: left 0.5s ease;
}

.til-save-button:hover::before {
    left: 100%;
}

/* Popup entrance animation */
.til-save-button.til-popup {
    animation: tilPopupEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes tilPopupEntrance {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    50% {
        opacity: 1;
        transform: translateY(-8px) scale(1.03);
    }
    70% {
        transform: translateY(2px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.til-save-button:hover {
    background: linear-gradient(135deg, #334155 0%, #475569 100%) !important;
    border-color: rgba(148, 163, 184, 0.5) !important;
    color: #ffffff !important;
    transform: translateY(-3px) scale(1.02) !important;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.2),
        0 8px 24px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
}

.til-save-button:active {
    transform: translateY(-1px) scale(0.98) !important;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}

/* Icon styling */
.til-icon {
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
    position: relative;
    z-index: 1;
}

.til-text {
    font-weight: 600;
    letter-spacing: 0.3px;
    position: relative;
    z-index: 1;
}

/* Saved state - Modern dark green with glow */
.til-save-button.saved {
    background: linear-gradient(135deg, #065f46 0%, #047857 100%) !important;
    border-color: rgba(16, 185, 129, 0.5) !important;
    color: #d1fae5 !important;
    box-shadow:
        0 2px 8px rgba(5, 150, 105, 0.3),
        0 4px 16px rgba(16, 185, 129, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
}

.til-save-button.saved:hover {
    background: linear-gradient(135deg, #047857 0%, #059669 100%) !important;
    border-color: rgba(16, 185, 129, 0.6) !important;
    color: #ecfdf5 !important;
    transform: translateY(-3px) scale(1.02) !important;
    box-shadow:
        0 4px 16px rgba(16, 185, 129, 0.3),
        0 8px 24px rgba(16, 185, 129, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

/* Celebration animation - More dynamic */
@keyframes tilSaveCelebrate {
    0% {
        transform: scale(1) rotate(0deg);
    }
    15% {
        transform: scale(1.15) rotate(-3deg);
    }
    30% {
        transform: scale(0.92) rotate(3deg);
    }
    45% {
        transform: scale(1.08) rotate(-2deg);
    }
    60% {
        transform: scale(0.97) rotate(1deg);
    }
    75% {
        transform: scale(1.03) rotate(0deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

.til-save-button.til-save-celebrate {
    animation: tilSaveCelebrate 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Feedback messages - Modern style */
.til-feedback {
    padding: 12px 20px;
    margin: 12px auto;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    animation: tilFeedbackSlide 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(8px);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

@keyframes tilFeedbackSlide {
    from {
        opacity: 0;
        transform: translateY(-15px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.til-feedback-success {
    background: linear-gradient(135deg, rgba(236, 253, 245, 0.95) 0%, rgba(209, 250, 229, 0.95) 100%);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.til-feedback-error {
    background: linear-gradient(135deg, rgba(254, 242, 242, 0.95) 0%, rgba(254, 226, 226, 0.95) 100%);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.til-feedback-info {
    background: linear-gradient(135deg, rgba(239, 246, 255, 0.95) 0%, rgba(219, 234, 254, 0.95) 100%);
    color: #1e40af;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .til-save-button {
        padding: 10px 16px;
        font-size: 14px;
        width: auto;
        max-width: 280px;
    }

    .til-icon {
        font-size: 18px;
    }

    .til-text {
        font-size: 14px;
    }
}

/* Dark mode support (if you have dark mode) */
@media (prefers-color-scheme: dark) {
    .til-save-button {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        border-color: #475569;
        color: #cbd5e1;
    }

    .til-save-button:hover {
        background: linear-gradient(135deg, #0c4a6e 0%, #075985 100%);
        border-color: #0ea5e9;
        color: #e0f2fe;
    }

    .til-save-button.saved {
        background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
        border-color: #10b981;
        color: #d1fae5;
    }
}

/* Integration with your existing question interface */
#mainContent .til-save-button {
    margin-top: 20px;
    margin-bottom: 10px;
}

/* Positioning relative to submit button */
.question-actions-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.question-actions-container .til-save-button {
    order: 1; /* Show after submit button */
    margin: 0;
}

.question-actions-container #submitAnswerBtn {
    order: 0; /* Submit button first */
}
