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

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip links for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 9999;
}

.skip-link:focus {
    top: 6px;
}

/* Focus management */
*:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

button:focus,
textarea:focus,
input:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

body {
    font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
    line-height: 1.6;
    background-color: #f9f9f9; /* Light, clean background */
    padding: 30px;
    color: #2d3748; /* Dark gray for text */
}

.container {
    max-width: 1200px; /* Wider container for spacious layout */
    margin: 0 auto;
    background-color: #ffffff; /* White background for content */
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* Tailwind-like shadow */
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #3b82f6; /* Bright blue accent similar to phrasefix */
    font-size: 32px;
    font-weight: 700; /* Bold for impact */
}

.guidance {
    margin-bottom: 30px;
    padding: 16px 24px;
    background-color: #f0f9ff; /* Very light blue for notice */
    border-radius: 8px;
    border-left: 6px solid #3b82f6; /* Blue accent border */
    font-size: 14px;
    color: #4a5568; /* Slightly lighter text */
}

.guidance p {
    margin-bottom: 10px;
    font-weight: 500;
}

.guidance ul {
    padding-left: 20px;
    margin-bottom: 0;
}

.editor-layout {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 1px; /* Reduce gap to 1px for minimal spacing between label and textarea */
    margin-bottom: 20px; /* 적절한 간격 설정 */
}

.controls-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 0px;
}

.control-row {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (min-width: 768px) {
    .control-row {
        flex-direction: row; /* Side by side layout like phrasefix */
        gap: 20px;
    }
    .control-group {
        flex: 1; /* Equal width for Find and Replace fields */
    }
    .editor-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 0px;
    }

    .controls-section {
        margin-top: 0px;
    }

    textarea#originalText {
        min-height: 200px; /* 데스크톱에서는 더 높게 */
    }
}

label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2d3748;
}

.label-with-checkbox {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0px;
}

.label-with-checkbox > label {
    margin-bottom: 0;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
}

.checkbox-wrapper input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #3b82f6; /* Blue checkbox */
}

.checkbox-wrapper label {
    font-weight: 400;
    margin-bottom: 0;
    cursor: pointer;
    color: #4a5568;
}

.textarea-with-copy {
    position: relative;
    width: 100%;
}

.copy-button {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    backdrop-filter: blur(4px);
    z-index: 10;
    min-width: auto;
    color: #6b7280;
}

.copy-button:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #3b82f6;
    transform: none;
}

.copy-button:active {
    background: rgba(59, 130, 246, 0.2);
    transform: scale(0.95);
}

.copy-button svg {
    width: 10px;
    height: 10px;
}

.copy-button .copy-icon.unchecked {
    color: #6b7280;
}

.copy-button .copy-icon.checked {
    color: #10b981;
}

.copy-button:hover .copy-icon.unchecked {
    color: #3b82f6;
}

.copy-button:hover .copy-icon.checked {
    color: #059669;
}

.copy-button.copied-tooltip::after {
    content: "Copied!";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: #ffffff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1000;
    opacity: 1;
    margin-bottom: 8px;
    animation: tooltipFadeIn 0.2s ease-out, tooltipFadeOut 0.3s ease-in 1.2s forwards;
    pointer-events: none;
}

.copy-button.copied-tooltip::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #1f2937;
    z-index: 1000;
    margin-bottom: 3px;
    animation: tooltipFadeIn 0.2s ease-out, tooltipFadeOut 0.3s ease-in 1.2s forwards;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes tooltipFadeOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-5px);
    }
}

.custom-textarea-wrapper {
    position: relative;
    width: 100%;
}

textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid #e5e7eb; /* Light gray border like phrasefix */
    border-radius: 8px;
    resize: vertical; /* Explicitly allow vertical resizing */
    font-family: 'JetBrains Mono', 'Menlo', 'Monaco', 'Courier New', monospace; /* Modern monospace font */
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

textarea#originalText {
    min-height: 150px; /* 이미지와 같이 더 높게 설정 */
    max-height: 600px; /* Maximum height for resizing */
}

textarea[readonly] {
    background-color: #f7fafc;
    cursor: not-allowed;
}

textarea:focus {
    outline: none;
    border-color: #3b82f6; /* Blue focus border */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); /* Subtle focus ring */
}

.symbol-overlay {
    position: absolute;
    top: 14px; /* Matches textarea padding */
    left: 14px;
    right: 14px;
    bottom: 14px;
    pointer-events: none;
    color: #718096; /* Gray for symbols */
    font-family: 'JetBrains Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow: hidden;
    width: calc(100% - 2px);
    height: calc(100% - 2px);
    margin: 1px;
}

.enter-symbol {
    color: #48bb78; /* Green for visibility */
    font-weight: bold;
}

.space-symbol {
    color: #b0bdce; /* Slightly different shade for space, or use opacity */
    /* opacity: 0.7; */
}

.buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    background-color: #3b82f6; /* Blue similar to phrasefix */
    color: #ffffff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease-in-out;
    min-width: 120px; /* Larger buttons */
}

button:hover:not(:disabled) {
    background-color: #2b6cb0; /* Darker blue on hover */
    transform: translateY(-2px); /* Lift effect */
}

button:disabled {
    background-color: #e2e8f0; /* Light gray for disabled */
    cursor: not-allowed;
    transform: none;
}

button#clearButton {
    background-color: #ed8936; /* Orange for clear to distinguish action */
}

button#clearButton:hover:not(:disabled) {
    background-color: #c05621; /* Darker orange */
}

button#undoButton:disabled {
    background-color: #e2e8f0;
}

button#undoButton:not(:disabled) {
    background-color: #48bb78; /* Green for undo */
}

button#undoButton:not(:disabled):hover {
    background-color: #38a169; /* Darker green */
}

.change-count {
    text-align: center;
    margin-top: 16px;
    color: #718096; /* Gray text */
    font-size: 14px;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .buttons {
        gap: 8px;
        flex-wrap: wrap;
    }
    
    button {
        min-width: 80px;
        padding: 10px 16px;
        font-size: 14px;
    }
}
