/**
 * Lemma Platform Polish & Micro-interactions
 * Modern developer platform enhancements
 */

/* ============================================
   1. MICRO-INTERACTIONS
   ============================================ */

/* Button Press Effect */
.btn,
.admin-btn,
.dev-btn,
button:not(.unstyled) {
    transition: transform 0.1s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.btn:active,
.admin-btn:active,
.dev-btn:active,
button:not(.unstyled):active {
    transform: scale(0.97);
}

/* Copy to Clipboard Feedback */
.copy-btn {
    position: relative;
    overflow: visible;
}

.copy-btn::after {
    content: 'Copied!';
    position: absolute;
    top: -32px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--gray-900, #1e293b);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.copy-btn.copied::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.copy-btn.copied svg {
    stroke: var(--success, #10b981);
}

/* Checkmark animation for copy */
@keyframes checkmark-draw {
    0% { stroke-dashoffset: 24; }
    100% { stroke-dashoffset: 0; }
}

.copy-btn.copied .icon-check {
    stroke-dasharray: 24;
    animation: checkmark-draw 0.3s ease forwards;
}

/* Toggle Switches */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--gray-300, #e2e8f0);
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-switch.active {
    background: var(--primary, #667eea);
}

.toggle-switch.active::after {
    transform: translateX(20px);
}

.toggle-switch:hover {
    background: var(--gray-400, #cbd5e1);
}

.toggle-switch.active:hover {
    background: var(--primary-dark, #5a67d8);
}

/* Card Expansion Animation */
.expandable-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.expandable-card .card-content {
    max-height: 0;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.expandable-card.expanded .card-content {
    max-height: 500px;
    opacity: 1;
}

.expandable-card .expand-icon {
    transition: transform 0.2s ease;
}

.expandable-card.expanded .expand-icon {
    transform: rotate(180deg);
}

/* Ripple Effect for Buttons */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.ripple:active::before {
    width: 200%;
    height: 200%;
}

/* Focus Ring Animation */
.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4);
    animation: focus-pulse 1.5s ease infinite;
}

@keyframes focus-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.4); }
    50% { box-shadow: 0 0 0 5px rgba(102, 126, 234, 0.2); }
}

/* ============================================
   2. ENHANCED TABLES
   ============================================ */

.table-enhanced {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-enhanced thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--gray-100, #f8fafc);
}

.table-enhanced thead th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600, #64748b);
    border-bottom: 2px solid var(--gray-200, #f1f5f9);
    white-space: nowrap;
    user-select: none;
}

/* Sortable Headers */
.table-enhanced th.sortable {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.table-enhanced th.sortable:hover {
    background: var(--gray-200, #f1f5f9);
}

.table-enhanced th.sortable::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 8px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--gray-400, #cbd5e1);
    transition: transform 0.2s ease;
}

.table-enhanced th.sortable.asc::after {
    border-top-color: var(--primary, #667eea);
    transform: rotate(180deg);
}

.table-enhanced th.sortable.desc::after {
    border-top-color: var(--primary, #667eea);
}

/* Table Body */
.table-enhanced tbody tr {
    transition: background-color 0.15s ease;
}

.table-enhanced tbody tr:hover {
    background: var(--gray-50, #f9fafb);
}

.table-enhanced tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--gray-100, #f8fafc);
    vertical-align: middle;
}

/* Row Selection */
.table-enhanced tbody tr.selected {
    background: rgba(102, 126, 234, 0.08);
}

.table-enhanced tbody tr.selected:hover {
    background: rgba(102, 126, 234, 0.12);
}

/* Row Checkbox */
.row-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--gray-300, #e2e8f0);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    appearance: none;
    background: white;
}

.row-checkbox:checked {
    background: var(--primary, #667eea);
    border-color: var(--primary, #667eea);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

.row-checkbox:hover {
    border-color: var(--primary, #667eea);
}

/* Inline Row Actions */
.row-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.table-enhanced tbody tr:hover .row-actions {
    opacity: 1;
}

.row-action-btn {
    padding: 6px 8px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--gray-500, #94a3b8);
    transition: all 0.15s ease;
}

.row-action-btn:hover {
    background: var(--gray-100, #f8fafc);
    color: var(--gray-700, #475569);
}

.row-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error, #ef4444);
}

/* Pagination */
.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-top: 1px solid var(--gray-200, #f1f5f9);
}

.pagination-info {
    font-size: 14px;
    color: var(--gray-600, #64748b);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    padding: 8px 12px;
    border: 1px solid var(--gray-200, #f1f5f9);
    background: white;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--gray-50, #f9fafb);
    border-color: var(--gray-300, #e2e8f0);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--primary, #667eea);
    border-color: var(--primary, #667eea);
    color: white;
}

.page-size-select {
    padding: 8px 12px;
    border: 1px solid var(--gray-200, #f1f5f9);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

/* ============================================
   3. STATUS BADGES WITH ANIMATIONS
   ============================================ */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
}

/* Status Dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Active Status - Pulsing */
.status-badge.active,
.status-badge.success,
.status-badge.online {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.status-badge.active .status-dot,
.status-badge.success .status-dot,
.status-badge.online .status-dot {
    background: #10b981;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    50% { 
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
}

/* Pending Status - Spinning */
.status-badge.pending,
.status-badge.processing,
.status-badge.loading {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.status-badge.pending .status-dot,
.status-badge.processing .status-dot,
.status-badge.loading .status-dot {
    background: transparent;
    border: 2px solid #f59e0b;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Inactive Status */
.status-badge.inactive,
.status-badge.disabled,
.status-badge.offline {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
}

.status-badge.inactive .status-dot,
.status-badge.disabled .status-dot,
.status-badge.offline .status-dot {
    background: #94a3b8;
}

/* Error/Revoked Status */
.status-badge.error,
.status-badge.revoked,
.status-badge.failed {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.status-badge.error .status-dot,
.status-badge.revoked .status-dot,
.status-badge.failed .status-dot {
    background: #ef4444;
}

/* Revoked with strikethrough */
.status-badge.revoked {
    text-decoration: line-through;
}

/* Warning Status */
.status-badge.warning,
.status-badge.expiring {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.status-badge.warning .status-dot,
.status-badge.expiring .status-dot {
    background: #f59e0b;
    animation: pulse-yellow 2s infinite;
}

@keyframes pulse-yellow {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }
    50% { 
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }
}

/* Info Status */
.status-badge.info,
.status-badge.new {
    background: rgba(99, 102, 241, 0.1);
    color: #4f46e5;
}

.status-badge.info .status-dot,
.status-badge.new .status-dot {
    background: #6366f1;
}

/* ============================================
   4. SLIDE-OUT PANEL
   ============================================ */

.panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

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

.slide-panel.active {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200, #f1f5f9);
    flex-shrink: 0;
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900, #1e293b);
    margin: 0;
}

.panel-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500, #94a3b8);
    transition: all 0.15s ease;
}

.panel-close:hover {
    background: var(--gray-100, #f8fafc);
    color: var(--gray-700, #475569);
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.panel-section {
    margin-bottom: 24px;
}

.panel-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500, #94a3b8);
    margin-bottom: 12px;
}

.panel-field {
    margin-bottom: 16px;
}

.panel-field-label {
    font-size: 13px;
    color: var(--gray-500, #94a3b8);
    margin-bottom: 4px;
}

.panel-field-value {
    font-size: 15px;
    color: var(--gray-900, #1e293b);
    font-weight: 500;
}

.panel-field-value.mono {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 13px;
    background: var(--gray-100, #f8fafc);
    padding: 8px 12px;
    border-radius: 6px;
    word-break: break-all;
}

.panel-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--gray-200, #f1f5f9);
    flex-shrink: 0;
}

.panel-footer .btn {
    flex: 1;
}

/* ============================================
   5. GRADIENT ACCENTS
   ============================================ */

/* Primary Gradient */
.gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Subtle gradient for cards */
.gradient-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* Gradient border effect */
.gradient-border {
    position: relative;
    background: white;
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Gradient hover effect for cards */
.card-gradient-hover {
    position: relative;
    transition: transform 0.2s ease;
}

.card-gradient-hover::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.card-gradient-hover:hover::before {
    opacity: 1;
}

.card-gradient-hover:hover {
    transform: translateY(-2px);
}

/* Gradient line decoration */
.gradient-line {
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #667eea 100%);
    background-size: 200% 100%;
    animation: gradient-flow 3s ease infinite;
}

@keyframes gradient-flow {
    0%, 100% { background-position: 0% 0%; }
    50% { background-position: 100% 0%; }
}

/* Glow effect for important elements */
.glow-primary {
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.3);
}

.glow-success {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

/* Hero gradient background */
.gradient-hero {
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(102, 126, 234, 0.15), transparent),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* ============================================
   6. ADDITIONAL POLISH
   ============================================ */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Better selection color */
::selection {
    background: rgba(102, 126, 234, 0.2);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100, #f8fafc);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300, #e2e8f0);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400, #cbd5e1);
}

/* Hide scrollbar but keep functionality */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Smooth image loading */
img {
    transition: opacity 0.3s ease;
}

img[loading] {
    opacity: 0;
}

img.loaded {
    opacity: 1;
}

/* Text truncation */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Number animations */
.animate-number {
    font-variant-numeric: tabular-nums;
    transition: all 0.3s ease;
}

/* Highlight animation for new items */
@keyframes highlight-new {
    0% { background-color: rgba(102, 126, 234, 0.2); }
    100% { background-color: transparent; }
}

.highlight-new {
    animation: highlight-new 2s ease;
}

/* Shake animation for errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.4s ease;
}

/* Fade transitions */
.fade-enter {
    opacity: 0;
    transform: translateY(10px);
}

.fade-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
}

.fade-exit {
    opacity: 1;
}

.fade-exit-active {
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Tooltip styles */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: var(--gray-900, #1e293b);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    pointer-events: none;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
