/**
 * CAPCUS CMS - EDITOR STYLES
 * Professional Webflow-style inline editor
 */

/* ============================================
   GLOBAL EDIT MODE
   ============================================ */
body.edit-mode {
    cursor: default !important;
}

body.preview-mode [data-editable] {
    pointer-events: none !important;
    outline: none !important;
}

body.preview-mode .capcus-image-controls {
    display: none !important;
}

/* ============================================
   TOOLBAR
   ============================================ */
.capcus-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-bottom: 2px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.capcus-toolbar-left,
.capcus-toolbar-center,
.capcus-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.capcus-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 16px;
    color: white;
    padding-right: 20px;
    border-right: 2px solid rgba(255, 255, 255, 0.1);
}

.capcus-logo i {
    color: #3b82f6;
    font-size: 20px;
}

.capcus-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    font-size: 13px;
}

.capcus-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.capcus-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.capcus-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.capcus-btn:active {
    transform: translateY(0);
}

.capcus-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.capcus-btn:disabled:hover {
    transform: none;
}

.capcus-btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-color: transparent;
}

.capcus-btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.capcus-btn-primary.has-changes {
    animation: savePulse 1.5s infinite;
}

@keyframes savePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    }
}

.capcus-btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.capcus-btn-danger:hover {
    background: #ef4444;
    color: white;
}

.capcus-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
}

/* ============================================
   EDITABLE ELEMENTS - TEXT
   ============================================ */
body.edit-mode [data-editable="text"] {
    position: relative;
    outline: 2px dashed transparent;
    outline-offset: 4px;
    transition: all 0.2s ease;
    cursor: text !important;
    border-radius: 4px;
    min-height: 20px;
}

body.edit-mode [data-editable="text"]:hover {
    outline-color: rgba(59, 130, 246, 0.6) !important;
    background: rgba(59, 130, 246, 0.05) !important;
    z-index: 99998 !important;
}

body.edit-mode [data-editable="text"]:focus {
    outline-color: #3b82f6 !important;
    outline-style: solid !important;
    outline-width: 3px !important;
    background: rgba(59, 130, 246, 0.08) !important;
    z-index: 99998 !important;
}

body.edit-mode [data-editable="text"].capcus-editing {
    outline-color: #3b82f6 !important;
    outline-style: solid !important;
    z-index: 99998 !important;
}

/* Icon indicator on hover */
body.edit-mode [data-editable="text"]:hover::before {
    content: '✏️';
    position: absolute;
    top: -12px;
    left: -12px;
    width: 24px;
    height: 24px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.6);
    z-index: 99999 !important;
    animation: popIn 0.2s ease;
    pointer-events: none;
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   EDITABLE ELEMENTS - IMAGES
   ============================================ */
.capcus-image-wrapper {
    position: relative;
    display: inline-block;
    transition: all 0.3s ease;
    z-index: 100000 !important;
    pointer-events: auto !important;
}

body.edit-mode .capcus-image-wrapper {
    cursor: pointer;
    z-index: 100000 !important;
}

body.edit-mode .capcus-image-wrapper:hover {
    outline: 3px dashed rgba(59, 130, 246, 0.7) !important;
    outline-offset: 4px;
    z-index: 99998 !important;
}

/* Placeholder para imagen eliminada */
.capcus-image-deleted {
    display: none !important;
}

.capcus-image-deleted-wrapper {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(100, 116, 139, 0.2) 0%, rgba(71, 85, 105, 0.2) 100%);
    border: 2px dashed rgba(100, 116, 139, 0.5);
    border-radius: 12px;
    min-width: 200px;
    min-height: 150px;
    position: relative;
}

.capcus-image-deleted-wrapper::before {
    content: '📷 Imagen eliminada\AHaz clic para agregar nueva';
    white-space: pre;
    text-align: center;
    color: rgba(100, 116, 139, 0.7);
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
}
}

body.edit-mode .capcus-image-wrapper:hover {
    outline: 3px dashed rgba(59, 130, 246, 0.7) !important;
    outline-offset: 4px;
    z-index: 100001 !important;
}

body.edit-mode .capcus-image-controls {
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 100001 !important;
}

.capcus-image-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    opacity: 1 !important;
    transition: opacity 0.2s ease;
    z-index: 100001 !important;
    pointer-events: auto !important;
}

.capcus-image-wrapper:hover .capcus-image-controls {
    opacity: 1;
}

.capcus-image-btn {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
}

.capcus-image-btn:hover {
    background: #3b82f6;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.6);
}

.capcus-image-btn[data-action="delete"]:hover {
    background: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.6);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.capcus-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 999998;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    max-width: 400px;
}

.capcus-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.capcus-notification-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.capcus-notification-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.capcus-notification-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.capcus-notification-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/* ============================================
   BODY PADDING (so content is not hidden by toolbar)
   ============================================ */
body.edit-mode {
    padding-top: 64px !important;
}

/* ============================================
   EDITABLE BACKGROUNDS
   ============================================ */
body.edit-mode [data-editable="background"] {
    position: relative !important;
}

body.edit-mode [data-editable="background"]:hover {
    outline: 3px dashed rgba(251, 191, 36, 0.7) !important;
    outline-offset: 4px;
}

.capcus-bg-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.9;
    transition: opacity 0.2s ease;
    z-index: 99999 !important;
    pointer-events: auto;
}

body.edit-mode [data-editable="background"]:hover .capcus-bg-controls {
    opacity: 1;
    pointer-events: auto;
}

.capcus-bg-label {
    background: rgba(251, 191, 36, 0.95);
    color: #000;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.capcus-bg-btn {
    width: 44px;
    height: 44px;
    background: rgba(251, 191, 36, 0.95);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 18px;
    font-weight: bold;
}

.capcus-bg-btn:hover {
    background: rgba(251, 191, 36, 1);
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.6);
}

/* ============================================
   EDITABLE VIDEO (HERO)
   ============================================ */
body.edit-mode [data-editable="video"] {
    position: relative !important;
}

.capcus-video-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 16px;
    opacity: 1;
    transition: all 0.3s ease;
    z-index: 99999 !important;
    pointer-events: none;
}

body.edit-mode [data-editable="video"]:hover .capcus-video-overlay {
    background: rgba(0, 0, 0, 0.3);
}

.capcus-video-btn-small {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.6);
    pointer-events: auto;
    opacity: 0.9;
}

body.edit-mode [data-editable="video"]:hover .capcus-video-btn-small {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(239, 68, 68, 0.8);
}

.capcus-video-btn-small:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 32px rgba(239, 68, 68, 1);
}

.capcus-video-btn-small:active {
    transform: scale(1.05) translateY(0);
}

.capcus-video-btn-small i {
    font-size: 16px;
}

/* Legacy video controls (removing) */
body.edit-mode [data-editable="video"]:hover {
    outline: none !important;
}

.capcus-video-controls {
    display: none !important;
}

.capcus-video-label,
.capcus-video-btn {
    display: none !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .capcus-toolbar {
        padding: 0 12px;
        height: auto;
        flex-wrap: wrap;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .capcus-toolbar-left,
    .capcus-toolbar-center,
    .capcus-toolbar-right {
        gap: 6px;
    }

    .capcus-logo span,
    .capcus-status {
        display: none;
    }

    .capcus-btn span {
        display: none;
    }

    .capcus-btn {
        padding: 10px 12px;
    }

    .capcus-divider {
        display: none;
    }

    body.edit-mode {
        padding-top: 56px !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
body.edit-mode .no-edit,
body.edit-mode [data-no-edit] {
    pointer-events: none !important;
    user-select: none !important;
}

/* Hide scrollbar for horizontal tab scroll */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .capcus-toolbar,
    .capcus-image-controls,
    .capcus-notification {
        display: none !important;
    }

    body.edit-mode {
        padding-top: 0 !important;
    }

    [data-editable] {
        outline: none !important;
    }
}