:root {
    --primary-green: #043927;
    /* أخضر زمردي داكن فاخر */
    --gold: #c5a059;
    /* ذهب ملكي */
    --gold-bright: #d4af37;
    --beige-soft: #f5f5dc;
    --bg-dark: #021a11;
    --glass: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --text-main: #1a1a1a;
    --shadow-lux: 0 20px 50px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at top right, rgba(4, 57, 39, 0.8), transparent),
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M50 0 L100 50 L50 100 L0 50 Z' fill='%23c5a059' fill-opacity='0.02'/%3E%3C/svg%3E");
    background-attachment: fixed;
    color: #fff;
    margin: 0;
    padding: 0;
}

.app-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 20px;
}

.main-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--gold);
}

.main-header .logo img {
    width: 100px;
    height: auto;
    margin-bottom: 10px;
    animation: golden-glow 4s infinite ease-in-out;
}

@keyframes golden-glow {

    0%,
    100% {
        filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 5px rgba(197, 160, 89, 0.4));
    }

    50% {
        filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 25px rgba(212, 175, 55, 0.8));
    }
}

.main-header h1 {
    color: var(--gold);
    font-family: 'Amiri', serif;
    font-size: 2.8rem;
    margin: 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.main-header p {
    color: #eee;
    font-weight: 500;
    margin-top: 5px;
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    max-width: 1300px;
    margin: 0 auto;
    flex: 1;
}

.editor-sidebar {
    background: var(--glass);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 25px;
    border-radius: 24px;
    box-shadow: var(--shadow-lux);
    width: 100%;
    max-width: 380px;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.control-group {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px dashed var(--border-color);
}

.control-group h3 {
    font-size: 1.1rem;
    color: var(--primary-green);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.design-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.design-preset {
    min-width: 0;
    border: 1px solid rgba(197, 160, 89, 0.45);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--primary-green);
    padding: 7px 5px 6px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.design-preset:hover,
.design-preset.active {
    transform: translateY(-2px);
    border-color: var(--gold-bright);
    box-shadow: 0 7px 16px rgba(4, 57, 39, 0.12);
}

.preset-preview {
    display: block;
    height: 38px;
    border-radius: 7px;
    margin-bottom: 5px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.preset-preview.emerald { background: linear-gradient(135deg, #043927 55%, #d4af37 56%, #043927 65%); }
.preset-preview.royal { background: linear-gradient(135deg, #111111 55%, #d4af37 56%, #3b2b12 65%); }
.preset-preview.modern { background: linear-gradient(135deg, #f4efe4 55%, #1f4d3d 56%, #f4efe4 65%); }
.preset-preview.cream { background: linear-gradient(135deg, #f5f5dc 55%, #043927 56%, #c5a059 65%); }
.preset-preview.daily { background: linear-gradient(135deg, #e9efe9 55%, #17684f 56%, #d4af37 65%); }
.preset-preview.red { background: linear-gradient(135deg, #4a0404 55%, #d4af37 56%, #7a1010 65%); }
.preset-preview.custom { background: linear-gradient(135deg, #315c75 55%, #ffffff 56%, #d4af37 65%); }

.occasion-presets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.occasion-preset {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(197, 160, 89, 0.4);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--primary-green);
    padding: 6px;
    cursor: pointer;
    font: 700 0.8rem 'Tajawal', sans-serif;
}

.occasion-preset:hover,
.occasion-preset.active {
    border-color: var(--gold-bright);
    box-shadow: 0 5px 12px rgba(4, 57, 39, 0.12);
}

.occasion-swatch {
    display: grid;
    place-items: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: #fff;
    font-size: 1.15rem;
}

.occasion-swatch.ramadan { background: #193958; color: #f5d477; }
.occasion-swatch.friday { background: #07533f; color: #e7c56e; }
.occasion-swatch.eid { background: #783e73; color: #f7d889; }
.occasion-swatch.morning { background: #d7a93e; color: #fffdf2; }
.occasion-swatch.evening { background: #34365f; color: #e9d8a2; }

.save-preset-button {
    width: 100%;
    min-height: 40px;
    margin-top: 9px;
    border: 1px dashed var(--gold);
    border-radius: 10px;
    background: rgba(197, 160, 89, 0.08);
    color: var(--primary-green);
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
}

.save-preset-button.saved {
    border-style: solid;
    background: rgba(4, 57, 39, 0.08);
}

.project-manager {
    margin: 16px 0;
    padding: 14px;
    border: 1px solid rgba(197, 160, 89, 0.35);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.45);
}

.project-manager label {
    margin-top: 8px;
}

.project-manager input,
.project-manager select {
    margin-bottom: 4px;
}

.project-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 6px;
}

.project-actions button {
    min-height: 38px;
    border: 1px solid var(--gold);
    border-radius: 9px;
    background: #fff;
    color: var(--primary-green);
    cursor: pointer;
    font: 700 0.95rem 'Tajawal', sans-serif;
}

.undo-button {
    width: 100%;
    min-height: 42px;
    margin: 12px 0;
    border: 1px solid rgba(4, 57, 39, 0.28);
    border-radius: 10px;
    background: #fff;
    color: var(--primary-green);
    cursor: pointer;
    font: 700 1rem 'Tajawal', sans-serif;
}

.undo-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.app-toast {
    position: fixed;
    z-index: 5000;
    inset-inline: 16px;
    bottom: 20px;
    width: fit-content;
    max-width: min(460px, calc(100vw - 32px));
    margin-inline: auto;
    padding: 12px 18px;
    border: 1px solid var(--gold);
    border-radius: 12px;
    background: #073b2c;
    color: #fff;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.app-toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.watermark-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    color: var(--primary-green);
    font-size: 0.82rem;
    font-weight: 700;
}

.watermark-lock {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(197, 160, 89, 0.16);
}

.preview-area {
    flex: 1;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-container {
    background: #fffdfa;
    /* مظهر رخامي */
    padding: 12px;
    border-radius: 20px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--gold);
    line-height: 0;
}

canvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.preview-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    color: #fff;
    font-weight: 700;
}

.preview-controls button {
    border: 1px solid var(--gold);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 9px 16px;
    cursor: pointer;
    font: inherit;
}

.preview-controls button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-download-secondary {
    margin-top: 10px;
    background: linear-gradient(135deg, #7a5a16 0%, #a67c20 100%);
}

.btn-download-secondary[hidden],
.preview-controls[hidden] {
    display: none;
}

label {
    display: block;
    margin-top: 15px;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 14px;
    margin: 5px 0 10px 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-sizing: border-box;
    font-family: inherit;
}

input[type="color"] {
    width: 100%;
    height: 45px;
    border: none;
    background: none;
    cursor: pointer;
}

textarea {
    height: 120px;
    resize: vertical;
    line-height: 1.6;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.1);
}

.btn-install {
    background: transparent;
    border: 2px solid var(--gold);
    color: var(--gold);
    padding: 15px;
    width: 100%;
    margin-bottom: 15px;
    clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-install:hover {
    background: rgba(197, 160, 89, 0.1);
    transform: translateY(-2px);
}

.btn-download {
    background: linear-gradient(135deg, var(--primary-green) 0%, #065f46 100%);
    border: 1px solid var(--gold);
    color: var(--white);
    padding: 20px;
    width: 100%;
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-download:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    background: var(--gold-bright);
}

/* تحسينات التجاوب للشاشات الصغيرة */
@media (max-width: 768px) {
    .app-wrapper {
        padding: 15px 10px;
    }

    .main-header h1 {
        font-size: 1.8rem;
    }

    .main-header .logo {
        font-size: 2.5rem;
    }

    .editor-sidebar {
        max-width: 100%;
        padding: 20px;
        box-sizing: border-box;
    }

    .input-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .main-content,
    .preview-area {
        width: 100%;
        min-width: 0;
    }

    .canvas-container {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        padding: 8px;
    }

    .canvas-container canvas {
        display: block;
        width: 100%;
        height: auto;
    }

    .library-tools {
        grid-template-columns: 1fr;
    }

    .library-header,
    .hadith-list {
        padding-inline: 16px;
    }

    .library-tools,
    .library-actions,
    .library-status {
        padding-inline: 16px;
    }

    .header-actions {
        width: 100%;
        align-items: stretch;
    }

    .header-actions .library-trigger,
    .header-actions .play-download {
        width: 100%;
        justify-content: center;
    }

    .header-actions .play-download {
        max-width: 190px;
        margin-inline: auto;
    }
}

@media (max-width: 420px) {
    .app-wrapper {
        padding-inline: 8px;
    }

    .editor-sidebar {
        padding: 14px;
    }

    .input-row {
        gap: 5px;
    }

    .design-presets,
    .occasion-presets {
        gap: 6px;
    }

    .design-preset {
        font-size: 0.72rem;
    }
}

.main-footer {
    text-align: center;
    margin-top: 60px;
    padding: 40px 20px;
    border-top: 1px solid rgba(197, 160, 89, 0.2);
    background: linear-gradient(to bottom, transparent, rgba(4, 57, 39, 0.2));
}

.footer-content p {
    font-family: 'Amiri', serif;
    font-size: 1.4rem;
    color: var(--gold);
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.seo-tagline {
    color: #aaa;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.seo-tagline span {
    color: var(--gold-bright);
    font-weight: 700;
    background: rgba(212, 175, 55, 0.1);
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(212, 175, 55, 0.3);
}


.helper-text {
    margin-top: 15px;
    color: #7f8c8d;
    font-style: italic;
    font-size: 0.9rem;
}

.library-trigger {
    margin: 0;
    min-height: 48px;
    padding: 10px 22px;
    border: 1px solid var(--gold);
    border-radius: 999px;
    background: rgba(212, 175, 55, 0.12);
    color: var(--gold-bright);
    font: 700 1rem 'Tajawal', sans-serif;
    cursor: pointer;
}

.library-trigger:hover {
    background: rgba(212, 175, 55, 0.22);
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.play-download {
    width: 190px;
    height: 58px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    box-sizing: border-box;
    padding: 7px 12px;
    border: 1px solid #aeb4b8;
    border-radius: 10px;
    background: linear-gradient(180deg, #18232b 0%, #070a0d 100%);
    color: #fff;
    text-decoration: none;
    direction: ltr;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.play-download:hover {
    transform: translateY(-3px);
    border-color: #fff;
    background: linear-gradient(180deg, #202f3a 0%, #0a0d10 100%);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.48);
}

.play-icon {
    display: grid;
    place-items: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
}

.play-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    direction: ltr;
    line-height: 1;
    white-space: nowrap;
}

.play-copy small {
    font-family: 'Tajawal', sans-serif;
    font-size: 0.68rem;
    color: #d7dde2;
}

.play-copy strong {
    margin-top: 4px;
    font-family: 'Tajawal', sans-serif;
    font-size: 1.25rem;
    line-height: 1;
    letter-spacing: 0.1px;
}

.library-modal {
    padding: 20px;
    box-sizing: border-box;
}

.library-panel {
    width: min(960px, 96vw);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fffdf7;
    border: 2px solid var(--gold);
    border-radius: 24px;
    color: var(--text-main);
    box-shadow: var(--shadow-lux);
}

.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px 14px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.35);
}

.library-header h2 {
    margin: 2px 0 0;
    color: var(--primary-green);
    font-family: 'Amiri', serif;
}

.library-kicker {
    color: var(--gold);
    font-size: 0.85rem;
}

.icon-button {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(4, 57, 39, 0.08);
    color: var(--primary-green);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.library-tools {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 8px 16px;
    padding: 16px 28px 8px;
}

.library-tools label {
    margin: 0 0 -4px;
}

.library-tools input,
.library-tools select {
    margin: 0;
    background: #fff;
}

.library-source-tabs {
    display: flex;
    gap: 8px;
    padding: 12px 28px 0;
}

.library-source {
    min-height: 40px;
    border: 1px solid var(--gold);
    border-radius: 999px;
    background: #fff;
    color: var(--primary-green);
    padding: 7px 16px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
}

.library-source.active {
    background: var(--primary-green);
    color: #fff;
}

.library-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 28px 14px;
}

.library-action {
    min-height: 38px;
    border: 1px solid var(--gold);
    border-radius: 999px;
    background: #fff;
    color: var(--primary-green);
    padding: 7px 12px;
    cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
}

.library-action.primary,
.library-action.active {
    background: var(--primary-green);
    color: #fff;
}

.library-status {
    padding: 8px 28px;
    color: #65736c;
    font-size: 0.9rem;
}

.hadith-list {
    overflow-y: auto;
    padding: 8px 28px 28px;
}

.hadith-card {
    border: 1px solid rgba(197, 160, 89, 0.35);
    border-radius: 16px;
    background: #fff;
    padding: 16px;
    margin-bottom: 12px;
}

.hadith-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--primary-green);
    font-size: 0.9rem;
}

.hadith-card-text {
    margin: 12px 0;
    color: #222;
    line-height: 2;
    white-space: pre-wrap;
}

.hadith-narrator {
    margin-top: 10px;
    color: #65736c;
    font-size: 0.85rem;
}

.hadith-reference {
    margin-top: 8px;
    color: #65736c;
    font-size: 0.82rem;
}

.hadith-actions {
    display: flex;
    gap: 8px;
}

.hadith-actions button {
    border: 1px solid var(--gold);
    border-radius: 8px;
    background: #fff;
    color: var(--primary-green);
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
}

.hadith-actions .favorite-button.active {
    border-color: #b82d45;
    background: #fff0f3;
    color: #b82d45;
}

.load-more-button {
    display: block;
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--gold);
    border-radius: 12px;
    background: var(--primary-green);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
}

/* تنسيقات نافذة التذكير */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    backdrop-filter: blur(10px);
}

.modal-content {
    background: var(--glass);
    padding: 40px;
    border-radius: 30px;
    text-align: center;
    max-width: 450px;
    width: 90%;
    border: 2px solid var(--gold);
    box-shadow: var(--shadow-lux);
    animation: modalSlideUp 0.5s ease-out;
    color: var(--text-main);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.modal-content h2 {
    color: var(--primary-green);
    font-family: 'Amiri', serif;
    margin-bottom: 15px;
    font-size: 2rem;
}