/* =====================================================
   Tools - Shared Design System
   ===================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary Colors */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --tools-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --games-gradient: linear-gradient(135deg, #fc466b 0%, #3f5efb 100%);

    /* Background Colors */
    --bg-dark: #0a0a1a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.1);
    --bg-input: rgba(255, 255, 255, 0.08);

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    /* Effects */
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 20px 60px rgba(0, 0, 0, 0.4);

    /* Sizes */
    --border-radius: 20px;
    --border-radius-sm: 12px;
    --border-radius-xs: 8px;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* =====================================================
   Background Animation
   ===================================================== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(17, 153, 142, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(56, 239, 125, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 60%);
    animation: gradientShift 15s ease-in-out infinite;
}

@keyframes gradientShift {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

.floating-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, #11998e, #38ef7d);
    top: -100px;
    left: -100px;
    animation: float1 20s ease-in-out infinite;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    top: 50%;
    right: -100px;
    animation: float2 25s ease-in-out infinite;
}

.shape-3 {
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, #11998e, #38ef7d);
    bottom: -50px;
    left: 30%;
    animation: float3 18s ease-in-out infinite;
}

@keyframes float1 {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(100px, 50px) rotate(120deg);
    }

    66% {
        transform: translate(50px, 100px) rotate(240deg);
    }
}

@keyframes float2 {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    50% {
        transform: translate(-80px, -60px) rotate(180deg);
    }
}

@keyframes float3 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(-50px, -80px);
    }
}

/* =====================================================
   Container & Layout
   ===================================================== */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* =====================================================
   Header
   ===================================================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    padding: 15px 0;
    flex-wrap: wrap;
    gap: 15px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: translateX(-5px);
}

.title-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tool-icon {
    font-size: 2rem;
}

.tool-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--tools-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =====================================================
   Tool Panels
   ===================================================== */
.tool-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tool-panel {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 25px;
    backdrop-filter: blur(10px);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
}

.panel-icon {
    font-size: 1.3rem;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* =====================================================
   Form Elements
   ===================================================== */
.input-group {
    margin-bottom: 15px;
}

.input-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.text-input,
.text-area {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.text-input:focus,
.text-area:focus {
    outline: none;
    border-color: rgba(56, 239, 125, 0.5);
    box-shadow: 0 0 0 3px rgba(56, 239, 125, 0.1);
}

.text-area {
    min-height: 120px;
    resize: vertical;
    font-family: 'Monaco', 'Consolas', monospace;
    line-height: 1.5;
}

.text-area.large {
    min-height: 200px;
}

/* Select */
.select-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
}

.select-input:focus {
    outline: none;
    border-color: rgba(56, 239, 125, 0.5);
}

/* =====================================================
   Buttons
   ===================================================== */
.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-xs);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    min-height: 44px;
}

.btn-primary {
    background: var(--tools-gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(17, 153, 142, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-icon {
    padding: 12px;
    min-width: 44px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    min-height: 36px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* =====================================================
   Tabs
   ===================================================== */
.tabs {
    display: flex;
    gap: 5px;
    background: var(--bg-input);
    padding: 5px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 20px;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: var(--border-radius-xs);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-height: 44px;
}

.tab-btn.active {
    background: var(--tools-gradient);
    color: white;
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   Result Display
   ===================================================== */
.result-box {
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
    padding: 15px;
    margin-top: 15px;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.result-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.result-content {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    word-break: break-all;
    color: #38ef7d;
}

.result-content.error {
    color: #fc466b;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.stat-item {
    background: var(--bg-input);
    border-radius: var(--border-radius-xs);
    padding: 15px;
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--tools-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =====================================================
   Copy Button with Feedback
   ===================================================== */
.copy-btn {
    position: relative;
}

.copy-btn.copied::after {
    content: '已复制!';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #38ef7d;
    color: #0a0a1a;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.75rem;
    animation: fadeOut 1.5s forwards;
}

@keyframes fadeOut {

    0%,
    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* =====================================================
   File Upload
   ===================================================== */
.file-upload {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: var(--bg-input);
    border: 2px dashed var(--glass-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-upload:hover {
    border-color: rgba(56, 239, 125, 0.5);
    background: rgba(56, 239, 125, 0.05);
}

.file-upload.dragover {
    border-color: #38ef7d;
    background: rgba(56, 239, 125, 0.1);
}

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

.upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.upload-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.upload-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 8px;
}

/* =====================================================
   Color Picker Specific
   ===================================================== */
.color-display {
    width: 100%;
    height: 150px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 15px;
    transition: background-color 0.3s ease;
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}

.color-picker {
    width: 60px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: var(--border-radius-xs);
    cursor: pointer;
    background: transparent;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-xs);
}

/* Gradient Preview */
.gradient-preview {
    width: 100%;
    height: 100px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 15px;
}

/* Color Palette */
.color-palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
}

.palette-color {
    aspect-ratio: 1;
    border-radius: var(--border-radius-xs);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.palette-color:hover {
    transform: scale(1.1);
    border-color: white;
}

/* =====================================================
   Range Slider
   ===================================================== */
.range-group {
    margin-bottom: 15px;
}

.range-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.range-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.range-value {
    font-size: 0.9rem;
    color: #38ef7d;
    font-weight: 600;
}

.range-input {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
}

.range-input::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--tools-gradient);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.range-input::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* =====================================================
   Image Preview
   ===================================================== */
.image-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--border-radius-sm);
    object-fit: contain;
}

.image-info {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.info-item {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.info-value {
    color: #38ef7d;
    font-weight: 600;
}

/* =====================================================
   Responsive Design
   ===================================================== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tool-title {
        font-size: 1.3rem;
    }

    .tool-panel {
        padding: 20px 15px;
    }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        flex: none;
        padding: 10px 15px;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .tool-panel {
        padding: 15px;
    }

    .text-area {
        min-height: 100px;
    }

    .file-upload {
        min-height: 150px;
    }

    .upload-icon {
        font-size: 2rem;
    }
}

/* =====================================================
   Utility Classes
   ===================================================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.gap-10 {
    gap: 10px;
}

.gap-20 {
    gap: 20px;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(56, 239, 125, 0.9);
    color: #0a0a1a;
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: rgba(252, 70, 107, 0.9);
    color: white;
}