* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #222;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    margin-bottom: 25px;
    font-size: 32px;
    color: white;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.search-bar {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input[type="text"] {
    width: 350px;
    max-width: 60vw;
    padding: 14px 40px 14px 16px;
    border: 2px solid transparent;
    border-radius: 8px 0 0 8px;
    font-size: 15px;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.input-wrapper input[type="text"]::placeholder {
    color: #999;
}

#clearBtn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s, background 0.2s;
}

#clearBtn:hover {
    color: #666;
    background: #f0f0f0;
}

.input-wrapper input:not(:placeholder-shown) + #clearBtn {
    opacity: 1;
}

#searchBtn {
    padding: 14px 24px;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    background: #4c6ef5;
    color: white;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: center;
}

#searchBtn:hover:not(:disabled) {
    background: #3b5bdb;
}

#searchBtn:active:not(:disabled) {
    transform: scale(0.98);
}

#searchBtn:disabled {
    cursor: wait;
}

#searchBtn .btn-loader {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#searchBtn.loading .btn-text {
    display: none;
}

#searchBtn.loading .btn-loader {
    display: block;
}

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

/* Results Header */
.results-header {
    width: 600px;
    max-width: 95vw;
    margin-top: 10px;
}

.results-header h2 {
    margin-bottom: 8px;
    font-size: 18px;
    color: white;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

#resultsNumber {
    font-weight: 600;
    font-size: 14px;
    color: rgba(255,255,255,0.9);
}

#resultsNumber:not(:empty)::before {
    content: " : ";
}

.progress-container {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
}

.progress-container.active {
    opacity: 1;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #51cf66, #37b24d);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease-out;
}

.results-container {
    position: relative;
    width: 600px;
    max-width: 95vw;
    margin-top: 12px;
}

.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    border: 2px dashed #ddd;
    color: #888;
    text-align: center;
    padding: 20px;
    z-index: 1;
    transition: opacity 0.3s;
}

.empty-state.hidden {
    opacity: 0;
    pointer-events: none;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.7;
}

.empty-state p {
    margin: 4px 0;
}

.empty-hint {
    font-size: 13px;
    color: #aaa;
}

.empty-hint code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #666;
}

textarea {
    width: 100%;
    height: 320px;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 13px;
    background: white;
    resize: vertical;
    overflow-y: auto;
    line-height: 1.5em;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s;
}

textarea:focus {
    outline: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15), 0 0 0 3px rgba(102, 126, 234, 0.2);
}

#copyBtn {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 8px 12px;
    font-size: 16px;
    background: #37b24d;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    z-index: 2;
    transition: background 0.2s, transform 0.15s, opacity 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#copyBtn:hover:not(:disabled) {
    background: #2f9e44;
    transform: scale(1.05);
}

#copyBtn:active:not(:disabled) {
    transform: scale(0.95);
}

#copyBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

#copyBtn .copy-icon,
#copyBtn .check-icon {
    transition: opacity 0.2s, transform 0.2s;
}

#copyBtn .check-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    font-weight: bold;
}

#copyBtn.copied .copy-icon {
    opacity: 0;
    transform: scale(0.5);
}

#copyBtn.copied .check-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#copyBtn.copied {
    background: #2f9e44;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s;
    z-index: 1000;
}

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

.toast.success {
    background: #37b24d;
}

.toast.error {
    background: #e03131;
}

textarea.error {
    border: 2px solid #e03131;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

@media (max-width: 500px) {
    h1 {
        font-size: 24px;
    }

    .search-bar {
        flex-direction: column;
        border-radius: 8px;
    }

    .input-wrapper input[type="text"] {
        width: 100%;
        max-width: 90vw;
        border-radius: 8px 8px 0 0;
    }

    #searchBtn {
        border-radius: 0 0 8px 8px;
        width: 100%;
    }
}
