:root {
    /* Primary Colors - Vibrant Purple Gradient */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --primary-hover: #5568d3;
    --primary-light: #818cf8;
    --accent-color: #f59e0b;
    --accent-gradient: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);

    /* Background Colors */
    --bg-gradient: linear-gradient(to bottom right, #faf5ff, #ede9fe, #ddd6fe);
    --bg-color: #faf5ff;
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.25);

    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Utility Colors */
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(102, 126, 234, 0.08);
    --shadow-md: 0 4px 16px rgba(102, 126, 234, 0.12);
    --shadow-lg: 0 10px 40px rgba(102, 126, 234, 0.15);
    --shadow-xl: 0 20px 50px rgba(102, 126, 234, 0.2);
    --glow: 0 0 20px rgba(102, 126, 234, 0.3);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Typography */
    --font-main: 'Tajawal', 'Cairo', sans-serif;

    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

:root.dark-theme {
    /* Primary Colors tuned for dark backgrounds */
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --primary-color: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-light: #c4b5fd;
    --accent-color: #fbbf24;
    --accent-gradient: linear-gradient(135deg, #f97316 0%, #ec4899 100%);

    /* Background Colors (Dark) */
    --bg-gradient: radial-gradient(circle at top, #020617 0%, #020617 45%, #000 100%);
    --bg-color: #020617;
    --card-bg: rgba(15, 23, 42, 0.96);
    --glass-bg: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(148, 163, 184, 0.4);

    /* Text Colors (Light on dark) */
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* Shadows (deeper for dark) */
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.6);
    --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.85);
    --shadow-lg: 0 18px 45px rgba(15, 23, 42, 0.95);
    --shadow-xl: 0 25px 65px rgba(0, 0, 0, 0.98);
    --glow: 0 0 30px rgba(129, 140, 248, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    direction: rtl;
    min-height: 100vh;
}

/* Presets Section */
.presets-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.template-search {
    margin-bottom: 1rem;
}

.template-search input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.6);
    font-family: var(--font-main);
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.9);
    transition: var(--transition-smooth);
}

.template-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    background: #ffffff;
}

.presets-section h3 {
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.2rem;
}

.presets-category {
    margin-bottom: 1.5rem;
}

.presets-category h4 {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
    opacity: 0.8;
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.preset-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.preset-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* ==================== HEADER ==================== */
.app-header {
    text-align: center;
    margin-bottom: 50px;
    padding: 60px 30px;
    background: var(--primary-gradient);
    color: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
    animation: fadeInDown 0.8s ease-out;
}

.app-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.app-header h1 {
    font-size: 3rem;
    margin-bottom: 15px;
    font-weight: 800;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.app-header p {
    opacity: 0.95;
    font-size: 1.2rem;
    position: relative;
    z-index: 1;
}

.theme-toggle {
    position: absolute;
    top: 18px;
    left: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(15, 23, 42, 0.18);
    color: #f9fafb;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
    z-index: 2;
}

.theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    background: rgba(15, 23, 42, 0.3);
}

.theme-toggle-icon {
    font-size: 1.1rem;
}

.theme-toggle-label {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .theme-toggle {
        top: 14px;
        left: 16px;
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .theme-toggle-label {
        display: none;
    }
}

html.dark-theme body {
    background: var(--bg-gradient);
    color: var(--text-primary);
}

html.dark-theme .theme-toggle {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(148, 163, 184, 0.7);
    color: #e5e7eb;
}

html.dark-theme .app-header {
    background: radial-gradient(circle at top, #1f2937 0%, #020617 60%, #000 100%);
    color: #f9fafb;
}

html.dark-theme .app-header p {
    color: var(--text-secondary);
}

html.dark-theme .presets-section {
    background: rgba(15, 23, 42, 0.82);
    border-color: rgba(148, 163, 184, 0.35);
}

html.dark-theme .control-column,
html.dark-theme .result-card,
html.dark-theme .history-section {
    background: var(--card-bg);
    border-color: rgba(148, 163, 184, 0.35);
}

html.dark-theme select,
html.dark-theme input[type="text"],
html.dark-theme textarea {
    background-color: rgba(15, 23, 42, 0.96);
    color: var(--text-primary);
    border-color: rgba(148, 163, 184, 0.45);
}

html.dark-theme select:focus,
html.dark-theme input[type="text"]:focus,
html.dark-theme textarea:focus {
    background-color: rgba(15, 23, 42, 1);
    box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.35);
}

html.dark-theme .template-search input {
    background-color: rgba(15, 23, 42, 0.96);
    color: var(--text-primary);
    border-color: rgba(148, 163, 184, 0.45);
}

html.dark-theme .pos-select {
    background: linear-gradient(135deg, #0f172a, #020617);
    color: var(--text-secondary);
}

html.dark-theme .preset-btn {
    background: rgba(15, 23, 42, 0.96);
    border-color: rgba(148, 163, 184, 0.4);
}

html.dark-theme .preset-btn .text {
    color: var(--text-primary);
}

html.dark-theme .prompt-box {
    background: radial-gradient(circle at top, #020617 0%, #020617 45%, #020617 100%);
    border-color: rgba(148, 163, 184, 0.45);
    color: var(--text-primary);
}

html.dark-theme .carousel-slide {
    background: linear-gradient(135deg, #020617, #0b1120);
    border-color: rgba(148, 163, 184, 0.4);
}

html.dark-theme .history-item {
    background: linear-gradient(135deg, #020617, #0b1120);
    border-color: transparent;
}

html.dark-theme .history-item:hover {
    border-color: var(--primary-light);
}

html.dark-theme .toast {
    background: linear-gradient(135deg, #020617, #111827);
}

html.dark-theme .app-footer {
    color: var(--text-secondary);
}

html.dark-theme .app-footer a:hover {
    opacity: 1;
}

/* ==================== PRESETS ==================== */
.presets-section {
    margin-bottom: 40px;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.category-label {
    font-size: 1.1rem;
    margin-top: 30px;
    margin-bottom: 15px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition-smooth);
}

.category-label:first-of-type {
    margin-top: 0;
}

.category-label:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    transform: translateX(-3px);
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.preset-btn {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px 15px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.preset-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: var(--transition-smooth);
}

.preset-btn:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.preset-btn:hover::before {
    opacity: 0.1;
}

.preset-btn .icon {
    font-size: 2rem;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.preset-btn .text {
    font-size: 0.95rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
    color: var(--text-primary);
}

/* ==================== CONTROLS ==================== */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.control-column {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--glass-border);
    transition: var(--transition-smooth);
}

.control-column:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.form-group {
    margin-bottom: 24px;
}

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

label {
    display: block;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

select,
input[type="text"],
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(102, 126, 234, 0.15);
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: var(--transition-smooth);
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
}

select:hover,
input:hover,
textarea:hover {
    border-color: rgba(102, 126, 234, 0.3);
}

select:focus,
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background-color: #ffffff;
}

textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.6;
}

.custom-input {
    margin-top: 10px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none;
}

.pos-select {
    margin-top: 8px;
    font-size: 0.9rem;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: var(--radius-sm);
}

/* ==================== ACTIONS ==================== */
.actions-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 50px;
    flex-wrap: wrap;
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.action-btn {
    padding: 16px 40px;
    border: none;
    border-radius: 50px;
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition-bounce);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.action-btn:hover::before {
    transform: translateX(100%);
}

.action-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--shadow-xl);
}

.action-btn:active {
    transform: translateY(-1px) scale(1.02);
}

.action-btn.primary {
    background: var(--primary-gradient);
    color: white;
}

.action-btn.secondary {
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    color: var(--text-primary);
}

.action-btn.danger {
    background: #ffffff;
    color: var(--danger-color);
    border: 2px solid var(--danger-color);
}

.action-btn.danger:hover {
    background: var(--danger-color);
    color: white;
}

/* ==================== RESULTS ==================== */
.results-section {
    display: grid;
    grid-template-columns: 2.5fr 1fr;
    gap: 24px;
    animation: fadeInUp 0.8s ease-out 0.8s both;
}

@media (max-width: 968px) {
    .results-section {
        grid-template-columns: 1fr;
    }
}

.result-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    padding: 32px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    transition: var(--transition-smooth);
}

.result-card:hover {
    box-shadow: var(--shadow-xl);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
}

.result-header h3 {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.3rem;
    font-weight: 800;
}

.copy-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: var(--font-main);
    font-weight: 700;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.prompt-box {
    background: linear-gradient(135deg, #faf5ff, #f3f4f6);
    padding: 24px;
    border-radius: var(--radius-md);
    min-height: 180px;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
    border: 2px solid rgba(102, 126, 234, 0.15);
    transition: var(--transition-smooth);
}

.carousel-slides {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(102, 126, 234, 0.15);
    display: none;
}

.carousel-slide {
    background: linear-gradient(135deg, #faf5ff, #f9fafb);
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.3);
    padding: 12px 16px;
    margin-bottom: 12px;
}

.carousel-slide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.carousel-slide-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--primary-color);
}

.carousel-slide-text {
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.slide-copy-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.prompt-box:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.prompt-box:empty::before {
    content: 'سيظهر النص هنا...';
    color: var(--text-muted);
    font-style: italic;
}

/* ==================== HISTORY ==================== */
.history-section {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    padding: 24px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--glass-border);
    max-height: 600px;
    overflow-y: auto;
}

.history-section::-webkit-scrollbar {
    width: 8px;
}

.history-section::-webkit-scrollbar-track {
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
}

.history-section::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.history-section h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-weight: 700;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
    padding-bottom: 12px;
}

.history-item {
    background: linear-gradient(135deg, #faf5ff, #ffffff);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition-smooth);
}

.history-item:hover {
    border-color: var(--primary-color);
    transform: translateX(-5px);
    box-shadow: var(--shadow-md);
}

.history-item .time {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.history-item .preview {
    font-size: 0.9rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

/* ==================== TOAST ==================== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1e293b, #334155);
    color: white;
    padding: 16px 32px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-smooth);
    z-index: 1000;
    box-shadow: var(--shadow-xl);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    bottom: 40px;
    animation: bounce 0.5s ease-out;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

/* ==================== FOOTER ==================== */
.app-footer {
    text-align: center;
    margin-top: 60px;
    padding: 30px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.app-footer a {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    font-weight: 700;
    transition: var(--transition-smooth);
}

.app-footer a:hover {
    opacity: 0.8;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 2rem;
    }

    .app-header p {
        font-size: 1rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    background: linear-gradient(135deg, #faf5ff, #f3f4f6);
    padding: 24px;
    border-radius: var(--radius-md);
    min-height: 180px;
    white-space: pre-wrap;
    font-family: 'Courier New',
    monospace;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
    border: 2px solid rgba(102, 126, 234, 0.15);
    transition: var(--transition-smooth);
}

.prompt-box:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.prompt-box:empty::before {
    content: 'سيظهر النص هنا...';
    color: var(--text-muted);
    font-style: italic;
}

/* ==================== HISTORY ==================== */
.history-section {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    padding: 24px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--glass-border);
    max-height: 600px;
    overflow-y: auto;
}

.history-section::-webkit-scrollbar {
    width: 8px;
}

.history-section::-webkit-scrollbar-track {
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
}

.history-section::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.history-section h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-weight: 700;
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
    padding-bottom: 12px;
}

.history-item {
    background: linear-gradient(135deg, #faf5ff, #ffffff);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition-smooth);
}

.history-item:hover {
    border-color: var(--primary-color);
    transform: translateX(-5px);
    box-shadow: var(--shadow-md);
}

.history-item .time {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.history-item .preview {
    font-size: 0.9rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

/* ==================== TOAST ==================== */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #1e293b, #334155);
    color: white;
    padding: 16px 32px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-smooth);
    z-index: 1000;
    box-shadow: var(--shadow-xl);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    bottom: 40px;
    animation: bounce 0.5s ease-out;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

/* ==================== FOOTER ==================== */
.app-footer {
    text-align: center;
    margin-top: 60px;
    padding: 30px;
    color: var(--text-secondary);
    font-size: 1rem;
}

.app-footer a {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    font-weight: 700;
    transition: var(--transition-smooth);
}

.app-footer a:hover {
    opacity: 0.8;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 2rem;
    }

    .app-header p {
        font-size: 1rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .action-btn {
        padding: 14px 30px;
        font-size: 1rem;
    }

    .presets-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* ==================== AI CUSTOM BUTTON STYLING ==================== */
.ai-category {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-left: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }

    50% {
        box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
    }
}

.ai-btn {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid #ffffff;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    transform: scale(1.05);
    overflow: visible;
}

.ai-btn::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
}

.ai-btn:hover {
    transform: translateY(-8px) scale(1.08);
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
    border-color: #ffd700;
}

.ai-btn .icon {
    color: white;
}

.ai-btn .text {
    color: white;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.ai-icon {
    font-size: 2.2rem !important;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

.badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ff4757, #ff6348);
    color: white;
    font-size: 10px;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 800;
    box-shadow: 0 3px 12px rgba(255, 71, 87, 0.6);
    letter-spacing: 0.5px;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {

    0%,
    /* ==================== TOAST ==================== */
    .toast {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: linear-gradient(135deg, #1e293b, #334155);
        color: white;
        padding: 16px 32px;
        border-radius: 50px;
        font-size: 1rem;
        font-weight: 700;
        opacity: 0;
        visibility: hidden;
        transition: var(--transition-smooth);
        z-index: 1000;
        box-shadow: var(--shadow-xl);
    }

    .toast.show {
        opacity: 1;
        visibility: visible;
        bottom: 40px;
        animation: bounce 0.5s ease-out;
    }

    @keyframes bounce {

        0%,
        100% {
            transform: translateX(-50%) translateY(0);
        }

        50% {
            transform: translateX(-50%) translateY(-10px);
        }
    }

    /* ==================== FOOTER ==================== */
    .app-footer {
        text-align: center;
        margin-top: 60px;
        padding: 30px;
        color: var(--text-secondary);
        font-size: 1rem;
    }

    .app-footer a {
        background: var(--primary-gradient);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        text-decoration: none;
        font-weight: 700;
        transition: var(--transition-smooth);
    }

    .app-footer a:hover {
        opacity: 0.8;
    }

    /* ==================== ANIMATIONS ==================== */
    @keyframes fadeInDown {
        from {
            opacity: 0;
            transform: translateY(-30px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(30px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* ==================== RESPONSIVE ==================== */
    @media (max-width: 768px) {
        .app-header h1 {
            font-size: 2rem;
        }

        .app-header p {
            font-size: 1rem;
        }

        .controls-grid {
            grid-template-columns: 1fr;
        }

        .action-btn {
            padding: 14px 30px;
            font-size: 1rem;
        }

        .presets-grid {
            grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        }
    }

    /* ==================== AI CUSTOM BUTTON STYLING ==================== */
    .ai-category {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border-left: none;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
        animation: shimmer 3s ease-in-out infinite;
    }

    @keyframes shimmer {

        0%,
        100% {
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
        }

        50% {
            box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
        }
    }

    .ai-btn {
        position: relative;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border: 2px solid #ffffff;
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
        transform: scale(1.05);
        overflow: visible;
    }

    .ai-btn::before {
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
    }

    .ai-btn:hover {
        transform: translateY(-8px) scale(1.08);
        box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
        border-color: #ffd700;
    }

    .ai-btn .icon {
        color: white;
    }

    .ai-btn .text {
        color: white;
        font-weight: 800;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .ai-icon {
        font-size: 2.2rem !important;
        animation: pulse 2s ease-in-out infinite;
    }

    @keyframes pulse {

        0%,
        100% {
            transform: scale(1);
        }

        50% {
            transform: scale(1.15);
        }
    }

    .badge {
        position: absolute;
        top: -8px;
        right: -8px;
        background: linear-gradient(135deg, #ff4757, #ff6348);
        color: white;
        font-size: 10px;
        padding: 4px 10px;
        border-radius: 12px;
        font-weight: 800;
        box-shadow: 0 3px 12px rgba(255, 71, 87, 0.6);
        letter-spacing: 0.5px;
        animation: badgePulse 2s ease-in-out infinite;
    }

    @keyframes badgePulse {

        0%,
        100% {
            transform: scale(1);
            box-shadow: 0 3px 12px rgba(255, 71, 87, 0.6);
        }

        50% {
            transform: scale(1.1);
            box-shadow: 0 5px 20px rgba(255, 71, 87, 0.8);
        }
    }

    /* ==================== AI INTRO SECTION (مختصر) ==================== */
    .ai-intro-section {
        margin-bottom: 15px;
        padding: 15px;
        background: rgba(255, 255, 255, 0.5);
        border-radius: 12px;
        animation: fadeInUp 0.8s ease-out 0.2s both;
    }

    .ai-intro-section .ai-badge {
        display: inline-block;
        background: var(--primary-gradient);
        color: white;
        padding: 4px 12px;
        border-radius: 20px;
        font-size: 0.75rem;
        font-weight: 600;
        margin-bottom: 8px;
    }

    .ai-intro-section h2 {
        font-size: 1.1rem;
        margin-bottom: 5px;
        color: var(--primary-color);
    }

    .ai-intro-section>p {
        font-size: 0.85rem;
        color: var(--text-secondary);
        margin-bottom: 10px;
    }

    .features-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        margin-bottom: 10px;
    }

    .feature-card {
        text-align: center;
        padding: 8px;
        background: rgba(255, 255, 255, 0.7);
        border-radius: 8px;
    }

    .feature-icon {
        font-size: 1.2rem;
        display: block;
        margin-bottom: 4px;
    }

    .feature-card h4 {
        font-size: 0.75rem;
        margin-bottom: 2px;
        color: var(--text-primary);
    }

    .feature-card p {
        font-size: 0.7rem;
        color: var(--text-muted);
    }

    .how-it-works {
        margin-top: 10px;
    }

    .how-it-works h3 {
        font-size: 0.9rem;
        margin-bottom: 8px;
        color: var(--text-secondary);
    }

    .steps-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 5px;
    }

    .step {
        flex: 1;
        text-align: center;
        padding: 6px;
        background: rgba(255, 255, 255, 0.6);
        border-radius: 8px;
    }

    .step-number {
        display: inline-block;
        width: 24px;
        height: 24px;
        line-height: 24px;
        border-radius: 50%;
        background: var(--primary-gradient);
        color: white;
        font-weight: 700;
        font-size: 0.8rem;
        margin-bottom: 4px;
    }

    .step p {
        font-size: 0.65rem;
        color: var(--text-secondary);
    }

    .step-line {
        width: 20px;
        height: 2px;
        background: linear-gradient(to right, var(--primary-color), transparent);
        flex-shrink: 0;
    }

    /* ==================== FULL WIDTH COLUMN ==================== */
    .control-column.full-width {
        grid-column: 1 / -1;
    }

    .control-column.full-width .form-group {
        margin-bottom: 24px;
    }

    .control-column.full-width textarea {
        font-size: 1.1rem;
        font-weight: 600;
    }