/* css/calendar.css - Premium 90-Day Strategy Grid Styles - v1.1 */

/* Cabecera controlada por sa-report-header en ui.css/analytics.css */

/* Controles integrados en sa-report-header */

.sa-btn-tab {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.sa-btn-tab:hover {
    color: #ffffff;
}

.sa-btn-tab--active {
    background: linear-gradient(135deg, #8b5cf6, #06b6d4);
    color: #ffffff;
    font-weight: 500;
}

.sa-calendar-actions {
    display: flex;
    gap: 12px;
}

.sa-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    padding: 2px;
    margin-top: 24px;
}

.sa-calendar-day {
    min-height: 120px;
    background: #121421;
    border: 1px solid #1f2235;
    border-radius: 12px;
    padding: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sa-calendar-day:hover {
    border-color: #8b5cf6;
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(139, 92, 246, 0.15);
}

.sa-calendar-day.has-strategy {
    border-left: 4px solid #06b6d4;
}

.sa-day-number {
    font-size: 0.75rem;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

.sa-post-pill {
    font-size: 0.8rem;
    color: #ffffff;
    background: #1f2235;
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.sa-day-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
    min-height: 20px;
}

.sa-day-pulse {
    display: flex;
    gap: 4px;
}

.sa-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.sa-pulse-dot.is-linkedin {
    background: #a855f7;
    /* Lila */
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

.sa-pulse-dot.is-x {
    background: #06b6d4;
    /* Cian */
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.6);
}

.sa-platform-badge {
    font-size: 0.65rem;
    color: #06b6d4;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* Modal Enhancements */
.sa-glass-modal {
    backdrop-filter: blur(12px);
    background: rgba(18, 20, 33, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.sa-modal-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

.sa-pill-mini {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sa-text-dimmed {
    color: #94a3b8;
    font-size: 0.8rem;
}

.sa-post-preview-box {
    background: #0a0b14;
    border: 1px solid #1f2235;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    min-height: 200px;
    color: #e2e8f0;
    line-height: 1.6;
    white-space: pre-wrap;
    font-size: 0.95rem;
}

.sa-editor-textarea {
    width: 100%;
    min-height: 300px;
    margin-bottom: 20px;
}

.sa-ai-progress-container {
    width: 100%;
    max-width: 1200px;
}

.sa-ai-progress-bar-bg {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-bottom: 10px;
}

.sa-ai-progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #8b5cf6, #06b6d4);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.sa-ai-status-text {
    font-size: 0.75rem;
    color: #94a3b8;
    font-style: italic;
    margin: 0;
    text-align: left;
    letter-spacing: 0.5px;
}

.sa-loading-container {
    padding: 60px 20px;
    text-align: center;
}

.sa-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(139, 92, 246, 0.1);
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: sa-spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes sa-spin {
    to {
        transform: rotate(360deg);
    }
}

.sa-loading-text {
    color: #ffffff;
    font-weight: 500;
    margin-bottom: 8px;
}

.sa-loading-subtext {
    color: #94a3b8;
    font-size: 0.85rem;
}

/* Empty State */
.sa-calendar-empty-state {
    grid-column: 1 / -1;
    padding: 100px 20px;
    text-align: center;
    background: #121421;
    border: 2px dashed #1f2235;
    border-radius: 20px;
}

.sa-empty-icon {
    font-size: 3rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Active Periods Rendering - Silicon Valley Style */
.sa-calendar-day.is-today {
    border: 2px solid #a855f7 !important;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
    position: relative;
    z-index: 2;
    opacity: 1 !important;
    filter: none !important;
    pointer-events: auto !important;
}

.sa-calendar-day.is-today::after {
    content: 'TODAY';
    position: absolute;
    top: -10px;
    right: 10px;
    background: #a855f7;
    color: white;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
}

.sa-calendar-day.is-active {
    background: rgba(147, 51, 234, 0.08);
    border: 1px solid rgba(147, 51, 234, 0.25);
}

.sa-calendar-day.is-active .sa-day-number {
    color: #c084fc;
    font-weight: 700;
}

/* Historic / Past Days - Dimmed & Non-interactive */
.sa-calendar-day.is-past {
    opacity: 0.4;
    filter: grayscale(1);
    cursor: default !important;
    pointer-events: none;
    border-left-width: 1px !important;
    /* Reset strategy border highlight */
    border-color: #1f2235 !important;
    background: #0d0f1a;
}

.sa-calendar-day.is-past:hover {
    transform: none !important;
    box-shadow: none !important;
    border-color: #1f2235 !important;
}

.sa-calendar-day.is-past .sa-post-pill {
    background: #1a1c2e;
    color: #64748b;
}

.sa-calendar-day.is-past .sa-platform-badge {
    color: #475569;
}

.sa-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.75rem;
    color: #94a3b8;
}

.sa-day-name {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sa-view-day {
    grid-template-columns: repeat(7, 1fr);
}

.sa-view-week {
    grid-template-columns: repeat(7, 1fr);
    font-size: 0.85rem;
}

.sa-view-month {
    grid-template-columns: repeat(7, 1fr);
    font-size: 0.75rem;
}

.sa-calendar-grid.sa-view-month .sa-calendar-day {
    padding: 10px;
    min-height: 100px;
}

/* Multi-layer System Styles */
.sa-daily-modal {
    max-width: 500px !important;
}

.sa-editor-modal {
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    /* Use slightly more space */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Important: allow children to handle overflow */
}

/* Scroll area for preview and editor */
.sa-post-preview-box,
.sa-editor-textarea {
    max-height: 55vh !important;
    /* Context-aware height limit */
    overflow-y: auto !important;
    white-space: pre-wrap;
    /* Preserve line breaks */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sa-post-preview-box::-webkit-scrollbar,
.sa-editor-textarea::-webkit-scrollbar {
    width: 6px;
}

.sa-post-preview-box::-webkit-scrollbar-thumb,
.sa-editor-textarea::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.sa-daily-list {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sa-daily-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sa-daily-item:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
}

.sa-item-time {
    font-family: 'Courier New', monospace;
    color: #a855f7;
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 80px;
    padding: 4px 8px;
    background: rgba(168, 85, 247, 0.1);
    border-radius: 4px;
    text-align: center;
}

.sa-item-info {
    flex: 1;
}

.sa-item-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: #fff;
    margin-bottom: 2px;
}

.sa-item-platform {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 700;
}

/* Wave Loader (3 dots) */
.sa-wave-loader {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 20px;
}

.sa-wave-loader span {
    width: 10px;
    height: 10px;
    background: #a855f7;
    border-radius: 50%;
    animation: sa-wave 1.4s infinite ease-in-out both;
}

.sa-wave-loader span:nth-child(1) {
    animation-delay: -0.32s;
}

.sa-wave-loader span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes sa-wave {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1.0);
    }
}

.sa-wave-loader--inline {
    display: inline-flex;
    gap: 3px;
    vertical-align: middle;
    margin-left: 4px;
}

.sa-wave-loader--inline span {
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    animation: sa-wave 1.4s infinite ease-in-out both;
}

.sa-wave-loader--inline span:nth-child(1) {
    animation-delay: -0.32s;
}

.sa-wave-loader--inline span:nth-child(2) {
    animation-delay: -0.16s;
}

.sa-editor-textarea {
    width: 100%;
    min-height: 250px;
    background: #0a0b14;
    border: 1px solid #1f2235;
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    margin-bottom: 20px;
    box-sizing: border-box;
}

/* Modal Close Button Refinement */
.sa-close-modal {
    display: none !important;
    /* Hidden in desktop */
}

@media (max-width: 900px) {
    #sa-view-calendar .sa-report-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 20px 16px;
        gap: 20px;
    }

    #sa-view-calendar .sa-header-content {
        margin-bottom: 5px;
    }

    #sa-view-calendar .sa-pill-selector {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    #sa-view-calendar .sa-calendar-actions {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    #sa-view-calendar .sa-btn-primary {
        width: 100%;
        justify-content: center;
        padding: 12px;
    }

    #sa-view-calendar .sa-calendar-actions .sa-btn-tab-action {
        width: 100%;
        justify-content: center;
        padding: 10px;
    }

    #sa-view-calendar .sa-modal-footer {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: stretch !important;
    }

    #sa-view-calendar .sa-modal-footer .sa-footer-left,
    #sa-view-calendar .sa-modal-footer .sa-footer-right {
        display: flex;
        flex-direction: row;
        gap: 10px;
        width: 100%;
    }

    #sa-view-calendar .sa-modal-footer .sa-footer-right {
        flex-direction: column;
    }

    #sa-view-calendar .sa-modal-footer .sa-btn {
        flex: 1;
        justify-content: center;
        padding: 10px;
    }

    #sa-view-calendar .sa-modal-footer #btn-publish-action {
        width: 100%;
        padding: 14px;
        font-size: 1rem;
    }

    .sa-close-modal {
        display: flex !important;
        position: absolute;
        top: 15px;
        right: 15px;
        background: transparent !important;
        border: none !important;
        color: rgba(255, 255, 255, 0.4) !important;
        font-size: 28px !important;
        cursor: pointer;
        z-index: 100;
        width: 32px;
        height: 32px;
        align-items: center;
        justify-content: center;
        box-shadow: none !important;
    }

    .sa-close-modal:hover {
        color: rgba(255, 255, 255, 0.8) !important;
    }
}

@media (max-width: 1024px) {
    .sa-calendar-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 640px) {
    .sa-calendar-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sa-calendar-day {
        min-height: 100px;
    }
}

/* --- Fase 7: Add Post & IA Refinements --- */
.sa-add-btn-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 20px;
}

.sa-add-day-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sa-add-day-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: #8b5cf6;
    color: #ffffff;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.sa-glass-modal-alt {
    backdrop-filter: blur(25px) saturate(180%);
    background: rgba(3, 5, 18, 0.75) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 20px !important;
    padding: 30px !important;
    width: 600px !important;
}

.sa-ai-suggestion-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: flex-end;
}

.sa-ai-input-wrapper {
    flex: 1;
}

.sa-ai-label {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 8px;
    display: block;
    font-weight: 600;
}

.sa-ai-val-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 15px;
    color: #ffffff;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sa-btn-retry-ai {
    background: transparent;
    border: none;
    color: #8b5cf6;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sa-btn-retry-ai:hover {
    background: rgba(139, 92, 246, 0.2);
    transform: rotate(180deg);
}

.sa-add-post-textarea {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 25px auto;
    display: block;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    outline: none;
}

.sa-add-post-textarea:focus {
    border-color: #00f2ff !important;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.25);
}

.sa-ai-val-box [contenteditable="true"] {
    outline: none;
    cursor: text;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.2s;
    flex: 1;
}

.sa-ai-val-box [contenteditable="true"]:focus {
    background: rgba(139, 92, 246, 0.1);
    box-shadow: 0 0 5px rgba(139, 92, 246, 0.2);
}

/* Ocultar Cancel en Escritorio */
@media (min-width: 901px) {
    .sa-hide-desktop {
        display: none !important;
    }
}

/* Botón cerrar para el modal nuevo (móvil/alt) */
.sa-close-modal-mobile {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    z-index: 10;
    transition: color 0.2s;
}

.sa-close-modal-mobile:hover {
    color: #ffffff;
}

.sa-modal-footer-alt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.sa-btn-import-alt {
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.sa-btn-import-alt:hover {
    background: rgba(6, 182, 212, 0.2);
    transform: translateY(-2px);
}