* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ambient page glow and subtle float animation */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(600px 400px at 12% 12%, rgba(57, 217, 255, 0.06), transparent 8%),
                radial-gradient(500px 360px at 88% 78%, rgba(124, 58, 237, 0.06), transparent 8%),
                radial-gradient(400px 260px at 50% 60%, rgba(255, 78, 207, 0.04), transparent 7%);
    mix-blend-mode: screen;
    opacity: 0.95;
    animation: floatBG 12s linear infinite;
    z-index: 0;
}

@keyframes floatBG {
    0% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
    100% { transform: translateY(0); }
}

:root {
    --bg: #07050a;
    --bg-2: #0b0b0f;
    --accent-cyan: #39d9ff;
    --accent-purple: #7c3aed;
    --accent-magenta: #ff4ecf;
    --accent-mid: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple), var(--accent-magenta));
    --glass: rgba(255, 255, 255, 0.02);
    --card-border: rgba(255, 255, 255, 0.04);
    --muted: #cfcbe1;
    --text: #e6e6ee;
    --surface: #071018;
    --light-bg: #f8f9fc;
    --light-bg-2: #f0f2f8;
    --light-text: #0d1117;
    --light-muted: #5a6470;
    --light-card: #ffffff;
    --success-color: #4ade80;
    --warning-color: #f97316;
    --error-color: #ef4444;
    --shadow: 0 8px 36px rgba(2, 6, 23, 0.65);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', Arial, sans-serif;
    background-color: var(--bg-2);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    direction: rtl;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.light-mode {
    background: linear-gradient(135deg, var(--light-bg) 0%, #f5f3ff 50%, #fff5f8 100%);
    color: var(--light-text);
    background-attachment: fixed;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Hero Section */
.hero {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.hero-inner {
    max-width: 920px;
    text-align: center;
}

.hero h2 {
    font-size: 2rem;
    margin: 0 0 0.5rem;
    background: var(--accent-mid);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

body.light-mode .hero h2 {
    background: linear-gradient(90deg, #7c3aed, #8b5cf6, #d946ef);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero .lead {
    color: var(--muted);
    margin-bottom: 1rem;
}

body.light-mode .hero .lead {
    color: var(--light-muted);
}

/* Header */
header {
    background: linear-gradient(180deg, rgba(6, 6, 10, 0.92), rgba(8, 6, 14, 0.88));
    color: var(--text);
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 36px rgba(2, 6, 23, 0.65);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid rgba(124, 58, 237, 0.06);
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.light-mode header {
    background: linear-gradient(180deg, #ffffff, #f7f3ff);
    border-bottom: 1px solid rgba(124, 58, 237, 0.12);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.08);
    color: var(--light-text);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    background: var(--accent-mid);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

body.light-mode header h1 {
    background: linear-gradient(90deg, #7c3aed, #8b5cf6, #d946ef);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Main Content */
main {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 2.5rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Sections */
.input-section,
.output-section,
.info-section {
    background: linear-gradient(180deg, rgba(20, 14, 28, 0.48), rgba(12, 8, 18, 0.6));
    backdrop-filter: blur(10px) saturate(140%);
    border-radius: 15px;
    padding: 30px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    animation: fadeIn 0.6s ease-out;
}

body.light-mode .input-section,
body.light-mode .output-section,
body.light-mode .info-section {
    background: linear-gradient(180deg, #ffffff, #f9f7ff);
    border: 1px solid rgba(124, 58, 237, 0.1);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Form Groups */
.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--accent-purple);
    font-size: 1rem;
}

body.light-mode .form-group label {
    color: #7c3aed;
}

textarea,
select {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--card-border);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(6, 6, 10, 0.72), rgba(8, 6, 14, 0.68));
    color: var(--text);
    font-family: 'Inter', Arial, sans-serif;
    font-size: 1rem;
    resize: vertical;
    transition: var(--transition);
    backdrop-filter: blur(6px) saturate(120%);
}

body.light-mode textarea,
body.light-mode select {
    background: var(--light-card);
    color: var(--light-text);
    border-color: rgba(124, 58, 237, 0.1);
}

textarea {
    min-height: 200px;
    line-height: 1.8;
}

textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(57, 217, 255, 0.2);
}

body.light-mode select:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.2);
}

/* Character Count */
.char-count {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--muted);
    display: flex;
    justify-content: flex-end;
}

body.light-mode .char-count {
    color: var(--light-muted);
}

#charCount {
    color: var(--accent-purple);
    font-weight: bold;
}

body.light-mode #charCount {
    color: #7c3aed;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 30px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    text-transform: none;
}

.btn-icon {
    font-size: 1.2rem;
}

.btn-text {
    display: inline;
}

.btn-primary {
    background: var(--accent-mid);
    color: #fff;
    box-shadow: 0 10px 36px rgba(124, 58, 237, 0.18);
}

body.light-mode .btn-primary {
    background: linear-gradient(90deg, #7c3aed, #8b5cf6);
    box-shadow: 0 10px 36px rgba(124, 58, 237, 0.12);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 2px solid var(--card-border);
}

body.light-mode .btn-secondary {
    color: var(--light-muted);
    border-color: rgba(124, 58, 237, 0.1);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

body.light-mode .btn-secondary:hover:not(:disabled) {
    border-color: #7c3aed;
    color: #7c3aed;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading Container */
.loading-container {
    background: linear-gradient(180deg, rgba(20, 14, 28, 0.48), rgba(12, 8, 18, 0.6));
    backdrop-filter: blur(10px) saturate(140%);
    border-radius: 15px;
    padding: 40px 30px;
    text-align: center;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
}

body.light-mode .loading-container {
    background: linear-gradient(180deg, #ffffff, #f9f7ff);
    border: 1px solid rgba(124, 58, 237, 0.1);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.08);
}

.loading-container.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--card-border);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loadingText {
    color: var(--muted);
    margin-bottom: 20px;
}

body.light-mode #loadingText {
    color: var(--light-muted);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 25px;
}

.stat {
    background: linear-gradient(180deg, rgba(10, 10, 14, 0.9), rgba(12, 8, 18, 0.9));
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
}

body.light-mode .stat {
    background: var(--light-card);
    border: 1px solid rgba(124, 58, 237, 0.1);
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

body.light-mode .stat-label {
    color: var(--light-muted);
}

.stat-value {
    display: block;
    color: var(--accent-cyan);
    font-size: 1.5rem;
    font-weight: bold;
}

body.light-mode .stat-value {
    color: #7c3aed;
}

/* Output Section */
.output-section {
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.output-section.hidden {
    display: none;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
    border-bottom: 2px solid var(--card-border);
    padding-bottom: 15px;
}

.output-header h2 {
    color: var(--accent-cyan);
    font-size: 1.5rem;
}

body.light-mode .output-header h2 {
    color: #7c3aed;
}

#summaryStats {
    color: var(--muted);
    font-size: 0.9rem;
}

body.light-mode #summaryStats {
    color: var(--light-muted);
}

.output-summary {
    background: linear-gradient(180deg, rgba(10, 10, 14, 0.9), rgba(12, 8, 18, 0.9));
    backdrop-filter: blur(6px);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 1px solid var(--card-border);
    line-height: 2;
    word-break: break-word;
    overflow-wrap: break-word;
}

body.light-mode .output-summary {
    background: var(--light-card);
    border: 1px solid rgba(124, 58, 237, 0.1);
}

.output-summary p {
    margin-bottom: 15px;
}

.output-summary ul {
    margin: 15px 0;
    padding-right: 20px;
}

.output-summary li {
    margin-bottom: 8px;
    padding: 8px 0;
    border-right: 3px solid var(--accent-cyan);
    padding-right: 12px;
}

body.light-mode .output-summary li {
    border-right-color: #7c3aed;
}

/* Output Actions */
.output-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.copy-feedback {
    color: var(--success-color);
    font-weight: bold;
    animation: fadeInOut 2s ease-in-out;
}

.copy-feedback.hidden {
    display: none;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
}

/* Info Section */
.info-section {
    margin-top: 20px;
}

.info-section h3 {
    color: var(--accent-cyan);
    margin-bottom: 20px;
    font-size: 1.3rem;
}

body.light-mode .info-section h3 {
    color: #7c3aed;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.info-card {
    background: linear-gradient(180deg, rgba(10, 10, 14, 0.9), rgba(12, 8, 18, 0.9));
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    border-left: 4px solid var(--accent-cyan);
}

body.light-mode .info-card {
    background: var(--light-card);
    border: 1px solid rgba(124, 58, 237, 0.1);
    border-left-color: #7c3aed;
}

.info-card h4 {
    color: var(--accent-cyan);
    margin-bottom: 12px;
}

body.light-mode .info-card h4 {
    color: #7c3aed;
}

.info-card ul {
    list-style: none;
    padding: 0;
}

.info-card li {
    padding: 8px 0;
    color: var(--muted);
    padding-right: 15px;
    position: relative;
}

body.light-mode .info-card li {
    color: var(--light-muted);
}

.info-card li:before {
    content: "✓";
    color: var(--accent-cyan);
    font-weight: bold;
    margin-right: 8px;
}

body.light-mode .info-card li:before {
    color: #7c3aed;
}

/* Footer */
footer {
    background: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding: 1.25rem 1rem;
    color: var(--muted);
    text-align: center;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

body.light-mode footer {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--light-muted);
}

footer a {
    color: var(--muted);
    text-decoration: none;
    opacity: 0.95;
}

body.light-mode footer a {
    color: var(--light-muted);
}

footer a:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

body.light-mode footer a:hover {
    color: #7c3aed;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .input-section,
    .output-section,
    .info-section {
        padding: 20px;
    }

    textarea {
        min-height: 150px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .output-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.3rem;
    }

    main {
        padding: 1.5rem 0.5rem;
    }

    .input-section,
    .output-section,
    .info-section {
        padding: 15px;
    }

    .output-summary {
        padding: 15px;
        line-height: 1.8;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Custom Select Component */
.custom-select {
    position: relative;
    display: block;
}

.custom-select__button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 15px;
    width: 100%;
    border-radius: 10px;
    border: 2px solid var(--card-border);
    background: linear-gradient(180deg, rgba(6, 6, 10, 0.72), rgba(8, 6, 14, 0.68));
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    font-family: 'Inter', Arial, sans-serif;
    box-shadow: 0 8px 26px rgba(2, 6, 23, 0.45);
    backdrop-filter: blur(6px) saturate(120%);
    cursor: pointer;
    transition: var(--transition);
    text-align: right;
}

body.light-mode .custom-select__button {
    background: linear-gradient(180deg, #ffffff, #f7f3ff);
    color: var(--light-text);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.08);
    border-color: rgba(124, 58, 237, 0.1);
}

.custom-select__button:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 10px 30px rgba(57, 217, 255, 0.15);
}

body.light-mode .custom-select__button:hover {
    border-color: #7c3aed;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.15);
}

.custom-select__label {
    flex: 1;
    text-align: right;
    line-height: 1.5;
}

.custom-select__chev {
    opacity: 0.9;
    width: 12px;
    height: 12px;
    color: rgba(255, 255, 255, 0.9);
    flex-shrink: 0;
}

body.light-mode .custom-select__chev {
    color: var(--light-text);
}

.custom-select__list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: linear-gradient(180deg, rgba(6, 6, 10, 0.96), rgba(8, 6, 14, 0.94));
    border-radius: 10px;
    padding: 0.2rem;
    border: 1px solid var(--card-border);
    min-width: 100%;
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.55);
    z-index: 100;
    display: none;
    list-style: none;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

body.light-mode .custom-select__list {
    background: #ffffff;
    color: var(--light-text);
    border: 1px solid rgba(124, 58, 237, 0.1);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.1);
}

.custom-select__list[aria-hidden="false"],
.custom-select__list.open {
    display: block;
}

.custom-select__list li {
    padding: 12px 15px;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: var(--transition);
    text-align: right;
}

body.light-mode .custom-select__list li {
    color: var(--light-text);
}

.custom-select__list li:hover {
    background: rgba(255, 255, 255, 0.03);
}

body.light-mode .custom-select__list li:hover {
    background: rgba(124, 58, 237, 0.08);
}

.custom-select__list li[aria-selected="true"] {
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
    color: #fff;
}

body.light-mode .custom-select__list li[aria-selected="true"] {
    background: linear-gradient(90deg, #7c3aed, #8b5cf6);
    color: #fff;
}

.custom-select__list li:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
}

/* Ensure brand header matches global site style (gradient clipped text) */
header nav .brand h1,
header .brand h1 {
    background: var(--accent-mid);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
    font-size: 1.05rem;
}
