/* ========================================== */
/* Hala Tap - Premium Minimalist Theme       */
/* ========================================== */

:root {
    /* Harmony Color Palette */
    --bg-main: radial-gradient(circle at top, #ffffff 0%, #f4f6f9 100%);
    --bg-card: #ffffff;
    --bg-drawer: rgba(255, 255, 255, 0.95);
    
    --border-soft: rgba(0, 0, 0, 0.04);
    --border-active: #d4af37;
    
    --text-main: #1a1a24;
    --text-secondary: #7a7c85;
    --text-muted: #a0a2ab;
    
    --color-gold: #c5a059;
    --color-cyan: #87afd3;
    --color-danger: #ff5f56;
    --color-success: #27c93f;
    
    --font-arabic: 'Cairo', sans-serif;
    --font-english: 'Inter', sans-serif;
    
    --shadow-card: 0 20px 40px rgba(0, 0, 0, 0.06);
    --shadow-toolbar: 0 10px 30px rgba(0, 0, 0, 0.06);
    --shadow-active: 0 8px 24px rgba(197, 160, 89, 0.15);
    
    --transition-premium: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset and Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-main);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-arabic);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    line-height: 1.6;
    padding: 0;
    transition: var(--transition-premium);
    -webkit-font-smoothing: antialiased;
}

/* App Layout Structure */
.app-container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 7.5rem; /* Space for floating bottom toolbar */
}

/* ---- Hala Tap Premium Header ---- */
.hala-header {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2.5rem 1.5rem 1rem 1.5rem;
    position: relative;
    z-index: 10;
}

.hala-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
}

.logo-image {
    height: 38px;
    object-fit: contain;
    transition: transform 0.4s ease;
}

.hala-logo:hover .logo-image {
    transform: scale(1.05);
}

/* ---- Floating Circular Language Button ---- */
.btn-lang-floating {
    position: absolute;
    top: 2rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 20;
    color: var(--text-main);
    font-size: 1.25rem;
    transition: var(--transition-premium);
}

.btn-lang-floating:hover {
    transform: scale(1.06) translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.btn-lang-floating:active {
    transform: scale(0.96);
}

/* ---- Main Card Viewport ---- */
.app-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 1.5rem;
}

.card-viewport {
    width: 100%;
    position: relative;
    border-radius: 28px;
    background: var(--bg-card);
    box-shadow: 0 25px 55px rgba(0, 0, 0, 0.06);
    transition: var(--transition-premium);
}

.card-viewport:hover {
    transform: translateY(-2px);
    box-shadow: 0 30px 65px rgba(0, 0, 0, 0.09);
}

.card-preview-wrapper {
    width: 100%;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.02);
    container-type: inline-size;
}

.card-aspect-ratio-box {
    width: 100%;
    padding-top: 125%; /* 4:5 Aspect Ratio */
    position: relative;
}

.card-preview-core {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-preview-bg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Dynamic Arabic/English Name Overlay */
.card-preview-name-overlay {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 83.5%;
    height: 8%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    
    font-family: 'Cairo', 'Tahoma', var(--font-arabic);
    color: var(--color-cyan);
    font-weight: 700;
    font-size: clamp(12px, 4.65cqw, 36px); /* Adaptive card relative font-size */
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    white-space: nowrap;
}

body.ltr-mode .card-preview-name-overlay {
    font-family: 'Tahoma', var(--font-english);
}

/* Loading overlay inside card */
.canvas-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-radius: 28px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.25rem;
}

.pulsing-ring {
    width: 48px;
    height: 48px;
    border: 3.5px solid rgba(197, 160, 89, 0.1);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

.canvas-loading p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ---- Floating Bottom Toolbar ---- */
.bottom-toolbar-container {
    position: fixed;
    bottom: 2.25rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    z-index: 90;
    pointer-events: none;
    padding: 0 1.5rem;
}

.bottom-toolbar {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(24px) saturate(190%);
    -webkit-backdrop-filter: blur(24px) saturate(190%);
    padding: 0.6rem;
    border-radius: 40px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.6);
    pointer-events: auto;
    width: 100%;
    max-width: 380px;
    transform: translateY(0);
    transition: var(--transition-premium);
}

.btn-toolbar-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg-card);
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    color: var(--text-main);
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-premium);
}

.btn-toolbar-circle:hover {
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.07);
    color: var(--color-gold);
}

.btn-toolbar-circle:active {
    transform: translateY(0) scale(0.96);
}

.toolbar-input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.toolbar-input-wrapper input {
    width: 100%;
    height: 52px;
    border-radius: 26px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0 2.75rem 0 1.25rem; /* Default RTL Arabic - padding right for icon */
    font-family: inherit;
    transition: var(--transition-premium);
    text-align: right;
}

/* LTR override for the input padding/text */
body.ltr-mode .toolbar-input-wrapper input {
    padding: 0 1.25rem 0 2.75rem; /* LTR English - padding left for icon */
    text-align: left;
}

.toolbar-input-wrapper input:focus {
    outline: none;
    border-color: rgba(197, 160, 89, 0.4);
    box-shadow: 0 0 15px rgba(197, 160, 89, 0.08);
    background: var(--bg-card);
}

.toolbar-input-icon {
    position: absolute;
    top: 50%;
    right: 1.15rem; /* RTL Default - icon on the right */
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.15rem;
    pointer-events: none;
    transition: var(--transition-premium);
}

/* LTR override for the icon */
body.ltr-mode .toolbar-input-icon {
    left: 1.15rem; /* LTR English - icon on the left */
    right: auto;
}

.toolbar-input-wrapper input:focus + .toolbar-input-icon {
    color: var(--color-gold);
}

/* ---- Customization Bottom Sheet Drawer ---- */
.custom-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.custom-drawer.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer-content {
    width: 100%;
    max-width: 440px;
    background: var(--bg-drawer);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top-left-radius: 32px;
    border-top-right-radius: 32px;
    box-shadow: 0 -15px 40px rgba(0, 0, 0, 0.08);
    padding: 2.25rem 1.75rem;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.65rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.custom-drawer.open .drawer-content {
    transform: translateY(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.drawer-header-titles {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.drawer-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    color: var(--text-main);
}

.drawer-header h2 i {
    margin-left: 0.65rem;
    color: var(--color-gold);
}

.panel-subtitle {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.btn-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    color: var(--text-main);
    font-size: 1.15rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-premium);
}

.btn-drawer-close:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.05);
}

.btn-drawer-close:active {
    transform: scale(0.95);
}

/* ---- Input Customization Elements ---- */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.input-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.label-text {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
}

.required-dot {
    color: var(--color-gold);
    margin-right: 0.2rem;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

.input-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.02);
    border-radius: 14px;
    padding: 0.95rem 2.85rem 0.95rem 1.25rem;
    color: var(--text-main);
    font-family: var(--font-arabic);
    font-size: 1.05rem;
    font-weight: 600;
    transition: var(--transition-premium);
    text-align: right;
}

.input-wrapper input:focus {
    outline: none;
    border-color: rgba(197, 160, 89, 0.4);
    box-shadow: 0 0 15px rgba(197, 160, 89, 0.08);
    background: var(--bg-card);
}

.input-icon {
    position: absolute;
    top: 50%;
    right: 1.15rem;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.15rem;
    pointer-events: none;
    transition: var(--transition-premium);
}

.input-wrapper input:focus + .input-icon {
    color: var(--color-gold);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    color: var(--text-secondary);
    padding: 0 0.25rem;
}

/* Card Selection grid options */
.image-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.image-option-card {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.02);
    border-radius: 18px;
    padding: 0.6rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    position: relative;
    transition: var(--transition-premium);
}

.image-option-card:hover {
    background: rgba(0, 0, 0, 0.04);
    transform: translateY(-2px);
}

.image-option-card.active {
    border-color: var(--border-active);
    background: rgba(197, 160, 89, 0.04);
    box-shadow: var(--shadow-active);
}

.option-preview-container {
    width: 100%;
    aspect-ratio: 16/11;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

.opt-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-premium);
}

.image-option-card:hover .opt-preview-img {
    transform: scale(1.05);
}

.option-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.image-option-card.active .option-title {
    color: var(--color-gold);
}

.selection-indicator {
    position: absolute;
    top: 0.45rem;
    left: 0.45rem;
    color: var(--text-muted);
    font-size: 1.15rem;
    opacity: 0;
    transition: var(--transition-premium);
}

.image-option-card.active .selection-indicator {
    opacity: 1;
    color: var(--color-gold);
}

.action-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.05);
    margin: 0.25rem 0;
}

/* Downloads Section */
.downloads-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.downloads-section .section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.downloads-section .section-title i {
    margin-left: 0.55rem;
    color: var(--color-gold);
}

.btn-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn {
    width: 100%;
    padding: 0.95rem;
    border-radius: 14px;
    font-family: var(--font-arabic);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.65rem;
    border: 1px solid transparent;
    transition: var(--transition-premium);
    position: relative;
    overflow: hidden;
}

.btn-premium {
    background: var(--bg-card);
    border-color: rgba(0, 0, 0, 0.04);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.btn-premium:hover {
    background: #f8fafc;
    transform: translateY(-1.5px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
}

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

.btn-image:hover {
    border-color: rgba(135, 175, 211, 0.4);
    color: var(--color-cyan);
}

.btn-pdf:hover {
    border-color: rgba(197, 160, 89, 0.4);
    color: var(--color-gold);
}

.btn-pptx:hover {
    border-color: rgba(255, 95, 86, 0.4);
    color: #e04a43;
}

.icon-btn {
    font-size: 1.1rem;
}

.btn-loader {
    position: absolute;
    left: 1.25rem;
    font-size: 1rem;
}

/* ---- QR Code Modal Dialog ---- */
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1001;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.qr-modal.open {
    opacity: 1;
    pointer-events: auto;
}

.qr-modal-content {
    background: var(--bg-card);
    border-radius: 28px;
    padding: 2rem;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.qr-modal.open .qr-modal-content {
    transform: scale(1);
}

.qr-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.qr-modal-header h4 {
    font-size: 1.05rem;
    font-weight: 700;
}

.btn-modal-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.04);
    border: none;
    color: var(--text-main);
    font-size: 0.95rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-premium);
}

.btn-modal-close:hover {
    background: rgba(0, 0, 0, 0.08);
}

.qr-modal-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.45;
}

.qr-code-container {
    width: 210px;
    height: 210px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8fafc;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.03);
    overflow: hidden;
}

.qr-code-img {
    width: 190px;
    height: 190px;
    object-fit: contain;
}

/* ========================================== */
/* LTR (English) Mode Overrides             */
/* ========================================== */

body.ltr-mode {
    direction: ltr;
    font-family: var(--font-english);
}

body.ltr-mode .btn-lang-floating {
    left: 1.5rem;
    right: auto;
}

body.ltr-mode .hala-header {
    direction: ltr;
}

body.ltr-mode .drawer-header h2 i {
    margin-right: 0.65rem;
    margin-left: 0;
}

body.ltr-mode .input-wrapper input {
    padding: 0.95rem 1.25rem 0.95rem 2.85rem;
    text-align: left;
}

body.ltr-mode .input-icon {
    left: 1.15rem;
    right: auto;
}

body.ltr-mode .btn {
    font-family: var(--font-english);
}

body.ltr-mode .btn-loader {
    left: auto;
    right: 1.25rem;
}

body.ltr-mode .downloads-section .section-title i {
    margin-right: 0.55rem;
    margin-left: 0;
}

body.ltr-mode .selection-indicator {
    right: 0.45rem;
    left: auto;
}

/* Utility Hidden elements */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes spin {
    to { transform: rotate(-360deg); }
}
