/* ============================================================
   RANDOM TEXT GENERATOR - Complete Stylesheet
   Scoped under .rtg-app to avoid host page CSS conflicts
   ============================================================ */

.rtg-app {
    /* Theme variables */
    --rtg-bg-primary: #0f1117;
    --rtg-bg-secondary: #161822;
    --rtg-bg-tertiary: #1c1e2e;
    --rtg-bg-card: #1e2032;
    --rtg-bg-hover: #252840;
    --rtg-bg-input: #12141f;
    --rtg-border: #2a2d42;
    --rtg-border-light: #353856;
    --rtg-text-primary: #e8e9f0;
    --rtg-text-secondary: #a0a3b8;
    --rtg-text-muted: #6b6e85;
    --rtg-accent: #6366f1;
    --rtg-accent-light: #818cf8;
    --rtg-accent-glow: rgba(99, 102, 241, 0.3);
    --rtg-success: #22c55e;
    --rtg-success-bg: rgba(34, 197, 94, 0.12);
    --rtg-danger: #ef4444;
    --rtg-danger-bg: rgba(239, 68, 68, 0.12);
    --rtg-warning: #f59e0b;
    --rtg-warning-bg: rgba(245, 158, 11, 0.12);
    --rtg-radius: 10px;
    --rtg-radius-sm: 6px;
    --rtg-radius-lg: 14px;
    --rtg-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --rtg-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    /* Self-contained full-screen layout */
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    min-width: 100vw;
    min-height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;

    /* Reset inherited styles */
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--rtg-text-primary);
    background: var(--rtg-bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: left;
    direction: ltr;
    z-index: 1;
}

.rtg-app *,
.rtg-app *::before,
.rtg-app *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.rtg-app button {
    font-family: inherit;
    cursor: pointer;
}

.rtg-app input,
.rtg-app select,
.rtg-app textarea {
    font-family: inherit;
}

.rtg-app a {
    color: var(--rtg-accent-light);
    text-decoration: none;
}

/* ---------- App Layout ---------- */
.rtg-app {
    display: flex;
    flex-direction: column;
}

/* ---------- Header ---------- */
.rtg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--rtg-bg-secondary);
    border-bottom: 1px solid var(--rtg-border);
    flex-shrink: 0;
    z-index: 10;
    height: 56px;
    min-height: 56px;
    max-height: 56px;
}

.rtg-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rtg-logo-icon {
    color: var(--rtg-accent-light);
    flex-shrink: 0;
}

.rtg-header-left h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--rtg-accent-light);
    line-height: 1.2;
}

.rtg-header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.rtg-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 100px;
    background: var(--rtg-accent-glow);
    color: var(--rtg-accent-light);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    line-height: 1.4;
    white-space: nowrap;
}

.rtg-badge.rtg-badge-outline {
    background: transparent;
    border: 1px solid var(--rtg-border-light);
    color: var(--rtg-text-secondary);
}

/* ---------- Main Layout ---------- */
.rtg-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    width: 100%;
    height: 100%;
}

/* ---------- Panels ---------- */
.rtg-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.rtg-panel-left {
    width: 380px;
    min-width: 380px;
    max-width: 380px;
    background: var(--rtg-bg-secondary);
    border-right: 1px solid var(--rtg-border);
    height: 100%;
}

.rtg-panel-right {
    flex: 1;
    background: var(--rtg-bg-primary);
    height: 100%;
    min-width: 0;
}

.rtg-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--rtg-border);
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 53px;
}

.rtg-panel-header h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--rtg-text-secondary);
    line-height: 1.4;
}

/* ---------- Left Panel Controls ---------- */
.rtg-controls {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

.rtg-control-group {
    margin-bottom: 22px;
}

.rtg-control-group:last-child {
    margin-bottom: 0;
}

.rtg-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--rtg-text-secondary);
    margin-bottom: 10px;
    line-height: 1.4;
}

.rtg-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.rtg-label-row .rtg-label {
    margin-bottom: 0;
}

.rtg-amount-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--rtg-accent-light);
    background: var(--rtg-accent-glow);
    padding: 2px 10px;
    border-radius: 100px;
    min-width: 36px;
    text-align: center;
    line-height: 1.4;
}

/* Type Grid */
.rtg-type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.rtg-type-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    background: var(--rtg-bg-tertiary);
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-secondary);
    border-radius: var(--rtg-radius-sm);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--rtg-transition);
    line-height: 1.3;
    text-align: center;
}

.rtg-type-btn:hover {
    border-color: var(--rtg-border-light);
    color: var(--rtg-text-primary);
    background: var(--rtg-bg-hover);
}

.rtg-type-btn.rtg-active {
    background: var(--rtg-accent-glow);
    border-color: var(--rtg-accent);
    color: var(--rtg-accent-light);
}

.rtg-type-btn svg {
    flex-shrink: 0;
}

/* Slider */
.rtg-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rtg-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--rtg-bg-tertiary);
    border-radius: 100px;
    outline: none;
    cursor: pointer;
}

.rtg-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--rtg-accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 4px var(--rtg-accent-glow);
    transition: all var(--rtg-transition);
}

.rtg-slider::-webkit-slider-thumb:hover {
    background: var(--rtg-accent-light);
    transform: scale(1.1);
}

.rtg-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--rtg-accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 0 4px var(--rtg-accent-glow);
}

.rtg-number-input {
    width: 64px;
    background: var(--rtg-bg-input);
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-primary);
    padding: 6px 8px;
    border-radius: var(--rtg-radius-sm);
    font-size: 13px;
    text-align: center;
    outline: none;
    transition: border-color var(--rtg-transition);
    line-height: 1.3;
}

.rtg-number-input:focus {
    border-color: var(--rtg-accent);
}

.rtg-number-input::-webkit-outer-spin-button,
.rtg-number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Radio Buttons */
.rtg-format-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.rtg-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--rtg-bg-tertiary);
    border: 1px solid var(--rtg-border);
    border-radius: var(--rtg-radius-sm);
    cursor: pointer;
    font-size: 12px;
    color: var(--rtg-text-secondary);
    transition: all var(--rtg-transition);
    line-height: 1.3;
}

.rtg-radio:hover {
    border-color: var(--rtg-border-light);
    color: var(--rtg-text-primary);
}

.rtg-radio input[type="radio"] {
    margin: 0;
    cursor: pointer;
    accent-color: var(--rtg-accent);
    flex-shrink: 0;
}

.rtg-radio:has(input:checked) {
    background: var(--rtg-accent-glow);
    border-color: var(--rtg-accent);
    color: var(--rtg-accent-light);
}

/* Select */
.rtg-select {
    width: 100%;
    background: var(--rtg-bg-input);
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-primary);
    padding: 8px 12px;
    border-radius: var(--rtg-radius-sm);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: border-color var(--rtg-transition);
    line-height: 1.4;
}

.rtg-select:focus {
    border-color: var(--rtg-accent);
}

/* Text Input */
.rtg-text-input {
    width: 100%;
    background: var(--rtg-bg-input);
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-primary);
    padding: 8px 12px;
    border-radius: var(--rtg-radius-sm);
    font-size: 13px;
    outline: none;
    margin-top: 6px;
    transition: border-color var(--rtg-transition);
    line-height: 1.4;
}

.rtg-text-input:focus {
    border-color: var(--rtg-accent);
}

.rtg-text-input.rtg-hidden {
    display: none;
}

/* Checkbox */
.rtg-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--rtg-text-secondary);
    padding: 6px 0;
    line-height: 1.4;
    user-select: none;
}

.rtg-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
    accent-color: var(--rtg-accent);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.rtg-checkbox:hover {
    color: var(--rtg-text-primary);
}

.rtg-checkbox-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rtg-control-group.rtg-hidden {
    display: none;
}

/* Action Buttons */
.rtg-action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.rtg-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--rtg-radius);
    font-size: 14px;
    font-weight: 600;
    border: none;
    transition: all var(--rtg-transition);
    line-height: 1.2;
    flex-shrink: 0;
}

.rtg-btn-primary {
    flex: 1;
    background: linear-gradient(135deg, var(--rtg-accent), #7c3aed);
    color: #ffffff;
}

.rtg-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.rtg-btn-primary:active {
    transform: translateY(0);
}

.rtg-btn-secondary {
    background: var(--rtg-bg-tertiary);
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-secondary);
    padding: 12px 14px;
}

.rtg-btn-secondary:hover {
    background: var(--rtg-bg-hover);
    border-color: var(--rtg-border-light);
    color: var(--rtg-text-primary);
}

/* ---------- Right Panel: Output ---------- */
.rtg-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.rtg-stat {
    font-size: 12px;
    color: var(--rtg-text-muted);
    line-height: 1.4;
    white-space: nowrap;
}

.rtg-stat strong {
    color: var(--rtg-text-primary);
    font-weight: 600;
    margin-right: 3px;
}

.rtg-output-wrapper {
    flex: 1;
    overflow: hidden;
    padding: 16px 20px 0 20px;
    min-height: 0;
    display: flex;
}

.rtg-output {
    width: 100%;
    height: 100%;
    background: var(--rtg-bg-input);
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-primary);
    padding: 16px;
    border-radius: var(--rtg-radius);
    font-size: 14px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: border-color var(--rtg-transition);
    overflow-y: auto;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.rtg-output:focus {
    border-color: var(--rtg-accent);
}

.rtg-output::placeholder {
    color: var(--rtg-text-muted);
    font-style: italic;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* Action Bar */
.rtg-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
}

.rtg-action-bar-left {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.rtg-action-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rtg-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: var(--rtg-bg-tertiary);
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-secondary);
    border-radius: var(--rtg-radius-sm);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--rtg-transition);
    line-height: 1.3;
}

.rtg-action-btn:hover {
    background: var(--rtg-bg-hover);
    border-color: var(--rtg-border-light);
    color: var(--rtg-text-primary);
}

.rtg-action-btn:active {
    transform: scale(0.98);
}

.rtg-download-filename {
    width: 180px;
    background: var(--rtg-bg-input);
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-primary);
    padding: 6px 10px;
    border-radius: var(--rtg-radius-sm);
    font-size: 12px;
    outline: none;
    transition: border-color var(--rtg-transition);
    line-height: 1.4;
}

.rtg-download-filename:focus {
    border-color: var(--rtg-accent);
}

.rtg-file-ext {
    font-size: 12px;
    color: var(--rtg-text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

/* History */
.rtg-history-section {
    flex-shrink: 0;
    border-top: 1px solid var(--rtg-border);
    background: var(--rtg-bg-secondary);
    max-height: 180px;
    display: flex;
    flex-direction: column;
}

.rtg-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--rtg-border);
    flex-shrink: 0;
}

.rtg-history-header h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--rtg-text-secondary);
    line-height: 1.4;
}

.rtg-history-clear {
    background: transparent;
    border: none;
    color: var(--rtg-text-muted);
    font-size: 11px;
    font-weight: 500;
    transition: color var(--rtg-transition);
    line-height: 1.4;
}

.rtg-history-clear:hover {
    color: var(--rtg-danger);
}

.rtg-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

.rtg-history-empty {
    text-align: center;
    color: var(--rtg-text-muted);
    font-size: 12px;
    padding: 20px;
    line-height: 1.4;
}

.rtg-history-item {
    background: var(--rtg-bg-card);
    border: 1px solid var(--rtg-border);
    border-radius: var(--rtg-radius-sm);
    padding: 8px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--rtg-transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.rtg-history-item:hover {
    border-color: var(--rtg-border-light);
    background: var(--rtg-bg-hover);
}

.rtg-history-item-info {
    flex: 1;
    min-width: 0;
}

.rtg-history-item-text {
    font-size: 12px;
    color: var(--rtg-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.rtg-history-item-meta {
    font-size: 10px;
    color: var(--rtg-text-muted);
    margin-top: 2px;
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.rtg-history-item-restore {
    background: transparent;
    border: 1px solid var(--rtg-border);
    color: var(--rtg-text-muted);
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 10px;
    transition: all var(--rtg-transition);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.3;
    flex-shrink: 0;
}

.rtg-history-item-restore:hover {
    border-color: var(--rtg-accent);
    color: var(--rtg-accent-light);
}

/* ---------- Toast ---------- */
.rtg-toast-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.rtg-toast {
    background: var(--rtg-bg-card);
    border: 1px solid var(--rtg-border);
    border-radius: var(--rtg-radius);
    padding: 12px 20px;
    font-size: 13px;
    color: var(--rtg-text-primary);
    box-shadow: var(--rtg-shadow);
    animation: rtg-toast-in 0.3s ease, rtg-toast-out 0.3s ease 2.7s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 380px;
    line-height: 1.4;
}

.rtg-toast.rtg-success {
    border-color: rgba(34, 197, 94, 0.4);
}

.rtg-toast.rtg-error {
    border-color: rgba(239, 68, 68, 0.4);
}

.rtg-toast.rtg-warning {
    border-color: rgba(245, 158, 11, 0.4);
}

.rtg-toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

@keyframes rtg-toast-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes rtg-toast-out {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

/* ---------- Scrollbar ---------- */
.rtg-app ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.rtg-app ::-webkit-scrollbar-track {
    background: transparent;
}

.rtg-app ::-webkit-scrollbar-thumb {
    background: var(--rtg-border-light);
    border-radius: 100px;
}

.rtg-app ::-webkit-scrollbar-thumb:hover {
    background: var(--rtg-text-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .rtg-panel-left {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        max-height: 50%;
        height: auto;
    }

    .rtg-panel-right {
        max-height: 50%;
        height: auto;
    }

    .rtg-main {
        flex-direction: column;
    }

    .rtg-type-grid {
        grid-template-columns: 1fr 1fr;
    }
}
