/* ===== Tools Pages Shared Styles (OCR / D2 / Fear Zone) ===== */
/* Requires base.css to be loaded first */

/* ===== Page Container ===== */
.tools-page {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

[data-theme="dark"] .tools-page {
    background: var(--bg-gradient);
}

.tools-page::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxkZWZzPjxwYXR0ZXJuIGlkPSJwYXR0ZXJuIiB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHBhdHRlcm5UcmFuc2Zvcm09InJvdGF0ZSg0NSkiPjxjaXJjbGUgY3g9IjIwIiBjeT0iMjAiIHI9IjAuNSIgZmlsbD0icmdiYSgyNTUsMjU1LDI1NSwwLjA1KSIvPjwvcGF0dGVybj48L2RlZnM+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNwYXR0ZXJuKSIvPjwvc3ZnPg==');
    opacity: 0.3;
    z-index: -1;
    pointer-events: none;
}

/* Override base container for tools pages */
.tools-page .container {
    max-width: var(--container-max);
    margin: 20px auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 30px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tools-page .container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, #667eea, #764ba2, #f39c12);
}

/* ===== Page Title ===== */
.tools-page h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--secondary);
    font-size: 2.2rem;
    position: relative;
    padding-bottom: 15px;
}

.tools-page h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--primary-gradient-h);
    border-radius: 2px;
}

/* ===== Content Wrapper ===== */
.content-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 30px;
}

/* ===== Upload Preview Section ===== */
.upload-preview-section {
    flex: 1;
    min-width: 300px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--surface-alt);
    position: relative;
    overflow: hidden;
}

.upload-preview-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    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;
}

.upload-preview-section:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.2);
}

.upload-preview-section:hover::before {
    opacity: 1;
}

.upload-preview-section.dragover {
    border-color: var(--primary);
    background-color: var(--surface-hover);
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.3);
}

.upload-preview-section.dragover::before {
    opacity: 1;
}

/* ===== Upload Icon ===== */
.upload-icon {
    font-size: 60px;
    color: var(--primary);
    margin-bottom: 20px;
    transition: transform 0.3s ease;
    position: relative;
    display: block;
}

.upload-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.1);
    transform: translate(-50%, -50%);
    z-index: -1;
}

.upload-preview-section:hover .upload-icon {
    transform: scale(1.1) rotate(5deg);
}

.upload-preview-section.has-preview .upload-icon {
    display: none;
}

.image-preview:not([src=""]):not([src]) ~ .upload-icon,
.image-preview[src]:not([src=""]) ~ .upload-icon {
    display: none;
}

.upload-preview-section h2 {
    color: var(--secondary);
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.upload-preview-section p {
    color: var(--text-muted);
    margin-bottom: 25px;
    font-size: 0.95rem;
}

/* ===== Image Preview ===== */
.image-preview {
    max-width: 100%;
    max-height: 250px;
    display: none;
    margin: 0 auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    border: 1px solid var(--border-light);
}

.image-preview:hover {
    box-shadow: var(--shadow-hover);
}

.image-preview-container {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--border-light);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    position: relative;
}

.image-preview-container:hover {
    background-color: rgba(102, 126, 234, 0.05);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.image-preview-container:hover .image-preview {
    box-shadow: var(--shadow-hover);
}

.image-preview-container:has(.image-preview[src]):not(:has(.image-preview[src=""])) {
    background:
        linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%),
        var(--surface-alt);
}

.image-preview-container:has(.image-preview[src]):not(:has(.image-preview[src=""]))::before {
    content: attr(data-zoom-text, 'Click to zoom');
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(102, 126, 234, 0.8);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-preview-container:has(.image-preview[src]):not(:has(.image-preview[src=""])):hover::before {
    opacity: 1;
}

.image-preview-container h3 {
    margin-bottom: 20px;
    color: var(--secondary);
    font-size: 1.2rem;
}

/* ===== File Input ===== */
.file-input-wrapper {
    position: relative;
    display: inline-block;
    margin: 20px 0;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-button {
    display: inline-block;
    padding: 14px 30px;
    background: var(--primary-gradient);
    color: white;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.file-input-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(102, 126, 234, 0.4);
}

.file-input-button:active {
    transform: translateY(-1px);
}

.file-input-button.disabled {
    background: linear-gradient(135deg, #b0b8d8 0%, #b8a5c2 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.file-input-button.disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.file-input-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.file-input-button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% { transform: scale(0, 0); opacity: 0.5; }
    100% { transform: scale(50, 50); opacity: 0; }
}

.file-name {
    margin-top: 15px;
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

.paste-tip {
    margin-top: 15px;
    font-size: 14px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 12px;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

/* ===== Result Section ===== */
.result-section {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
}

.result-section h2 {
    margin-bottom: 20px;
    color: var(--secondary);
    font-size: 1.5rem;
}

.result-text {
    width: 100%;
    flex: 1;
    min-height: 300px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: var(--font);
    font-size: 16px;
    resize: vertical;
    display: none;
    background: var(--surface-alt);
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    line-height: 1.6;
    color: var(--text);
}

.result-text:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05), 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== Loading Overlay ===== */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.loading-content {
    text-align: center;
    padding: 40px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    width: 400px;
    position: relative;
    animation: fadeInScale 0.3s ease;
}

.spinner {
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-left-color: var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.2);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin: 0;
    font-weight: 500;
}

/* ===== Error / Success Messages ===== */
.error-message {
    color: var(--color-error);
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    border-radius: var(--radius);
    background: rgba(231, 76, 60, 0.1);
    display: none;
    animation: fadeIn 0.3s ease;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

.success-message {
    color: var(--color-success);
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    border-radius: var(--radius);
    background: rgba(39, 174, 96, 0.1);
    display: none;
    animation: fadeIn 0.3s ease;
    border: 1px solid rgba(39, 174, 96, 0.2);
}

/* ===== Feature Introduction ===== */
.feature-introduction {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-light);
}

.feature-introduction h2 {
    text-align: center;
    color: var(--secondary);
    margin-bottom: 30px;
    font-size: 1.8rem;
    position: relative;
}

.feature-introduction h2::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--primary-gradient-h);
    border-radius: 2px;
}

.feature-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.feature-item {
    background: var(--surface-alt);
    border-radius: 10px;
    padding: 25px;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.feature-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feature-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.feature-item:hover::before {
    opacity: 1;
}

.feature-item h3 {
    color: var(--secondary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.feature-item h3::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-gradient);
    margin-right: 10px;
    flex-shrink: 0;
}

.feature-item p {
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 0.95rem;
}

/* ===== Image Preview Modal ===== */
.image-preview-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 90%;
    max-height: 90%;
    animation: fadeInScaleCenter 0.3s ease;
}

@keyframes fadeInScaleCenter {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-image {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: #fff;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover,
.modal-close:focus {
    color: #ccc;
}

/* ===== Tools Page Footer ===== */
/* Footer style is now defined in base.css */
.tools-page footer {
    margin-top: 40px;
}

.tools-page footer .container {
    background: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0 auto;
    overflow: visible;
}

.tools-page footer .container::after {
    display: none;
}

/* ===== D2 Specific Styles ===== */
.rarity-star {
    color: var(--color-warning);
    font-size: 1.2rem;
}

.highlight-list,
.defect-list,
.scenario-list,
.market-list,
.evaluation-list {
    padding-left: 20px;
}

.highlight-list > li,
.defect-list > li,
.scenario-list > li,
.evaluation-list > li {
    margin-bottom: 10px;
}

.sub-list {
    padding-left: 20px;
    margin-top: 8px;
}

.sub-list li {
    margin-bottom: 5px;
}

.price {
    color: var(--color-error);
    font-weight: bold;
}

.table-wrapper {
    overflow-x: auto;
}

.tools-page table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.tools-page table th,
.tools-page table td {
    padding: 10px;
    text-align: left;
    border: 1px solid var(--border);
}

.tools-page table th {
    background-color: var(--bg);
    font-weight: bold;
}

.tools-page table tbody tr:nth-child(even) {
    background-color: var(--bg);
}

.tags {
    margin: 20px 0;
}

.tag {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    margin: 5px;
}

.back-link {
    text-align: center;
    margin-top: 20px;
}

.back-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: bold;
}

.back-link a:hover {
    text-decoration: underline;
}

.articles-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.articles-section h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--secondary);
    font-size: 1.6rem;
}

.articles-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.article-item {
    padding: 20px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    transition: all 0.3s ease;
    background: var(--bg);
}

.article-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.article-item h3 {
    margin-bottom: 10px;
}

.article-item h3 a {
    color: var(--secondary);
    text-decoration: none;
    font-size: 1.2rem;
}

.article-item h3 a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.article-excerpt {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 15px;
}

.tools-page .article-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.article-detail {
    max-width: var(--content-max);
    margin: 0 auto;
}

.tools-page .article-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.tools-page .article-header h1 {
    font-size: 1.8rem;
    margin-bottom: 15px;
    text-align: center;
}

.tools-page .article-meta .author,
.tools-page .article-meta .date {
    margin: 0 10px;
}

.article-content section {
    margin-bottom: 30px;
    padding: 0;
}

.article-content h2 {
    color: var(--secondary);
    font-size: 1.4rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
}

.article-content img {
    display: block;
    max-width: 100%;
    max-height: 500px;
    height: auto;
    margin: 20px auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.article-content img:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .tools-page footer {
        padding: 20px;
        margin-top: 30px;
    }

    .tools-page footer p {
        font-size: 0.85rem;
    }

    .tools-page footer .container {
        padding: 0;
    }

    .content-wrapper {
        flex-direction: column;
    }

    .tools-page .container {
        padding: 20px;
    }

    .result-text {
        min-height: 200px;
    }

    .tools-page h1 {
        font-size: 1.8rem;
    }

    .upload-preview-section, .result-section {
        min-width: 100%;
    }

    .feature-content {
        grid-template-columns: 1fr;
    }

    .feature-item {
        padding: 20px;
    }

    .tools-page {
        padding: 10px;
    }
}
