/**
 * 我的工具导航 - 样式文件
 * Feature: my-tools-navigation
 */

:root {
    --my-tools-primary: #8b5cf6;
    --my-tools-primary-hover: #7c3aed;
    --my-tools-primary-light: #a78bfa;
    --my-tools-bg: #ffffff;
    --my-tools-bg-light: #faf5ff;
    --my-tools-border: #e9d5ff;
    --my-tools-text: #1f2937;
    --my-tools-text-light: #6b7280;
    --my-tools-shadow: 0 2px 8px rgba(139, 92, 246, 0.1);
    --my-tools-shadow-lg: 0 10px 25px rgba(139, 92, 246, 0.2);
}

@media (prefers-color-scheme: dark) {
    :root {
        --my-tools-bg: #1f2937;
        --my-tools-bg-light: #2d1f47;
        --my-tools-border: #4c1d95;
        --my-tools-text: #f3f4f6;
        --my-tools-text-light: #d1d5db;
    }
}

/* 使用 Bootstrap 5 的 container 类，不再自定义宽度 */
.my-tools-wrapper {
    width: 100%;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 12px;
    box-sizing: border-box;
}

@media (min-width: 576px) {
    .my-tools-wrapper { max-width: 540px; padding: 0 12px; }
}

@media (min-width: 768px) {
    .my-tools-wrapper { max-width: 720px; }
}

@media (min-width: 992px) {
    .my-tools-wrapper { max-width: 960px; }
}

@media (min-width: 1200px) {
    .my-tools-wrapper { max-width: 1140px; }
}

@media (min-width: 1400px) {
    .my-tools-wrapper { max-width: 1320px; }
}


#my-tools-container {
    margin: 20px auto;
    background: var(--my-tools-bg);
    border: 1px solid var(--my-tools-border);
    border-radius: 12px;
    box-shadow: var(--my-tools-shadow);
    overflow: visible;
}

#my-tools-container.collapsed #my-tools-list {
    display: none;
}

#my-tools-container.collapsed .my-tools-header {
    border-radius: 12px;
}

#my-tools-container.collapsed .my-tools-header .bi-chevron-up {
    transform: rotate(180deg);
}

.my-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(139, 92, 246, 0.06);
    border-bottom: 1px solid var(--my-tools-border);
    border-radius: 11px 11px 0 0;
}

.my-tools-title {
    font-size: 14px;
    font-weight: 500;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--my-tools-text-light);
}

.my-tools-title i {
    color: var(--my-tools-primary);
}

.my-tools-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.my-tools-btn {
    background: transparent;
    border: 1px solid var(--my-tools-border);
    color: var(--my-tools-text-light);
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
}

.my-tools-btn:hover {
    background: var(--my-tools-primary);
    color: white;
    border-color: var(--my-tools-primary);
}

.my-tools-btn i {
    transition: transform 0.2s ease;
}

.my-tools-btn-add {
    background: linear-gradient(135deg, var(--my-tools-primary), var(--my-tools-primary-hover));
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.my-tools-btn-add:hover {
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

#my-tools-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
    gap: 12px;
    padding: 16px 20px;
    background: var(--my-tools-bg-light);
    border-radius: 0 0 11px 11px;
}


.tool-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px;
    padding: 14px 10px;
    background: var(--my-tools-bg);
    border: 2px solid transparent;
    border-radius: 10px;
    text-decoration: none !important;
    color: var(--my-tools-text) !important;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    /* 防止被全局 a 标签样式覆盖 */
    font-weight: normal;
}

.tool-item:hover {
    border-color: var(--my-tools-primary);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.2);
    transform: translateY(-3px);
    color: var(--my-tools-text) !important;
    text-decoration: none !important;
}

.tool-item.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.tool-item.drag-over {
    border-color: var(--my-tools-primary);
    background: var(--my-tools-bg-light);
}

.tool-icon {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    object-fit: contain;
    border-radius: 8px;
    background: #f8f5ff;
    padding: 4px;
    /* 防止被全局 img 样式覆盖 */
    flex-shrink: 0;
}

.tool-name {
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    color: var(--my-tools-text) !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    line-height: 1.2;
}

/* 确保 a 标签样式不被全局覆盖 */
a.tool-item,
a.tool-item:hover,
a.tool-item:active,
a.tool-item:visited {
    color: var(--my-tools-text) !important;
    text-decoration: none !important;
}

.tool-remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.15s ease;
}

.tool-item:hover .tool-remove-btn {
    display: flex;
}

.tool-remove-btn:hover {
    background: #dc2626;
    transform: scale(1.15);
}


#add-tool-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dialog-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--my-tools-bg);
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--my-tools-shadow-lg);
}

.dialog-content-wide {
    max-width: 700px;
}

.dialog-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--my-tools-text);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--my-tools-border);
}

.dialog-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--my-tools-text-light);
    line-height: 1;
}

.dialog-close:hover {
    color: var(--my-tools-text);
}

.dialog-body-flex {
    display: flex;
    gap: 24px;
}

.dialog-form-section {
    flex: 1;
    min-width: 200px;
    padding-right: 24px;
    border-right: 1px solid var(--my-tools-border);
}

.dialog-quick-section {
    flex: 1.2;
    min-width: 250px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--my-tools-primary);
    margin: 0 0 12px 0;
}

.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--my-tools-text);
}

.form-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--my-tools-border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--my-tools-bg);
    color: var(--my-tools-text);
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--my-tools-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-actions {
    margin-top: 16px;
}

.dialog-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.dialog-btn-primary {
    background: linear-gradient(135deg, var(--my-tools-primary), var(--my-tools-primary-hover));
    color: white;
}

.dialog-btn-primary:hover {
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}


.quick-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.quick-tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    background: var(--my-tools-bg-light);
    border: 1px solid var(--my-tools-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.quick-tool-item:hover {
    border-color: var(--my-tools-primary);
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

.quick-tool-item.added {
    opacity: 0.4;
    pointer-events: none;
}

.quick-tool-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 6px;
}

.quick-tool-name {
    font-size: 10px;
    color: var(--my-tools-text);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* 悬浮工具栏 - 位置调整避免与回到顶部按钮冲突 */
.my-tools-floating {
    position: fixed;
    bottom: 170px; /* 在回到顶部按钮上方 */
    right: 50px;
    z-index: 998; /* 低于回到顶部按钮的 z-index */
}

.floating-trigger {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--my-tools-primary), var(--my-tools-primary-hover));
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
    transition: all 0.2s ease;
}

.floating-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

/* 悬浮面板 - 向左弹出 */
.floating-panel {
    display: none !important;
    position: absolute;
    bottom: 0;
    right: 60px; /* 在按钮左侧弹出 */
    width: 360px;
    max-height: 320px;
    background: var(--my-tools-bg);
    border: 1px solid var(--my-tools-border);
    border-radius: 12px;
    box-shadow: var(--my-tools-shadow-lg);
    overflow: hidden;
    z-index: 999; /* 确保在按钮上方 */
}

.floating-panel.show {
    display: block !important;
    animation: slideLeft 0.2s ease;
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.floating-panel-header {
    padding: 12px 16px;
    background: rgba(139, 92, 246, 0.06);
    border-bottom: 1px solid var(--my-tools-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.floating-panel-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--my-tools-text);
}

.floating-panel-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.floating-tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 6px;
    background: var(--my-tools-bg-light);
    border: 1px solid transparent;
    border-radius: 8px;
    text-decoration: none;
    color: var(--my-tools-text);
    transition: all 0.15s ease;
}

.floating-tool-item:hover {
    border-color: var(--my-tools-primary);
    background: white;
    transform: translateY(-2px);
}

.floating-tool-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}

.floating-tool-name {
    font-size: 10px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}


/* 响应式设计 */
@media (max-width: 768px) {
    .dialog-body-flex {
        flex-direction: column;
    }
    
    .dialog-form-section {
        padding-right: 0;
        border-right: none;
        border-bottom: 1px solid var(--my-tools-border);
        padding-bottom: 16px;
    }
    
    .dialog-quick-section {
        padding-top: 16px;
    }
    
    .quick-tools-grid {
        max-height: 200px;
    }
    
    #my-tools-list {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 10px;
        padding: 12px 16px;
    }
    
    .tool-item {
        padding: 12px 8px;
    }
    
    .tool-icon {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        max-width: 36px !important;
        max-height: 36px !important;
    }
    
    .tool-name {
        font-size: 11px;
    }
    
    .my-tools-btn span {
        display: none;
    }
    
    .floating-panel {
        width: 280px;
        right: 60px;
    }
    
    .my-tools-floating {
        bottom: 150px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    #my-tools-list {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 8px;
        padding: 10px 12px;
    }
    
    .tool-item {
        padding: 10px 6px;
        gap: 6px;
    }
    
    .tool-icon {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
    }
    
    .tool-name {
        font-size: 10px;
    }
    
    .tool-remove-btn {
        width: 18px;
        height: 18px;
        font-size: 10px;
        top: -5px;
        right: -5px;
    }
    
    .dialog-content {
        padding: 16px;
        width: 95%;
    }
    
    .floating-panel {
        width: 240px;
        right: 55px;
    }
    
    .my-tools-floating {
        bottom: 130px;
        right: 10px;
    }
    
    .floating-trigger {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}
