/* AI Text Humanizer v2.2 – Apple-inspired minimal UI with dark mode */

/* ================================================================ */
/*  CSS Custom Properties (Light / Dark)                            */
/* ================================================================ */

:root {
    --aith-bg: #f5f5f7;
    --aith-card: #fff;
    --aith-card-shadow: rgba(0, 0, 0, .08);
    --aith-text: #1d1d1f;
    --aith-text-muted: #86868b;
    --aith-border: #d2d2d7;
    --aith-border-light: #e8e8ed;
    --aith-input-bg: #fafafa;
    --aith-input-focus-bg: #fff;
    --aith-btn-secondary-bg: #e8e8ed;
    --aith-btn-secondary-hover: #dcdce0;
    --aith-accent: #0071e3;
    --aith-accent-hover: #0077ed;
    --aith-green: #34c759;
    --aith-diff-add: #d4edda;
    --aith-diff-del: #f8d7da;
    --aith-diff-add-text: #155724;
    --aith-diff-del-text: #721c24;
    --aith-dropzone-bg: #f0f0f5;
    --aith-dropzone-border: #c7c7cc;
}

.aith-dark {
    --aith-bg: #1c1c1e;
    --aith-card: #2c2c2e;
    --aith-card-shadow: rgba(0, 0, 0, .3);
    --aith-text: #f5f5f7;
    --aith-text-muted: #98989d;
    --aith-border: #48484a;
    --aith-border-light: #3a3a3c;
    --aith-input-bg: #1c1c1e;
    --aith-input-focus-bg: #2c2c2e;
    --aith-btn-secondary-bg: #3a3a3c;
    --aith-btn-secondary-hover: #48484a;
    --aith-diff-add: #1b3a26;
    --aith-diff-del: #3a1b1f;
    --aith-diff-add-text: #82dda0;
    --aith-diff-del-text: #f5a0a8;
    --aith-dropzone-bg: #2c2c2e;
    --aith-dropzone-border: #48484a;
}

/* ================================================================ */
/*  Body reset for standalone template                              */
/* ================================================================ */

.aith-body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--aith-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    transition: background .3s;
}

/* ================================================================ */
/*  App container & Card                                            */
/* ================================================================ */

.aith-app {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    box-sizing: border-box;
}

.aith-card {
    background: var(--aith-card);
    border-radius: 20px;
    box-shadow: 0 4px 24px var(--aith-card-shadow);
    padding: 36px 32px 28px;
    box-sizing: border-box;
    transition: background .3s, box-shadow .3s;
}

/* ================================================================ */
/*  Header with dark-mode toggle                                    */
/* ================================================================ */

.aith-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.aith-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--aith-text);
    margin: 0 0 4px;
    letter-spacing: -0.3px;
}

.aith-subtitle {
    font-size: 15px;
    color: var(--aith-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* Icon button (dark mode toggle) */
.aith-btn-icon {
    background: var(--aith-btn-secondary-bg);
    color: var(--aith-text);
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 10px;
    font-size: 18px;
    flex-shrink: 0;
}

.aith-icon-moon { display: none; }
.aith-dark .aith-icon-sun { display: none; }
.aith-dark .aith-icon-moon { display: inline; }

/* ================================================================ */
/*  Labels & counts                                                 */
/* ================================================================ */

.aith-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--aith-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.aith-count {
    font-size: 12px;
    color: var(--aith-text-muted);
    font-variant-numeric: tabular-nums;
}

.aith-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

/* ================================================================ */
/*  Side-by-side panels                                             */
/* ================================================================ */

.aith-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

.aith-panel {
    position: relative;
    min-width: 0;
}

/* ================================================================ */
/*  Textareas (both editable)                                       */
/* ================================================================ */

.aith-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--aith-border);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.55;
    color: var(--aith-text);
    background: var(--aith-input-bg);
    resize: vertical;
    transition: border-color .2s, box-shadow .2s, background .3s;
    margin-bottom: 0;
}

.aith-textarea:focus {
    outline: none;
    border-color: var(--aith-accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, .15);
    background: var(--aith-input-focus-bg);
}

/* ================================================================ */
/*  Dropzone                                                        */
/* ================================================================ */

.aith-dropzone {
    display: none;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 28px 0 0 0;
    border: 2px dashed var(--aith-dropzone-border);
    border-radius: 12px;
    background: var(--aith-dropzone-bg);
    color: var(--aith-text-muted);
    font-size: 14px;
    font-weight: 600;
    z-index: 10;
    pointer-events: none;
    opacity: 0.95;
}

.aith-dropzone.active {
    display: flex;
}

/* ================================================================ */
/*  Buttons                                                         */
/* ================================================================ */

.aith-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.aith-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    transition: background .2s, opacity .2s, color .3s;
    font-family: inherit;
    line-height: 1;
    color: var(--aith-text);
}

.aith-btn:active { opacity: .75; }

.aith-btn:disabled {
    opacity: .4;
    cursor: default;
}

.aith-btn-primary {
    background: var(--aith-accent);
    color: #fff;
}
.aith-btn-primary:hover:not(:disabled) { background: var(--aith-accent-hover); }

.aith-btn-secondary {
    background: var(--aith-btn-secondary-bg);
}
.aith-btn-secondary:hover:not(:disabled) { background: var(--aith-btn-secondary-hover); }

.aith-btn-ghost {
    background: transparent;
    color: var(--aith-text-muted);
    padding: 10px 14px;
}
.aith-btn-ghost:hover { color: var(--aith-text); }

/* ================================================================ */
/*  Diff view                                                       */
/* ================================================================ */

.aith-diff-container {
    margin-bottom: 16px;
}

.aith-diff-output {
    border: 1px solid var(--aith-border);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.55;
    color: var(--aith-text);
    background: var(--aith-input-bg);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.aith-diff-add {
    background: var(--aith-diff-add);
    color: var(--aith-diff-add-text);
    border-radius: 3px;
    padding: 0 2px;
}

.aith-diff-del {
    background: var(--aith-diff-del);
    color: var(--aith-diff-del-text);
    text-decoration: line-through;
    border-radius: 3px;
    padding: 0 2px;
}

/* ================================================================ */
/*  Find & Replace bar                                              */
/* ================================================================ */

.aith-fnr-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--aith-input-bg);
    border: 1px solid var(--aith-border);
    border-radius: 12px;
    flex-wrap: wrap;
}

.aith-fnr-input {
    flex: 1 1 120px;
    min-width: 100px;
    border: 1px solid var(--aith-border);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--aith-text);
    background: var(--aith-input-focus-bg);
    transition: border-color .2s;
}

.aith-fnr-input:focus {
    outline: none;
    border-color: var(--aith-accent);
}

.aith-btn-sm {
    padding: 7px 14px;
    font-size: 13px;
    border-radius: 8px;
}

.aith-fnr-status {
    font-size: 12px;
    color: var(--aith-text-muted);
    white-space: nowrap;
}

/* ================================================================ */
/*  Comparison slider                                               */
/* ================================================================ */

.aith-slider-container {
    margin-bottom: 16px;
}

.aith-slider-hint {
    font-size: 12px;
    color: var(--aith-text-muted);
}

.aith-slider-wrap {
    position: relative;
    border: 1px solid var(--aith-border);
    border-radius: 12px;
    overflow: hidden;
    min-height: 120px;
    background: var(--aith-input-bg);
    user-select: none;
    cursor: col-resize;
}

.aith-slider-layer {
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.aith-slider-original {
    color: var(--aith-diff-del-text);
    background: var(--aith-diff-del);
}

.aith-slider-cleaned {
    position: absolute;
    inset: 0;
    color: var(--aith-diff-add-text);
    background: var(--aith-diff-add);
    clip-path: inset(0 0 0 50%);
}

.aith-slider-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    margin-left: -2px;
    background: var(--aith-accent);
    cursor: col-resize;
    z-index: 5;
    transition: box-shadow .2s;
}

.aith-slider-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background: var(--aith-accent);
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 6px rgba(0,0,0,.2);
}

.aith-slider-handle:hover {
    box-shadow: 0 0 0 3px rgba(0, 113, 227, .2);
}

/* ================================================================ */
/*  Status line + Readability                                       */
/* ================================================================ */

.aith-status-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.aith-status {
    font-size: 13px;
    color: var(--aith-text-muted);
    min-height: 20px;
    line-height: 1.4;
}

.aith-readability {
    font-size: 13px;
    color: var(--aith-text-muted);
    font-weight: 600;
    white-space: nowrap;
}

/* ================================================================ */
/*  Settings / Toggles                                              */
/* ================================================================ */

.aith-settings {
    border-top: 1px solid var(--aith-border-light);
    padding-top: 20px;
}

.aith-settings-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--aith-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}

.aith-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 32px;
}

/* iOS-style toggle */
.aith-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    color: var(--aith-text);
    cursor: pointer;
    user-select: none;
}

.aith-toggle input[type="checkbox"] { display: none; }

.aith-toggle-slider {
    position: relative;
    width: 44px;
    height: 26px;
    background: var(--aith-border);
    border-radius: 13px;
    flex-shrink: 0;
    transition: background .25s;
}

.aith-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
    transition: transform .25s;
}

.aith-toggle input:checked + .aith-toggle-slider {
    background: var(--aith-green);
}

.aith-toggle input:checked + .aith-toggle-slider::after {
    transform: translateX(18px);
}

/* ================================================================ */
/*  Upload button (admin only)                                      */
/* ================================================================ */

.aith-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.aith-upload-label input[type="file"] {
    display: none;
}

/* ================================================================ */
/*  RTL support                                                     */
/* ================================================================ */

[dir="rtl"] .aith-card { text-align: right; }
[dir="rtl"] .aith-textarea { direction: rtl; text-align: right; }
[dir="rtl"] .aith-actions { flex-direction: row-reverse; }
[dir="rtl"] .aith-toggle { flex-direction: row-reverse; }
[dir="rtl"] .aith-toggle-slider::after { left: auto; right: 2px; }
[dir="rtl"] .aith-toggle input:checked + .aith-toggle-slider::after { transform: translateX(-18px); }
[dir="rtl"] .aith-header { flex-direction: row-reverse; }
[dir="rtl"] .aith-panel-header { flex-direction: row-reverse; }

/* ================================================================ */
/*  Responsive – stack on small screens                             */
/* ================================================================ */

@media (max-width: 700px) {
    .aith-panels {
        grid-template-columns: 1fr;
    }

    .aith-settings-grid {
        grid-template-columns: 1fr;
    }

    .aith-card {
        padding: 24px 18px 20px;
        border-radius: 16px;
    }

    .aith-title { font-size: 24px; }

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

    .aith-btn {
        flex: 1 1 auto;
        min-width: 0;
    }
}
