/* Global resets & variables for Light Mode */
:root {
    --bg-light-1: #eef6fa;
    --bg-light-2: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.8);
    --inner-border: rgba(18, 72, 115, 0.1);

    --color-primary: #124873;
    --color-secondary: #3ea2c0;
    --color-accent: #72bcd4;

    --text-main: #124873;
    --text-muted: #546e7a;

    --font-ui: 'Cairo', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-ui);
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Base Body Styling */
body {
    background-color: var(--bg-light-1);
    color: var(--text-main);
    min-height: 100vh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background animated cloud-like glows for Light Mode */
.glow-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, var(--bg-light-2) 0%, var(--bg-light-1) 100%);
}

.glow-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.45;
    animation: float 25s infinite alternate;
}

.glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #d4edf6 0%, transparent 70%);
    top: -150px;
    right: -100px;
}

.glow-2 {
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, #e3eff6 0%, transparent 70%);
    bottom: -200px;
    left: -150px;
    animation-delay: -5s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(60px, 40px) scale(1.08);
    }
}

/* Application Container */
.app-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    justify-content: space-between;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 2.2rem;
    position: relative;
}

.logo-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.8rem;
}

.app-logo {
    height: 100px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(18, 72, 115, 0.12));
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.app-logo:hover {
    transform: scale(1.08) rotate(1deg);
}

.app-title {
    font-size: 2.3rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 0.4rem;
    text-shadow: 0 2px 5px rgba(18, 72, 115, 0.05);
}

.app-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 600;
}

.app-subtitle .highlight {
    color: var(--color-secondary);
    font-weight: 800;
    position: relative;
    display: inline-block;
}

.app-subtitle .highlight::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(62, 162, 192, 0.15);
    border-radius: 2px;
    z-index: -1;
}

/* Main Grid Layout */
.app-main {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 2.5rem;
    align-items: center;
    margin-bottom: 2rem;
}

@media (max-width: 968px) {
    .app-main {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

/* Font Definitions */
@font-face {
    font-family: 'Thmanyah Serif Display';
    src: url('fonts/thmanyahserifdisplay-Bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* Live Preview Section */
.preview-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.card-preview-wrapper {
    width: 100%;
    max-width: 420px;
    perspective: 1000px;
}

.card-frame {
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    padding: 0.8rem;
    box-shadow: 0 20px 45px rgba(18, 72, 115, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card-frame:hover {
    transform: translateY(-5px);
}

.card-canvas-container {
    width: 100%;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(18, 72, 115, 0.06);
    aspect-ratio: 4 / 5;
    background: #e2eff5;
}

.card-canvas-container canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* Loading Overlay inside Canvas container */
.loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(238, 246, 250, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.5s ease;
    color: var(--color-primary);
}

.spinner {
    width: 45px;
    height: 45px;
    border: 3px solid rgba(18, 72, 115, 0.08);
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
    margin-bottom: 1rem;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Glassmorphism Controls Panel - Light Mode */
.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.2rem;
    box-shadow: 0 20px 45px rgba(18, 72, 115, 0.07),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
}

.panel-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 1.8rem;
    border-bottom: 1px solid var(--inner-border);
    padding-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.2rem;
    background: var(--color-secondary);
    border-radius: 2px;
}

/* Form Controls */
.control-group {
    margin-bottom: 2rem;
}

.control-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.8rem;
}

.input-tip {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.6rem;
    line-height: 1.5;
}

/* Text Input Styling */
.input-wrapper {
    position: relative;
    width: 100%;
}

.text-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(18, 72, 115, 0.15);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    color: var(--color-primary);
    font-size: 1.15rem;
    font-weight: 600;
    font-family: 'Thmanyah Serif Display', var(--font-ui);
    outline: none;
    transition: all 0.3s ease;
    text-align: right;
    box-shadow: inset 0 2px 4px rgba(18, 72, 115, 0.02);
}

.text-input:focus {
    background: #ffffff;
    border-color: rgba(62, 162, 192, 0.5);
    box-shadow: 0 0 15px rgba(62, 162, 192, 0.12),
        inset 0 1px 2px rgba(18, 72, 115, 0.02);
}

.focus-border {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
    transition: width 0.3s ease;
    border-radius: 0 0 12px 12px;
}

.text-input:focus~.focus-border {
    width: 100%;
}

/* Action buttons */
.actions-container {
    margin-top: 1.5rem;
}

.btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1.1rem;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    box-shadow: 0 8px 25px rgba(18, 72, 115, 0.18);
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 80%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(18, 72, 115, 0.25),
        0 0 12px rgba(62, 162, 192, 0.2);
}

.btn-primary:hover::after {
    opacity: 1;
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 4px 15px rgba(18, 72, 115, 0.2);
}

.btn-icon {
    transition: transform 0.3s ease;
}

.btn:hover .btn-icon {
    transform: translateY(2px);
}

/* Footer Styling */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(18, 72, 115, 0.05);
}

.credits {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-top: 0.5rem;
}

.credit-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease, transform 0.3s ease;
}

.credit-link:hover {
    color: var(--color-primary);
    transform: translateY(-2px);
}

.divider {
    color: rgba(18, 72, 115, 0.2);
    font-size: 1rem;
}

.credit-text {
    color: var(--text-muted);
}

/* Mobile Responsiveness & Layout Tweaks */
@media (max-width: 768px) {
    .app-container {
        padding: 1.5rem 1rem;
    }

    .app-header {
        margin-bottom: 1.8rem;
    }

    .app-logo {
        height: 85px;
    }

    .app-title {
        font-size: 2rem;
    }

    .glass-panel {
        padding: 1.8rem;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 1rem 0.8rem;
    }

    .app-header {
        margin-bottom: 1.5rem;
    }

    .app-logo {
        height: 75px;
    }

    .app-title {
        font-size: 1.7rem;
    }

    .app-subtitle {
        font-size: 0.9rem;
    }

    .app-main {
        gap: 1.2rem;
    }

    .glass-panel {
        padding: 1.25rem 1.1rem;
        border-radius: 20px;
    }

    .panel-title {
        font-size: 1.15rem;
        margin-bottom: 1.2rem;
    }

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

    .text-input {
        padding: 0.8rem 1rem;
        font-size: 1.05rem;
    }

    .btn {
        padding: 0.95rem;
        font-size: 0.98rem;
    }
}