/* --- Global Reset & Typography --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    color: #374151;
}

::selection {
    background-color: #fed7aa;
}

/* --- Background --- */
.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom right, #fffbeb, #fff7ed, #ffffff);
    z-index: -1;
}

/* --- Main Layout --- */
.main-container {
    flex-grow: 1;
    padding: 40px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass-panel {
    width: 100%;
    max-width: 1152px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (min-width: 1024px) {
    .glass-panel {
        flex-direction: row;
    }
}

/* --- Left Column (Controls) --- */
.controls-panel {
    width: 100%;
    padding: 32px;
    background: rgba(255, 255, 255, 0.6);
    border-right: 1px solid rgba(255, 237, 213, 0.5);
}

@media (min-width: 1024px) {
    .controls-panel {
        width: 35%;
        padding: 40px;
    }
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.header-title .icon {
    font-size: 30px;
}

.header-title h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(to right, #ea580c, #f59e0b);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* --- Inputs --- */
.inputs-container {
    margin-bottom: 32px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    margin-left: 4px;
}

.input-group input {
    width: 100%;
    padding: 12px 20px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    outline: none;
    transition: all 0.3s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.input-group input:focus {
    border-color: #f97316;
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.15);
}

/* --- Templates --- */
.template-section {
    margin-bottom: 32px;
}

.template-section label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    margin-left: 4px;
}

.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.template-btn {
    padding: 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    border: 3px solid transparent;
    background-color: var(--bg-color);
    color: var(--txt-color);
    transition: all 0.3s ease;
}

.template-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.15);
}

.template-btn.active-template {
    border-color: var(--active-color);
    transform: scale(1.04) translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

/* --- Download Button --- */
.btn-download {
    width: 100%;
    margin-top: 40px;
    padding: 16px;
    background: linear-gradient(to right, #f97316, #f59e0b);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    box-shadow: 0 10px 15px -3px rgba(249, 115, 22, 0.3);
}

.btn-download:hover {
    background: linear-gradient(to right, #ea580c, #d97706);
    transform: translateY(-2px);
}

.btn-download:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.status-msg {
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    margin-top: 16px;
    height: 20px;
}

/* --- Right Column (Preview) --- */
.preview-panel {
    width: 100%;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (min-width: 1024px) {
    .preview-panel {
        width: 65%;
        padding: 40px;
    }
}

.preview-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.preview-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.badge {
    background: #fef3c7;
    color: #b45309;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.preview-wrapper {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: center;
}

#card-preview {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background-color: #ffffff;
    overflow: hidden;
    transition: all 0.3s ease;
    /* අලුත්: කාඩ් එකේ පළල හඳුනා ගැනීමට */
    container-type: inline-size;
}

#card-image {
    width: 100%;
    height: auto;
    display: block;
}

.card-text {
    position: absolute;
    font-family: 'Abhaya Libre', serif;
    font-size: 16px;
    /* fallback only — JS override කරයි */
    font-weight: 800;
    color: #1f2937;
    white-space: nowrap;
    text-shadow: 0px 1px 2px rgba(255, 255, 255, 0.8);
    transform: translateY(-50%);
    /* ✅ Text card ෙකන් පිටට නොයන්නට */
    max-width: 26%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ✅ මේ media query ද ඉවත් කරන්න — JS handle කරනවා */
/* @media (max-width: 600px) {
    .card-text {
        font-size: 2cqw;
    }
} */

/* @media (min-width: 800px) කොටස දැන් අවශ්‍ය නැති නිසා මකා දැමිය හැක */

/* transform එක යෙදූ නිසා top අගය මඳක් වෙනස් කළා */
#display-to {
    top: 71%;
    left: 72%;
}

#display-from {
    top: 82%;
    left: 72%;
}

/* Mobile Phone වලදී පමණක් අකුරු කුඩා කිරීම */
@media (max-width: 600px) {
    .card-text {
        font-size: 2cqw;
        /* 3cqw වෙනුවට 2.2cqw හෝ 2cqw යොදා වෙනස බලන්න */
    }
}

/* --- Footer --- */
.footer {
    width: 100%;
    padding: 24px;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

@media (min-width: 640px) {
    .footer-content {
        flex-direction: row;
    }
}

.footer p {
    font-size: 14px;
    font-weight: 500;
}

.footer a {
    color: #ea580c;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.3s;
}

.footer a:hover {
    color: #c2410c;
    text-decoration: underline;
}

@keyframes heartPulse {
    0% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.3);
    }

    30% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.3);
    }

    60% {
        transform: scale(1);
    }

    100% {
        transform: scale(1);
    }
}

.heart-pulse {
    display: inline-block;
    animation: heartPulse 1.2s infinite;
    transform-origin: center;
}

.btn-donate {
    padding: 6px 16px;
    background: linear-gradient(to right, #ffedd5, #fff7ed);
    border: 1px solid #fed7aa;
    color: #c2410c;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Poppins', sans-serif;
}

.btn-donate:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* --- Modal (Popup) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 16px;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    padding: 32px;
    border-radius: 24px;
    max-width: 384px;
    width: 100%;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal.show .modal-content {
    transform: scale(1);
}

.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 20px;
    color: #9ca3af;
    cursor: pointer;
    font-weight: bold;
    transition: color 0.3s;
}

.close-btn:hover {
    color: #ef4444;
}

.modal h3 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
}

.modal-text {
    text-align: center;
    font-size: 14px;
    color: #4b5563;
    margin-bottom: 24px;
}

.qr-container {
    display: flex;
    justify-content: center;
    background: #fff7ed;
    border: 2px solid #ffedd5;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}

.qr-container img {
    width: 192px;
    height: 192px;
    object-fit: contain;
    border-radius: 12px;
    mix-blend-mode: multiply;
}

.modal-footer-text {
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}
