/* ===========================================
   ADMIN MODE - PREMIUM EDITING EXPERIENCE
   =========================================== */

/* CSS Variables for Admin Theme */
:root {
    --admin-primary: #7C3AED;
    --admin-primary-dark: #6D28D9;
    --admin-primary-light: #A78BFA;
    --admin-success: #10B981;
    --admin-danger: #EF4444;
    --admin-warning: #F59E0B;
    --admin-bg-overlay: rgba(0, 0, 0, 0.5);
    --admin-shadow: 0 10px 40px rgba(124, 58, 237, 0.3);
    --admin-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================================
   FLOATING ADMIN BUTTON
   =========================================== */

.admin-floating-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    padding: 12px 20px;
    border: none;
    border-radius: 50px;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--admin-transition);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.admin-floating-btn.locked {
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    color: white;
}

.admin-floating-btn.locked:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.admin-floating-btn.active {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    animation: admin-pulse 2s infinite;
}

@keyframes admin-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(16, 185, 129, 0.6); }
}

.admin-floating-btn .icon {
    font-size: 16px;
}

/* ===========================================
   ADMIN BANNER (when active)
   =========================================== */

.admin-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: linear-gradient(135deg, #7C3AED 0%, #6D28D9 100%);
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-banner.visible {
    transform: translateY(0);
}

.admin-banner-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.admin-banner-title {
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-banner-actions {
    display: flex;
    gap: 10px;
}

.admin-banner-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--admin-transition);
}

.admin-banner-btn.primary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.admin-banner-btn.primary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.admin-banner-btn.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #FCA5A5;
}

.admin-banner-btn.danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* ===========================================
   LOGIN MODAL
   =========================================== */

.admin-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--admin-bg-overlay);
    backdrop-filter: blur(8px);
    z-index: 10001;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--admin-transition);
}

.admin-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.admin-modal {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--admin-shadow);
    transform: scale(0.9) translateY(20px);
    transition: var(--admin-transition);
}

.admin-modal-overlay.visible .admin-modal {
    transform: scale(1) translateY(0);
}

.admin-modal-header {
    text-align: center;
    margin-bottom: 30px;
}

.admin-modal-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.admin-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #1F2937;
    margin-bottom: 8px;
}

.admin-modal-subtitle {
    color: #6B7280;
    font-size: 14px;
}

.admin-input-group {
    margin-bottom: 20px;
}

.admin-input-wrapper {
    position: relative;
}

.admin-input {
    width: 100%;
    padding: 14px 50px 14px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    font-size: 16px;
    transition: var(--admin-transition);
    box-sizing: border-box;
}

.admin-input:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.admin-input.error {
    border-color: var(--admin-danger);
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.admin-toggle-password {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: #9CA3AF;
    transition: var(--admin-transition);
}

.admin-toggle-password:hover {
    color: #6B7280;
}

.admin-error-message {
    color: var(--admin-danger);
    font-size: 13px;
    margin-top: 8px;
    display: none;
}

.admin-error-message.visible {
    display: block;
}

.admin-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--admin-transition);
}

.admin-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4);
}

.admin-submit-btn:active {
    transform: translateY(0);
}

.admin-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    color: #9CA3AF;
    cursor: pointer;
    transition: var(--admin-transition);
}

.admin-modal-close:hover {
    color: #6B7280;
}

/* Success animation */
.admin-success-check {
    display: none;
    text-align: center;
    padding: 30px;
}

.admin-success-check.visible {
    display: block;
    animation: successPop 0.5s ease-out;
}

@keyframes successPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.admin-success-icon {
    font-size: 64px;
    color: var(--admin-success);
}

.admin-success-text {
    font-size: 18px;
    font-weight: 600;
    color: #1F2937;
    margin-top: 15px;
}

/* ===========================================
   EDITABLE CONTENT STYLES
   =========================================== */

/* When admin mode is active */
body.admin-active [data-editable] {
    position: relative;
    transition: var(--admin-transition);
    cursor: text;
}

body.admin-active [data-editable]:hover {
    background: rgba(124, 58, 237, 0.08);
    border-radius: 4px;
    outline: 2px dashed rgba(124, 58, 237, 0.3);
}

body.admin-active [data-editable]:hover::after {
    content: '✏️';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 14px;
    background: var(--admin-primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Currently editing */
body.admin-active [data-editable].editing {
    background: rgba(124, 58, 237, 0.1);
    outline: 2px solid var(--admin-primary);
    padding: 8px;
    border-radius: 6px;
}

body.admin-active [data-editable].editing:hover::after {
    display: none;
}

/* Edit action buttons */
.admin-edit-actions {
    display: none;
    position: absolute;
    bottom: -40px;
    right: 0;
    gap: 8px;
    z-index: 100;
}

.admin-edit-actions.visible {
    display: flex;
}

.admin-edit-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: var(--admin-transition);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.admin-edit-btn.save {
    background: var(--admin-success);
    color: white;
}

.admin-edit-btn.save:hover {
    background: #059669;
    transform: translateY(-1px);
}

.admin-edit-btn.cancel {
    background: #F3F4F6;
    color: #6B7280;
}

.admin-edit-btn.cancel:hover {
    background: #E5E7EB;
}

/* ===========================================
   HISTORY PANEL
   =========================================== */

.admin-history-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    z-index: 10002;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.admin-history-panel.visible {
    transform: translateX(0);
}

.admin-history-header {
    padding: 20px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-history-title {
    font-size: 18px;
    font-weight: 700;
    color: #1F2937;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-history-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #9CA3AF;
    cursor: pointer;
}

.admin-history-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.admin-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #9CA3AF;
}

.admin-history-item {
    background: #F9FAFB;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    border-left: 4px solid var(--admin-primary);
    transition: var(--admin-transition);
}

.admin-history-item:hover {
    background: #F3F4F6;
}

.admin-history-time {
    font-size: 12px;
    color: #9CA3AF;
    margin-bottom: 8px;
}

.admin-history-action {
    font-size: 14px;
    color: #374151;
    margin-bottom: 10px;
}

.admin-history-diff {
    font-size: 13px;
    padding: 10px;
    border-radius: 8px;
    background: white;
}

.admin-history-old {
    color: var(--admin-danger);
    text-decoration: line-through;
    margin-bottom: 5px;
}

.admin-history-new {
    color: var(--admin-success);
}

.admin-history-undo {
    margin-top: 10px;
    padding: 6px 12px;
    background: rgba(124, 58, 237, 0.1);
    color: var(--admin-primary);
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--admin-transition);
}

.admin-history-undo:hover {
    background: rgba(124, 58, 237, 0.2);
}

/* Revert All Button */
.admin-revert-all {
    margin: 20px;
    padding: 12px;
    background: linear-gradient(135deg, var(--admin-danger) 0%, #DC2626 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--admin-transition);
}

.admin-revert-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

/* ===========================================
   FIND & REPLACE PANEL
   =========================================== */

.admin-find-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    z-index: 10002;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.admin-find-panel.visible {
    transform: translateX(0);
}

.admin-find-header {
    padding: 20px;
    border-bottom: 1px solid #E5E7EB;
}

.admin-find-title {
    font-size: 18px;
    font-weight: 700;
    color: #1F2937;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-find-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-find-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #E5E7EB;
    border-radius: 10px;
    font-size: 14px;
    transition: var(--admin-transition);
    box-sizing: border-box;
}

.admin-find-input:focus {
    outline: none;
    border-color: var(--admin-primary);
}

.admin-find-btn {
    padding: 12px;
    background: linear-gradient(135deg, var(--admin-primary) 0%, var(--admin-primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--admin-transition);
}

.admin-find-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4);
}

.admin-find-results {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.admin-find-count {
    font-size: 14px;
    color: #6B7280;
    margin-bottom: 15px;
    padding: 10px;
    background: #F3F4F6;
    border-radius: 8px;
}

.admin-find-match {
    background: #FFFBEB;
    border: 1px solid #FCD34D;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 12px;
}

.admin-find-match-location {
    font-size: 12px;
    color: #92400E;
    margin-bottom: 8px;
    font-weight: 600;
}

.admin-find-match-text {
    font-size: 14px;
    color: #374151;
}

.admin-find-match-text mark {
    background: #FDE047;
    padding: 2px 4px;
    border-radius: 3px;
}

.admin-find-replace-all {
    margin: 20px;
    padding: 12px;
    background: linear-gradient(135deg, var(--admin-success) 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--admin-transition);
}

.admin-find-replace-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

/* ===========================================
   TOAST NOTIFICATIONS
   =========================================== */

.admin-toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10003;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-toast {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: toastSlideIn 0.3s ease-out;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.admin-toast.success {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.admin-toast.error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.admin-toast.info {
    background: #EEF2FF;
    color: #3730A3;
    border: 1px solid #C7D2FE;
}

/* ===========================================
   BODY OFFSET WHEN ADMIN BANNER VISIBLE
   =========================================== */

body.admin-active {
    padding-top: 50px;
}

body.admin-active .sidebar {
    top: 50px;
    height: calc(100vh - 50px);
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */

@media (max-width: 768px) {
    .admin-floating-btn {
        padding: 10px 14px;
        font-size: 12px;
    }

    .admin-floating-btn span:not(.icon) {
        display: none;
    }

    .admin-banner {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .admin-banner-actions {
        flex-wrap: wrap;
        justify-content: center;
    }

    .admin-modal {
        padding: 25px;
        margin: 15px;
    }

    .admin-history-panel,
    .admin-find-panel {
        width: 100%;
    }
}
