/*
 * DAILY NOTES DOWNLOAD BUTTON - STYLES
 *
 * PURPOSE: Bottom-center button for downloading daily notes (appears at end of page)
 * INTEGRATION: Used in articles.html
 * BACKEND: Connects to GET /api/users/:userId/notes/:date
 * STYLE: Warm terracotta/earthy tone - complements cream background
 */

.download-button-container {
    position: relative;
    margin: 3rem auto 2rem;
    text-align: center;
    display: block;
    width: 100%;
}

.download-button {
    padding: 14px 32px;
    font-size: 1rem;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.4;
    text-align: center;
    letter-spacing: 0.3px;
    position: relative;
    z-index: 1;
    margin: 0 auto;

    /* Warm terracotta gradient - organic notebook feel */
    background: linear-gradient(135deg, #B85C38 0%, #C96D4A 50%, #D4785A 100%);
    color: #FDF8F3; /* Warm cream text */

    /* Warm terracotta shadow */
    box-shadow:
        0 2px 4px rgba(184, 92, 56, 0.2),
        0 4px 12px rgba(184, 92, 56, 0.15);

    /* Smooth transitions */
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        background 0.3s ease;
}

/* Hover state - deeper terracotta */
.download-button:hover {
    transform: translateY(-2px);
    background: linear-gradient(135deg, #A54E2C 0%, #B85C38 50%, #C96D4A 100%);
    box-shadow:
        0 4px 8px rgba(184, 92, 56, 0.25),
        0 8px 24px rgba(184, 92, 56, 0.2);
}

/* Active/pressed state */
.download-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(184, 92, 56, 0.2);
}

/* Focus state for accessibility */
.download-button:focus {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(184, 92, 56, 0.3),
        0 4px 12px rgba(184, 92, 56, 0.15);
}

/* --- Button Text --- */
.button-text {
    font-weight: 600;
    color: #FDF8F3;
    letter-spacing: 0.4px;
}

/* --- ® Symbol - Professional and subtle --- */
.reg-symbol {
    font-weight: 400;
    font-size: 0.6em;
    margin-left: 2px;
    position: relative;
    top: -5px;
    color: rgba(253, 248, 243, 0.75); /* Slightly muted */
    letter-spacing: 0;
}

/* --- Tooltip - Warm terracotta themed --- */
.tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    width: max-content;
    max-width: 220px;
    background: #A54E2C;
    color: #FDF8F3;
    text-align: center;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(184, 92, 56, 0.25);
    border: 1px solid rgba(253, 248, 243, 0.15);
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    white-space: normal;
    z-index: 10;
}

/* Tooltip arrow */
.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #A54E2C transparent transparent transparent;
}

/* Tooltip on hover */
.download-button:hover .tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Mobile: Touch-friendly tooltip */
@media (hover: none) {
    .download-button:active .tooltip {
        visibility: visible;
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* === DARK MODE SUPPORT === */
body.dark-mode .download-button {
    /* Muted terracotta for dark mode - less saturated */
    background: linear-gradient(135deg, #8B5A42 0%, #9D6B52 50%, #A87860 100%);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.25),
        0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .download-button:hover {
    background: linear-gradient(135deg, #9D6B52 0%, #A87860 50%, #B8886E 100%);
    box-shadow:
        0 4px 8px rgba(0, 0, 0, 0.3),
        0 8px 24px rgba(0, 0, 0, 0.35);
}

body.dark-mode .tooltip {
    background: #8B5A42;
    border-color: rgba(253, 248, 243, 0.15);
}

body.dark-mode .tooltip::after {
    border-color: #8B5A42 transparent transparent transparent;
}

/* === LOADING STATE === */
.download-button.loading {
    pointer-events: none;
    opacity: 0.85;
}

.download-button.loading .button-text::after {
    content: '...';
    animation: loadingDots 1.2s infinite;
}

@keyframes loadingDots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* === DOWNLOAD DIALOG STYLES === */
.download-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.download-dialog {
    background: #FDF8F3;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: slideUp 0.3s ease;
}

body.dark-mode .download-dialog {
    background: #2D3748;
    color: #F7FAFC;
}

.dialog-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.dialog-title {
    font-family: 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: #1a202c;
    margin: 0 0 24px 0;
}

body.dark-mode .dialog-title {
    color: #F7FAFC;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 24px;
}

.spinner-ring {
    width: 60px;
    height: 60px;
    border: 4px solid #e2e8f0;
    border-top-color: #B85C38;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

body.dark-mode .spinner-ring {
    border-color: #4A5568;
    border-top-color: #9D6B52;
}

.dialog-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #cbd5e0, transparent);
    margin: 24px 0;
}

body.dark-mode .dialog-divider {
    background: linear-gradient(to right, transparent, #4A5568, transparent);
}

.dialog-details {
    text-align: left;
    margin-bottom: 16px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-family: 'Source Serif 4', serif;
}

.detail-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.detail-text {
    font-size: 14px;
    color: #4a5568;
}

body.dark-mode .detail-text {
    color: #CBD5E0;
}

.dialog-hint {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #718096;
    font-style: italic;
    margin: 16px 0 0 0;
}

body.dark-mode .dialog-hint {
    color: #A0AEC0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
    .download-button-container {
        margin: 2rem auto 1.5rem;
        padding: 0 16px;
    }

    .download-button {
        padding: 12px 24px;
        font-size: 0.95rem;
        width: auto;
        max-width: 280px;
    }

    .tooltip {
        font-size: 11px;
        padding: 6px 10px;
        max-width: 180px;
    }

    .download-dialog {
        padding: 24px;
        max-width: 340px;
    }

    .dialog-title {
        font-size: 18px;
    }

    .detail-text {
        font-size: 13px;
    }
}
