/* Tool Unified Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    line-height: 1.6;
    background: #fafafa;
    min-height: 100vh;
    color: #1a1a1a;
}

/* RTL Support */
[dir="rtl"] body {
    font-family: 'IBM Plex Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

[lang="zh"] body,
[lang="ja"] body {
    font-family: 'Noto Sans SC', 'Noto Sans JP', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

/* Header */
header {
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo img {
    height: 32px;
    width: auto;
}

/* Navigation */
nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-dropdown {
    position: relative;
}

.nav-dropdown-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    transition: color 0.15s, background 0.15s;
}

.nav-dropdown-btn:hover {
    color: #1a1a1a;
    background: #f5f5f5;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 6px;
    display: none;
    min-width: 180px;
    z-index: 200;
}

[dir="rtl"] .nav-dropdown-menu {
    left: auto;
    right: 0;
}

.nav-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-menu a {
    display: block;
    padding: 10px 14px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    border-radius: 4px;
    transition: background 0.15s;
}

.nav-dropdown-menu a:hover { background: #f5f5f5; }
.nav-dropdown-menu a.active { background: #1a1a1a; color: #fff; }

.back-link {
    font-size: 14px;
    color: #666;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.back-link:hover { color: #1a1a1a; }

.nav-link {
    font-size: 14px;
    color: #666;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
    color: #1a1a1a;
    background: #f5f5f5;
}

/* Language Dropdown */
.lang-dropdown {
    position: relative;
}

.lang-current {
    font-size: 14px;
    color: #666;
    background: none;
    border: 1px solid #e5e5e5;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.lang-current:hover { border-color: #ccc; }

.lang-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
    min-width: 140px;
    z-index: 1000;
    padding: 4px;
}

[dir="rtl"] .lang-menu {
    right: auto;
    left: 0;
}

.lang-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

.lang-dropdown:hover .lang-menu,
.lang-dropdown.open .lang-menu { display: block; }

.lang-menu a {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    color: #1a1a1a;
    font-size: 14px;
    border-radius: 4px;
}

.lang-menu a:hover { background: #f5f5f5; }
.lang-menu a.active { font-weight: 600; background: #1a1a1a; color: #fff; }

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

/* Tool Header */
.tool-header {
    text-align: center;
    margin-bottom: 40px;
}

.tool-header h1 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1a1a1a;
    letter-spacing: -0.5px;
}

.tool-header p {
    font-size: 16px;
    color: #666;
}

/* Tool Workspace */
.tool-workspace {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    overflow: hidden;
}

.workspace-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 768px) {
    .workspace-grid { grid-template-columns: 1fr; }
    .nav-dropdown { display: none; }
}

.column {
    display: flex;
    flex-direction: column;
}

.column:first-child {
    border-right: 1px solid #e5e5e5;
}

[dir="rtl"] .column:first-child {
    border-right: none;
    border-left: 1px solid #e5e5e5;
}

@media (max-width: 768px) {
    .column:first-child {
        border-right: none;
        border-bottom: 1px solid #e5e5e5;
    }
}

.column-header {
    padding: 12px 20px;
    border-bottom: 1px solid #e5e5e5;
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.column-header label {
    font-weight: 500;
    color: #1a1a1a;
    font-size: 14px;
}

.column-actions {
    display: flex;
    gap: 8px;
}

.small-btn {
    background: #fff;
    border: 1px solid #e5e5e5;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    font-family: inherit;
    transition: all 0.15s;
}

.small-btn:hover {
    background: #f5f5f5;
    color: #1a1a1a;
    border-color: #ccc;
}

/* Textarea */
.textarea-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.copy-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s, background 0.15s;
    z-index: 10;
}

[dir="rtl"] .copy-icon {
    right: auto;
    left: 8px;
}

.textarea-wrapper:hover .copy-icon { opacity: 1; }
.copy-icon:hover { background: #f0f0f0; border-color: #ccc; }
.copy-icon.copied { background: #d4edda; border-color: #28a745; }

.column textarea {
    width: 100%;
    min-height: 280px;
    padding: 20px;
    border: none;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 14px;
    resize: vertical;
    line-height: 1.7;
}

.column textarea:focus { outline: none; }
.column textarea::placeholder { color: #999; }

/* Generator Controls */
.generator-controls {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.generator-controls .option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.generator-controls .option-group label {
    font-weight: 500;
    font-size: 14px;
    color: #333;
}

.generator-controls input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: #1a1a1a;
}

.generator-controls .range-value {
    font-size: 14px;
    color: #666;
    text-align: right;
}

[dir="rtl"] .generator-controls .range-value { text-align: left; }

.generator-controls .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.generator-controls .checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.generator-controls .checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #1a1a1a;
}

.generator-controls .checkbox-item label {
    cursor: pointer;
    font-weight: normal;
    font-size: 14px;
    color: #666;
}

.generator-controls select,
.generator-controls input[type="number"],
.generator-controls input[type="text"] {
    padding: 10px 14px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    background: #fff;
}

.generator-controls select { cursor: pointer; }

.generator-controls select:focus,
.generator-controls input[type="number"]:focus,
.generator-controls input[type="text"]:focus {
    outline: none;
    border-color: #1a1a1a;
}

/* Strength Indicator */
.strength-indicator { margin-top: 8px; }

.strength-indicator .strength-label {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 6px;
}

.strength-indicator .strength-bar {
    height: 6px;
    background: #e5e5e5;
    border-radius: 3px;
    overflow: hidden;
}

.strength-indicator .strength-fill {
    height: 100%;
    transition: width 0.3s, background 0.3s;
}

.generator-controls .generate-btn {
    background: #1a1a1a;
    color: #fff;
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.2s;
    margin-top: auto;
}

.generator-controls .generate-btn:hover { background: #333; }

/* Additional Inputs */
.additional-inputs {
    padding: 16px 20px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.additional-inputs input {
    padding: 12px 16px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.additional-inputs input:focus {
    outline: none;
    border-color: #1a1a1a;
}

/* Stats Box */
.stats-box {
    padding: 16px 20px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.stat-item {
    text-align: left;
}

[dir="rtl"] .stat-item { text-align: right; }

.stat-item .label {
    font-size: 12px;
    color: #999;
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.stat-item .value {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
}

/* Options Section */
.options-section {
    padding: 16px 20px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    background: #fafafa;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #1a1a1a;
}

.option-item label {
    cursor: pointer;
    font-size: 14px;
    color: #666;
}

/* Controls Section */
.controls-section {
    padding: 20px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    background: #fafafa;
}

/* Buttons */
.tool-btn {
    background: #1a1a1a;
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.2s;
}

.tool-btn:hover { background: #333; }
.tool-btn:active { background: #000; }

.tool-btn.secondary {
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #e5e5e5;
}

.tool-btn.secondary:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

/* Footer */
footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
    text-align: center;
}

.footer-content {
    padding-top: 24px;
    border-top: 1px solid #e5e5e5;
}

.footer-content p {
    color: #999;
    font-size: 13px;
}

/* Diff Highlighting Styles */
.diff-added {
    background-color: #d4edda;
    color: #155724;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

.diff-removed {
    background-color: #f8d7da;
    color: #721c24;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    text-decoration: line-through;
}

/* Textarea highlighting mode */
textarea[style*="pointer-events: none"] {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* On-Screen Keyboard Styles */
.keyboard-container {
    margin-top: 20px;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
}

.layout-selector {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.layout-selector label {
    font-weight: 500;
    color: #1a1a1a;
}

.layout-selector select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
    min-width: 120px;
}

.virtual-keyboard {
    user-select: none;
}

.keyboard-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.keyboard-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.keyboard-key {
    min-width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    user-select: none;
}

.keyboard-key:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.keyboard-key:active {
    background: #e5e5e5;
    transform: scale(0.98);
}

.keyboard-key.wide {
    min-width: 60px;
}

.keyboard-key.extra-wide {
    min-width: 80px;
}

.keyboard-key.spacebar {
    min-width: 200px;
}

.keyboard-key[data-type="shift"].active,
.keyboard-key[data-type="caps"].active {
    background: #007bff;
    color: #fff;
    border-color: #007bff;
}

.keyboard-key[data-type="shift"].active:hover,
.keyboard-key[data-type="caps"].active:hover {
    background: #0056b3;
    border-color: #0056b3;
}

/* RTL Support for Keyboard */
[dir="rtl"] .keyboard-row {
    direction: rtl;
}

[dir="rtl"] .keyboard-key {
    font-family: 'IBM Plex Sans Arabic', monospace;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .keyboard-key {
        min-width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .keyboard-key.wide {
        min-width: 50px;
    }

    .keyboard-key.extra-wide {
        min-width: 65px;
    }

    .keyboard-key.spacebar {
        min-width: 150px;
    }

    .keyboard-rows {
        gap: 6px;
    }

    .keyboard-row {
        gap: 3px;
    }
}

/* Keyboard Layout Links */
.keyboard-layout-links {
    margin: 20px 0;
    padding: 16px;
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
}

.keyboard-layout-links h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 12px;
    text-align: center;
}

.layout-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.layout-link {
    display: block;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    text-decoration: none;
    color: #666;
    font-size: 14px;
    text-align: center;
    transition: all 0.15s ease;
}

.layout-link:hover {
    background: #f5f5f5;
    border-color: #ccc;
    color: #1a1a1a;
}

.layout-link.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

/* Mobile Responsiveness for Layout Links */
@media (max-width: 768px) {
    .layout-links-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .layout-link {
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* Tool Content Section */
.tool-content-section {
    margin-top: 40px;
    padding: 32px 24px;
    background: #f8f9fa;
    border-top: 2px solid #e5e5e5;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.tool-content-section h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 16px;
    margin-top: 0;
}

.tool-content-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin-top: 24px;
    margin-bottom: 12px;
}

.tool-content-section p {
    font-size: 14px;
    line-height: 1.8;
    color: #666;
    margin-bottom: 12px;
}

.tool-content-section ul {
    margin: 12px 0 12px 24px;
    line-height: 1.8;
}

.tool-content-section ul li {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.tool-content-section ul li strong {
    color: #1a1a1a;
    font-weight: 600;
}

.tool-content-section ol {
    margin: 12px 0 12px 24px;
    line-height: 1.8;
}

.tool-content-section ol li {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.tool-content-section a {
    color: #0066cc;
    text-decoration: none;
    font-weight: 500;
}

.tool-content-section a:hover {
    text-decoration: underline;
}

/* Mobile Responsiveness for Content Section */
@media (max-width: 768px) {
    .tool-content-section {
        padding: 24px 16px;
        margin-top: 32px;
    }

    .tool-content-section h2 {
        font-size: 20px;
    }

    .tool-content-section h3 {
        font-size: 16px;
        margin-top: 20px;
    }

    .tool-content-section p,
    .tool-content-section ul li,
    .tool-content-section ol li {
        font-size: 13px;
    }

    .tool-content-section ul,
    .tool-content-section ol {
        margin-left: 20px;
    }
}

