/* ========================================
   Floating Widget Styles
   AgomTradePro 浮动小组件系统
   ======================================== */

/* Widget Container */
.floating-widget {
    position: fixed;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

/* Default position: bottom-right */
.floating-widget.position-bottom-right {
    bottom: 24px;
    right: 24px;
}

.floating-widget.position-bottom-left {
    bottom: 24px;
    left: 24px;
}

.floating-widget.position-top-right {
    top: 24px;
    right: 24px;
}

.floating-widget.position-top-left {
    top: 24px;
    left: 24px;
}

/* ========================================
   Collapsed State (Default)
   ======================================== */
.floating-widget .widget-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    border: none;
    padding: 0;
}

.floating-widget .widget-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.floating-widget .widget-toggle:active {
    transform: scale(0.95);
}

.floating-widget .widget-icon {
    font-size: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Pulse animation for collapsed state */
@keyframes widget-pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.6);
    }
}

.floating-widget:not(.expanded) .widget-toggle {
    animation: widget-pulse 3s ease-in-out infinite;
}

/* ========================================
   Expanded State
   ======================================== */
.floating-widget.expanded {
    align-items: flex-end;
}

.floating-widget.expanded .widget-toggle {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    margin-bottom: 8px;
    animation: none;
}

.floating-widget.expanded .widget-icon {
    font-size: 20px;
}

.floating-widget.expanded .widget-toggle .close-icon {
    display: inline-block;
}

.floating-widget.expanded .widget-toggle .default-icon {
    display: none;
}

/* Hide close icon in collapsed state */
.floating-widget:not(.expanded) .widget-toggle .close-icon {
    display: none;
}

.floating-widget:not(.expanded) .widget-toggle .default-icon {
    display: inline-block;
}

/* Widget Content Panel */
.floating-widget .widget-content {
    display: none;
    width: 400px;
    max-height: 600px;
    background: var(--color-bg, #ffffff);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: widget-expand 0.3s ease;
}

@keyframes widget-expand {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.floating-widget.expanded .widget-content {
    display: flex;
    flex-direction: column;
}

/* Widget Header */
.floating-widget .widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.floating-widget .widget-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.floating-widget .widget-title-icon {
    font-size: 20px;
}

.floating-widget .widget-actions {
    display: flex;
    gap: 8px;
}

.floating-widget .widget-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.floating-widget .widget-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Widget Body */
.floating-widget .widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Widget Sections */
.floating-widget .widget-section {
    margin-bottom: 20px;
}

.floating-widget .widget-section:last-child {
    margin-bottom: 0;
}

.floating-widget .section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary, #0f172a);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-border, #e2e8f0);
}

.floating-widget .section-content {
    font-size: 13px;
    line-height: 1.6;
    color: var(--color-text-secondary, #475569);
}

.floating-widget .section-content p {
    margin-bottom: 10px;
}

.floating-widget .section-content p:last-child {
    margin-bottom: 0;
}

/* Widget Accordions (reused from teaching.css) */
.floating-widget .accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.floating-widget .accordion-item {
    background: var(--color-surface, #f8fafc);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.floating-widget .accordion-item:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.floating-widget .accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary, #0f172a);
    transition: background 0.2s ease;
}

.floating-widget .accordion-header:hover {
    background: rgba(102, 126, 234, 0.05);
}

.floating-widget .accordion-title {
    flex: 1;
}

.floating-widget .accordion-icon {
    font-size: 10px;
    color: var(--color-text-muted, #94a3b8);
    transition: transform 0.3s ease;
}

.floating-widget .accordion-item.open .accordion-icon {
    transform: rotate(180deg);
}

.floating-widget .accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.floating-widget .accordion-item.open .accordion-content {
    max-height: 500px;
}

.floating-widget .accordion-body {
    padding: 0 16px 16px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--color-text-secondary, #475569);
}

/* Widget Info Boxes (reused from teaching.css) */
.floating-widget .info-box {
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    line-height: 1.5;
}

.floating-widget .warning-box {
    background: #fff7ed;
    border-left: 3px solid #f59e0b;
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    line-height: 1.5;
}

.floating-widget .success-box {
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    line-height: 1.5;
}

/* Widget Footer */
.floating-widget .widget-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border, #e2e8f0);
    background: var(--color-surface, #f8fafc);
}

.floating-widget .widget-actions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.floating-widget .widget-action-link {
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary, #475569);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.floating-widget .widget-action-link:hover {
    border-color: var(--color-primary, #667eea);
    color: var(--color-primary, #667eea);
    background: rgba(102, 126, 234, 0.05);
}

/* Scrollbar Styling */
.floating-widget .widget-body::-webkit-scrollbar {
    width: 6px;
}

.floating-widget .widget-body::-webkit-scrollbar-track {
    background: var(--color-surface, #f8fafc);
    border-radius: 3px;
}

.floating-widget .widget-body::-webkit-scrollbar-thumb {
    background: var(--color-border, #e2e8f0);
    border-radius: 3px;
}

.floating-widget .widget-body::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* ========================================
   Mobile Responsive (仅针对真正的移动设备)
   ======================================== */
@media (max-width: 768px) and (hover: none) {
    .floating-widget.position-bottom-right,
    .floating-widget.position-bottom-left,
    .floating-widget.position-top-right,
    .floating-widget.position-top-left {
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
    }

    .floating-widget .widget-toggle {
        width: 48px;
        height: 48px;
    }

    .floating-widget .widget-icon {
        font-size: 20px;
    }

    .floating-widget.expanded {
        align-items: stretch;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        padding: 0;
        justify-content: center;
    }

    .floating-widget.expanded .widget-toggle {
        position: absolute;
        top: 16px;
        right: 16px;
        margin: 0;
        z-index: 10;
    }

    .floating-widget.expanded .widget-content {
        width: 100%;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
    }

    .floating-widget .widget-header {
        padding: 14px 16px;
    }

    .floating-widget .widget-title {
        font-size: 15px;
    }

    .floating-widget .widget-body {
        padding: 16px;
    }

    .floating-widget .section-title {
        font-size: 13px;
    }

    .floating-widget .section-content,
    .floating-widget .accordion-body {
        font-size: 12px;
    }
}

/* 小屏幕但非触屏设备（页面放大等情况）：确保面板不超出可视区域 */
@media (max-width: 768px) and (hover: hover) {
    .floating-widget .widget-content {
        max-width: calc(100vw - 48px);
        right: 0;
    }
    
    .floating-widget.position-bottom-right .widget-content {
        right: 0;
        left: auto;
    }
}

/* ========================================
   Accessibility
   ======================================== */
.floating-widget .widget-toggle:focus-visible,
.floating-widget .widget-action-btn:focus-visible,
.floating-widget .widget-action-link:focus-visible {
    outline: 2px solid var(--color-primary, #667eea);
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .floating-widget .widget-toggle,
    .floating-widget .widget-content,
    .floating-widget .accordion-content {
        transition: none;
        animation: none;
    }

    .floating-widget:not(.expanded) .widget-toggle {
        animation: none;
    }
}

/* ========================================
   Dark Mode Support (future)
   ======================================== */
@media (prefers-color-scheme: dark) {
    .floating-widget .widget-content {
        background: #1e293b;
    }

    .floating-widget .widget-body {
        color: #cbd5e1;
    }

    .floating-widget .section-title {
        color: #f1f5f9;
        border-bottom-color: #334155;
    }

    .floating-widget .section-content {
        color: #94a3b8;
    }

    .floating-widget .accordion-item {
        background: #0f172a;
        border-color: #334155;
    }

    .floating-widget .accordion-header {
        color: #f1f5f9;
    }

    .floating-widget .info-box {
        background: rgba(59, 130, 246, 0.1);
        border-left-color: #3b82f6;
    }

    .floating-widget .warning-box {
        background: rgba(245, 158, 11, 0.1);
        border-left-color: #f59e0b;
    }

    .floating-widget .success-box {
        background: rgba(34, 197, 94, 0.1);
        border-left-color: #22c55e;
    }

    .floating-widget .widget-footer {
        background: #0f172a;
        border-top-color: #334155;
    }

    .floating-widget .widget-action-link {
        background: #1e293b;
        border-color: #334155;
        color: #94a3b8;
    }

    .floating-widget .widget-action-link:hover {
        border-color: #667eea;
        color: #667eea;
        background: rgba(102, 126, 234, 0.1);
    }
}
