/**
 * Agent Access CSS
 * UPDATE56 - Phase 6: Agent button locked/unlocked states
 */

/* Agent Button Base Styles */
[data-agent-type] {
    position: relative; /* Required for absolute positioning of lock icons */
    transition: all 0.3s ease;
}

/* Locked Button State - Same visual style as unlocked, only icon differs */
.agent-button-locked {
    opacity: 1;
    filter: none;
    cursor: pointer;
    pointer-events: all;
}

.agent-button-locked:hover {
    opacity: 1;
    /* Removed transform: scale(1.02) to prevent lock icon jumping */
}

/* Unlocked Button State */
.agent-button-unlocked {
    opacity: 1;
    filter: none;
    cursor: pointer;
}

/* Lock/Unlock Icons - Fixed position on absolute RIGHT edge */
.agent-lock-icon,
.agent-unlock-icon {
    position: absolute;
    right: 0.75rem; /* Fixed distance from right edge */
    top: 50%;
    transform: translateY(-50%); /* Vertically center */
    font-size: 0.9em;
    display: none;
}

/* Fixed gold color for both lock and unlock icons across all themes */
.agent-lock-icon {
    color: #FFD700 !important; /* Fixed gold color for locked */
}

.agent-unlock-icon {
    color: #FFD700 !important; /* Fixed gold color for unlocked */
}

/* Sidebar Agent List - Lock/Unlock Icon Styling */
/* Keep inline (not absolute) to avoid overlapping with favorite icon */
#agentList .agent-lock-icon {
    color: #FFD700 !important; /* Fixed gold color for sidebar locked */
    position: static; /* Override absolute positioning */
    margin-left: 0.5rem; /* Inline spacing after text */
    transform: none; /* Remove vertical centering transform */
    font-size: 0.85em;
}

#agentList .agent-unlock-icon {
    color: #FFD700 !important; /* Fixed gold color for sidebar unlocked */
    position: static; /* Override absolute positioning */
    margin-left: 0.5rem; /* Inline spacing after text */
    transform: none; /* Remove vertical centering transform */
    font-size: 0.85em;
}

/* Quick Action Grid - Lock/Unlock Icon Styling */
.quick-action-btn {
    position: relative; /* Required for absolute positioning of lock icons */
    /* Ensure transform creates stacking context that includes children */
    transform-style: preserve-3d;
}

.quick-action-btn .agent-lock-icon,
.quick-action-btn .agent-unlock-icon {
    color: #FFD700 !important; /* Fixed gold color for quick actions */
    position: absolute;
    right: 0.75rem; /* Fixed distance from right edge */
    top: 50%;
    margin-top: -0.45em; /* Vertically center without transform */
    line-height: 1; /* Consistent line height */
    /* Ensure icon is part of parent's 3D transform context */
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Dropdown Menu Items - Lock/Unlock Icon Styling */
.dropdown-item[data-agent-type] .agent-lock-icon,
.dropdown-item[data-agent-type] .agent-unlock-icon {
    color: #FFD700 !important; /* Fixed gold color for dropdown items */
    margin-left: 0.5rem; /* Changed from margin-right to position on right */
    font-size: 0.9em;
}

/* Sidebar Multi-Query Button - Lock/Unlock Icon Styling */
#multiQueryModeBtn .agent-lock-icon,
#multiQueryModeBtn .agent-unlock-icon {
    color: #FFD700 !important; /* Fixed gold color for sidebar multi-query */
}

/* 
 * Feature Badge and Action Buttons - Locked State
 * No visual difference between locked/unlocked - only icon differs
 * Removed gray/disabled styling to make locked agents look identical to unlocked
 */

/* Agent Purchase Modal */
#agentPurchaseModal .modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

#agentPurchaseModal .modal-header {
    background: var(--card-background);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 16px 16px 0 0;
    padding: 1.5rem;
}

#agentPurchaseModal .modal-body {
    padding: 2rem;
    background: var(--card-background);
}

#agentPurchaseModal .modal-title {
    font-weight: 600;
    color: var(--text-primary);
}

#agentPurchaseModal .fa-lock {
    color: var(--warning-color, #ffc107);
}

/* Purchase Modal Alert - Theme-aware styling for better readability */
#agentPurchaseModal .alert-info {
    background: rgba(13, 110, 253, 0.1);
    border: 1px solid rgba(13, 110, 253, 0.3);
    border-radius: 12px;
    color: var(--bs-body-color);
}

#agentPurchaseModal .alert-info .fa-info-circle {
    color: #0d6efd;
}

#agentPurchaseModal .alert-info strong {
    color: var(--bs-body-color);
    font-weight: 600;
}

/* Purchase Modal Buttons */
#agentPurchaseModal .btn-primary {
    background: var(--primary-color, #0070C0);
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

#agentPurchaseModal .btn-primary:hover {
    background: var(--primary-hover, #005a9c);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 112, 192, 0.3);
}

#agentPurchaseModal .btn-secondary {
    background: transparent;
    border: 2px solid var(--border-color, #ddd);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

#agentPurchaseModal .btn-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--text-primary);
}

/* Tooltip for Locked Buttons - REMOVED (no tooltips, agents look identical) */

/* Dark Theme Support - REMOVED locked button overrides (agents look identical) */

[data-theme="dark"] #agentPurchaseModal .modal-header {
    background: #1a1a1a;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] #agentPurchaseModal .modal-body {
    background: #1a1a1a;
}

[data-theme="dark"] #agentPurchaseModal .alert-info {
    background: rgba(13, 110, 253, 0.15);
    border-color: rgba(13, 110, 253, 0.4);
    color: #e0e0e0;
}

[data-theme="dark"] #agentPurchaseModal .alert-info .fa-info-circle {
    color: #4d9eff;
}

[data-theme="dark"] #agentPurchaseModal .alert-info strong {
    color: #ffffff;
}

[data-theme="dark"] .agent-lock-icon {
    color: #FFD700 !important; /* Fixed gold - same as light theme */
}

[data-theme="dark"] .agent-unlock-icon {
    color: #FFD700 !important; /* Fixed gold - same as light theme */
}

/* Warm Theme Support - REMOVED locked button overrides (agents look identical) */

[data-theme="warm"] #agentPurchaseModal .modal-header {
    background: #fffaed;
    border-bottom-color: rgba(212, 165, 116, 0.2);
}

[data-theme="warm"] #agentPurchaseModal .modal-body {
    background: #fffaed;
}

[data-theme="warm"] #agentPurchaseModal .alert-info {
    background: rgba(13, 110, 253, 0.08);
    border-color: rgba(13, 110, 253, 0.25);
    color: #3d3426;
}

[data-theme="warm"] #agentPurchaseModal .alert-info .fa-info-circle {
    color: #0d6efd;
}

[data-theme="warm"] #agentPurchaseModal .alert-info strong {
    color: #2b1f14;
}

[data-theme="warm"] #agentPurchaseModal .modal-body {
    background: #fffaed;
}

[data-theme="warm"] #agentPurchaseModal .alert-info {
    background: rgba(212, 165, 116, 0.15);
    border-color: rgba(212, 165, 116, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .agent-lock-icon,
    .agent-unlock-icon {
        font-size: 0.8em;
        margin-right: 0.3rem;
    }
    
    #agentPurchaseModal .modal-body {
        padding: 1.5rem;
    }
    
    #agentPurchaseModal .btn-primary,
    #agentPurchaseModal .btn-secondary {
        padding: 0.65rem 1.25rem;
        font-size: 0.95rem;
    }
}

/* Loading State */
.agent-access-loading {
    position: relative;
}

.agent-access-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 1rem;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary-color, #0070C0);
    border-radius: 50%;
    animation: agent-spinner 0.6s linear infinite;
}

@keyframes agent-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Unlock Animation */
@keyframes unlock-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.agent-unlocked-animation {
    animation: unlock-pulse 0.5s ease-in-out;
}

/* Lock Icon Shake (on click when locked) */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.agent-button-locked.shake {
    animation: shake 0.5s ease-in-out;
}

/* Premium Badge Indicator */
.premium-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Unlock Progress Indicator (for future use) */
.agent-unlock-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.agent-unlock-progress-bar {
    height: 100%;
    background: var(--success-color, #28a745);
    transition: width 0.3s ease;
}

/* ============================================
   Phase 7: Purchase Success & Unlock Animations
   ============================================ */

/* Agent Unlock Badge (Purchase Success Modal) */
.agent-unlock-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: transform 0.3s ease;
}

.agent-unlock-badge:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.agent-unlock-badge i.fa-2x {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Unlock Pulse Animation */
@keyframes unlockPulse {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Unlock Shake Animation */
@keyframes unlockShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px) rotate(-5deg);
    }
    75% {
        transform: translateX(5px) rotate(5deg);
    }
}

/* Unlock Reveal Animation (for unlock icon) */
@keyframes unlockReveal {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.3) rotate(20deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

/* Fade Out Scale (for lock icon) */
@keyframes fadeOutScale {
    0% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
    100% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
}

/* Agent Unlocking State */
.agent-unlocking {
    animation: unlockShake 0.5s ease-in-out;
}

/* Lock Icon Disappearing */
.agent-lock-icon.disappearing {
    animation: fadeOutScale 0.3s ease-out forwards;
}

/* Unlock Icon Appearing */
.agent-unlock-icon.appearing {
    animation: unlockReveal 0.6s ease-out forwards;
}

/* Purchase Success Modal Styles */
#purchaseSuccessModal .modal-content {
    border: 2px solid #28a745;
    border-radius: 20px;
}

#purchaseSuccessModal .modal-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border-radius: 18px 18px 0 0;
    border-bottom: none;
}

#purchaseSuccessModal .alert-success {
    background: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.3);
    border-radius: 12px;
}

/* Dark Theme Adjustments for Purchase Success */
[data-theme="dark"] #purchaseSuccessModal .modal-content {
    background: #1a1a1a;
}

[data-theme="dark"] #purchaseSuccessModal .agent-unlock-badge {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

/* Warm Theme Adjustments for Purchase Success */
[data-theme="warm"] #purchaseSuccessModal .modal-content {
    background: #fffaed;
}

[data-theme="warm"] #purchaseSuccessModal .alert-success {
    background: rgba(212, 165, 116, 0.1);
    border-color: rgba(212, 165, 116, 0.3);
}

/* Accessibility: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .agent-unlock-badge,
    .agent-unlocking,
    .agent-lock-icon.disappearing,
    .agent-unlock-icon.appearing {
        animation: none !important;
        transition: none !important;
    }
}

/* ========================================
   Phase 7: Package Expiry Warning System
   ======================================== */

/* Package expiry warning banner container */
.package-expiry-warning {
    position: relative;
    z-index: 1040; /* Below modals (1050) but above content */
    animation: slideDown 0.4s ease-out;
}

.package-expiry-warning .alert {
    border-radius: 12px;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 0;
}

.package-expiry-warning .alert i {
    font-size: 1.1rem;
    vertical-align: middle;
}

.package-expiry-warning .alert-link {
    font-weight: 600;
    text-decoration: none;
    padding: 4px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.package-expiry-warning .alert-link:hover {
    background: rgba(255, 255, 255, 0.3);
    text-decoration: none;
}

/* Warning level-specific styles */
.package-expiry-warning .alert-danger {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.1) 0%, rgba(220, 53, 69, 0.05) 100%);
    border: 2px solid #dc3545;
    color: #721c24;
}

.package-expiry-warning .alert-warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1) 0%, rgba(255, 193, 7, 0.05) 100%);
    border: 2px solid #ffc107;
    color: #856404;
}

.package-expiry-warning .alert-info {
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.1) 0%, rgba(23, 162, 184, 0.05) 100%);
    border: 2px solid #17a2b8;
    color: #0c5460;
}

/* Slide down animation */
@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Dark theme adjustments */
[data-theme="dark"] .package-expiry-warning .alert-danger {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.2) 0%, rgba(220, 53, 69, 0.1) 100%);
    color: #f8d7da;
}

[data-theme="dark"] .package-expiry-warning .alert-warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2) 0%, rgba(255, 193, 7, 0.1) 100%);
    color: #fff3cd;
}

[data-theme="dark"] .package-expiry-warning .alert-info {
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.2) 0%, rgba(23, 162, 184, 0.1) 100%);
    color: #d1ecf1;
}

/* Warm theme adjustments */
[data-theme="warm"] .package-expiry-warning .alert-danger {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.15) 0%, rgba(220, 53, 69, 0.08) 100%);
    border-color: #c82333;
}

[data-theme="warm"] .package-expiry-warning .alert-warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15) 0%, rgba(255, 193, 7, 0.08) 100%);
    border-color: #e0a800;
}

[data-theme="warm"] .package-expiry-warning .alert-info {
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.15) 0%, rgba(23, 162, 184, 0.08) 100%);
    border-color: #138496;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .package-expiry-warning .alert {
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }
    
    .package-expiry-warning .alert i {
        font-size: 1rem;
    }
    
    .package-expiry-warning .alert-link {
        display: inline-block;
        margin-top: 0.5rem;
    }
}
