/**
 * ConvMaster - Find & Replace Styles v1.0
 * 
 * @package    ConvMaster
 * @version    1.0.0
 */

/* =====================================================
   TOOL PAGE LAYOUT
   ===================================================== */
.tool-page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tool-header__icon {
    font-size: 2.5rem;
}

.tool-header__icon .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
}

.tool-header__icon .icon--cyan {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.tool-header__text h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: var(--text-primary);
}

.tool-header__text p {
    margin: 0;
    color: var(--text-secondary);
}

/* =====================================================
   FORMAT BADGES
   ===================================================== */
.format-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.format-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-sm);
}

.format-badge--find {
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.format-badge--replace {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.format-badge--regex {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
}

.format-badge--text {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

/* =====================================================
   FIND REPLACE WIDGET
   ===================================================== */
.find-replace {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* =====================================================
   SEARCH SECTION (Find/Replace inputs)
   ===================================================== */
.find-replace__search {
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.find-replace__search-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.find-replace__search-header svg {
    color: #06b6d4;
}

/* Rules Container */
.find-replace__rules {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Single Rule */
.find-replace__rule {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.find-replace__rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.find-replace__rule-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: #06b6d4;
    background: rgba(6, 182, 212, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.find-replace__rule-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.find-replace__rule-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.find-replace__rule-remove[hidden] {
    display: none;
}

.find-replace__rule-fields {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
}

.find-replace__field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
}

.find-replace__field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.find-replace__input {
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s ease;
}

.find-replace__input:focus {
    outline: none;
    border-color: #06b6d4;
}

.find-replace__input::placeholder {
    color: var(--text-muted);
}

.find-replace__input.has-error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.find-replace__count {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(25%);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    background: rgba(6, 182, 212, 0.15);
    color: #06b6d4;
}

.find-replace__count[hidden] {
    display: none;
}

.find-replace__count.no-match {
    background: rgba(234, 179, 8, 0.15);
    color: #eab308;
}

.find-replace__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.find-replace__add-rule {
    margin-top: 1rem;
}

/* =====================================================
   OPTIONS SECTION
   ===================================================== */
.find-replace__options {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.find-replace__options-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.find-replace__options-header svg {
    color: var(--text-muted);
}

.find-replace__options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
}

/* Checkboxes */
.find-replace__checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.find-replace__checkbox input {
    display: none;
}

.find-replace__checkbox-mark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

.find-replace__checkbox input:checked + .find-replace__checkbox-mark {
    background: #06b6d4;
    border-color: #06b6d4;
}

.find-replace__checkbox input:checked + .find-replace__checkbox-mark::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.find-replace__checkbox:hover .find-replace__checkbox-mark {
    border-color: #06b6d4;
}

/* Options Help */
.find-replace__options-help {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    min-height: 20px;
}

.find-replace__help-item {
    display: block;
    padding: 0.5rem 0.75rem;
    background: rgba(6, 182, 212, 0.05);
    border-radius: var(--radius-sm);
    border-left: 3px solid #06b6d4;
}

.find-replace__help-item[hidden] {
    display: none;
}

.find-replace__help-item strong {
    color: var(--text-primary);
}

/* =====================================================
   PANELS (INPUT/OUTPUT)
   ===================================================== */
.find-replace__panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.find-replace__panel {
    padding: 1.5rem;
}

.find-replace__panel--input {
    border-right: 1px solid var(--border-color);
}

.find-replace__panel--output {
    background: var(--bg-secondary);
}

.find-replace__panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.find-replace__panel-header label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.find-replace__panel-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Textarea with highlight support */
.find-replace__textarea-wrapper {
    position: relative;
}

.find-replace__textarea {
    width: 100%;
    height: 280px;
    padding: 1rem;
    font-size: 0.875rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    resize: vertical;
    transition: border-color 0.2s ease;
    line-height: 1.6;
}

.find-replace__textarea:focus {
    outline: none;
    border-color: #06b6d4;
}

.find-replace__textarea::placeholder {
    color: var(--text-muted);
}

.find-replace__textarea--output {
    background: var(--bg-primary);
    cursor: default;
}

/* Highlight layer (for showing matches) */
.find-replace__highlight-layer {
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    padding: 1rem;
    font-size: 0.875rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    line-height: 1.6;
    pointer-events: none;
    overflow: hidden;
    border-radius: calc(var(--radius-md) - 2px);
    white-space: pre-wrap;
    word-wrap: break-word;
    color: transparent;
}

.find-replace__highlight-layer mark {
    background: rgba(6, 182, 212, 0.3);
    color: transparent;
    border-radius: 2px;
}

.find-replace__stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.find-replace__matches {
    color: #06b6d4;
    font-weight: 500;
}

.find-replace__diff {
    color: #22c55e;
    font-weight: 500;
}

.find-replace__diff--negative {
    color: #ef4444;
}

/* =====================================================
   ACTION BUTTONS
   ===================================================== */
.find-replace__actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

/* =====================================================
   MESSAGE AREA
   ===================================================== */
.find-replace__message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border-top: 1px solid rgba(34, 197, 94, 0.2);
    color: #22c55e;
    font-size: 0.9rem;
    font-weight: 500;
}

.find-replace__message[hidden] {
    display: none !important;
}

.find-replace__message--error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.find-replace__message--info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.find-replace__message--warning {
    background: rgba(234, 179, 8, 0.1);
    border-color: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.find-replace__message-icon {
    font-size: 1.1rem;
}

/* =====================================================
   PRIVACY NOTICE
   ===================================================== */
.find-replace__privacy {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(6, 182, 212, 0.1);
    border-top: 1px solid var(--border-color);
}

.find-replace__privacy span {
    font-size: 1rem;
}

.find-replace__privacy p {
    font-size: 0.85rem;
    color: #06b6d4;
    margin: 0;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn--primary {
    background: #06b6d4;
    color: white;
}

.btn--primary:hover {
    background: #0891b2;
    transform: translateY(-1px);
}

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

.btn--secondary:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: #06b6d4;
}

.btn--small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn--large {
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

.btn--success {
    background: #22c55e !important;
    border-color: #22c55e !important;
    color: white !important;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    flex-shrink: 0;
}

.btn[hidden] {
    display: none !important;
}

/* =====================================================
   SEO CONTENT
   ===================================================== */
.tool-content {
    margin-top: 3rem;
}

.tool-section {
    margin-bottom: 2.5rem;
}

.tool-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.tool-section p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
}

.feature-card__icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Formats Table */
.formats-table-wrapper {
    overflow-x: auto;
    margin-top: 1.5rem;
}

.formats-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.formats-table th,
.formats-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.formats-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.formats-table td {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.formats-table tr:last-child td {
    border-bottom: none;
}

.formats-table code {
    padding: 0.2rem 0.5rem;
    background: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Steps Grid */
.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    position: relative;
}

.step-card__number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #06b6d4;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 50%;
    margin-bottom: 0.75rem;
}

.step-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
}

.step-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.faq-item summary {
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    color: var(--text-muted);
}

.faq-item[open] summary::after {
    content: '−';
}

.faq-item p {
    padding: 0 1.5rem 1rem;
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* =====================================================
   HIDDEN ELEMENTS
   ===================================================== */
[hidden] {
    display: none !important;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
    .find-replace__panels {
        grid-template-columns: 1fr;
    }
    
    .find-replace__panel--input {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .find-replace__textarea {
        height: 200px;
    }
    
    .find-replace__rule-fields {
        flex-direction: column;
    }
    
    .find-replace__arrow {
        transform: rotate(90deg);
        margin: 0.5rem 0;
    }
}

@media (max-width: 640px) {
    .tool-header {
        flex-direction: column;
        text-align: center;
    }
    
    .find-replace__panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .find-replace__panel-actions {
        width: 100%;
    }
    
    .find-replace__panel-actions .btn {
        flex: 1;
    }
    
    .find-replace__options-grid {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .find-replace__stats {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .format-badges {
        justify-content: center;
    }
    
    .find-replace__actions {
        flex-direction: column;
    }
    
    .find-replace__actions .btn {
        width: 100%;
    }
    
    .formats-table th,
    .formats-table td {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
}

/* =====================================================
   LIGHT THEME ADJUSTMENTS
   ===================================================== */
[data-theme="light"] .find-replace__textarea {
    background: var(--bg-primary);
}

[data-theme="light"] .find-replace__textarea--output {
    background: white;
}

[data-theme="light"] .find-replace__search {
    background: var(--bg-secondary);
}

[data-theme="light"] .find-replace__options {
    background: transparent;
}

[data-theme="light"] .find-replace__actions {
    background: var(--bg-secondary);
}

[data-theme="light"] .find-replace__input {
    background: white;
}

[data-theme="light"] .find-replace__rule {
    background: white;
}

[data-theme="light"] .find-replace__checkbox-mark {
    background: white;
}

[data-theme="light"] .btn--secondary {
    background: white;
}

[data-theme="light"] .formats-table {
    background: white;
}

[data-theme="light"] .find-replace__highlight-layer mark {
    background: rgba(6, 182, 212, 0.25);
}
