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

:root {
    --primary-gold: #C9A961;
    --earth-bg: #E8DFD0;
    --text-dark: #a06704;
    --card-bg: #FFFFFF;
    --shadow: rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Tajawal', sans-serif;
    background-color: var(--earth-bg);
    color: var(--text-dark);
    direction: rtl;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    background: linear-gradient(135deg, var(--earth-bg) 0%, #D4C4B0 100%);
}

.site-logo {
    max-width: 300px;
    height: auto;
    margin-bottom: 0.5rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.site-subtitle {
    font-size: 1rem;
    color: var(--primary-gold);
    opacity: 0.9;
}

main {
    flex: 1;
    padding: 1rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 768px) {
    .container {
        grid-template-columns: 400px 1fr;
    }
}

.controls-section {
    background: white;
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: 0 4px 20px var(--shadow);
    height: fit-content;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.control-group i {
    color: var(--primary-gold);
    margin-left: 0.5rem;
}

.control-group input[type="text"],
.control-group input[type="password"],
.control-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #E8DFD0;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.control-group-inline {
    margin-bottom: 1rem;
}

.control-group-inline label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.control-group-inline select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #E8DFD0;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.control-group-inline select:focus {
    outline: none;
    border-color: var(--primary-gold);
}

.control-group input:focus,
.control-group textarea:focus {
    outline: none;
    border-color: var(--primary-gold);
}

.control-group small {
    display: block;
    margin-top: 0.25rem;
    color: #888;
    font-size: 0.85rem;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-gold) 0%, #B8964F 100%);
    color: white;
    margin-bottom: 1.5rem;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(201, 169, 97, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--primary-gold);
    margin-bottom: 0.75rem;
}

.btn-secondary:hover {
    background: var(--primary-gold);
    color: white;
}

.accordion {
    margin-bottom: 1rem;
}

.accordion-header {
    width: 100%;
    padding: 1rem;
    background: var(--earth-bg);
    border: none;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.3s;
}

.accordion-header:hover {
    background: #D4C4B0;
}

.accordion-header i {
    color: var(--primary-gold);
}

.accordion-header::after {
    content: '\f078';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    transition: transform 0.3s;
}

.accordion-header.active::after {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 1rem;
}

.accordion-content.active {
    max-height: 1000px;
    padding: 1rem;
}

.control-row {
    margin-bottom: 1rem;
}

.control-row label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.control-row input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--earth-bg);
    outline: none;
    -webkit-appearance: none;
}

.control-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-gold);
    cursor: pointer;
}

.control-row input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-gold);
    cursor: pointer;
    border: none;
}

.control-row input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid #E8DFD0;
    border-radius: 10px;
    cursor: pointer;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.action-buttons .btn-secondary {
    margin-bottom: 0;
}

.preview-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
}

.card-wrapper {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

.background-image {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}

.card-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    z-index: 1;
    pointer-events: none;
}

.card {
    position: relative;
    z-index: 2;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 8px 30px var(--shadow);
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.card-content {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    padding: 1rem 0;
}

#generatedText {
    font-size: 24px;
    line-height: 1.8;
    color: var(--text-dark);
    text-align: center;
    word-wrap: break-word;
    max-width: 100%;
}

.card-footer {
    border-top: 2px solid var(--earth-bg);
    padding-top: 1rem;
    text-align: center;
}

.designer-name {
    font-size: 0.9rem;
    color: var(--primary-gold);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    display: inline-block;
    background-color: rgba(255, 255, 255, 0);
    transition: all 0.3s;
}

footer {
    text-align: center;
    padding: 1.5rem;
    background: white;
    margin-top: 2rem;
}

.copyright {
    color: var(--primary-gold);
    font-weight: 500;
}

.loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loader.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader p {
    color: white;
    margin-top: 1rem;
    font-size: 1.2rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 767px) {
    .site-title {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.5rem;
        min-height: 300px;
    }

    #generatedText {
        font-size: 18px;
    }
}
