/* app.css - Core Before/After App & Glass UI Modals */

/* CSS Variables - GLOBALS & THEMES */
:root {
    --shadow: 0 12px 35px rgba(15, 23, 42, 0.06); 
    --radius-lg: 32px;
    --radius-md: 20px;
    --radius-pill: 50px;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
}
[data-theme*="-dark"] {
    --shadow: 0 12px 35px rgba(0, 0, 0, 0.3); 
    --glass-bg: rgba(30, 41, 59, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
}

/* 1. CANVAS (Classic/Original) */
:root, [data-theme='canvas-light'] {
    --bg-body: #eef2f6; --panel-bg: #ffffff; --box-bg: #f8fafc; --border-color: #f1f5f9;
    --text-main: #1e293b; --text-muted: #64748b; --input-bg: #ffffff;
    --btn-main-bg: #1e293b; --btn-main-text: #ffffff; --btn-sec-bg: #f1f5f9; --btn-sec-hover: #e2e8f0;
    --preview-dash: #cbd5e1; --dropzone1-bg: #f0fdf4; --dropzone1-border: #dcfce7;
    --dropzone2-bg: #eff6ff; --dropzone2-border: #dbeafe;
    --dl-btn: #3b82f6; --share-btn: #10b981;
}
[data-theme='canvas-dark'] {
    --bg-body: #0f172a; --panel-bg: #1e293b; --box-bg: #334155; --border-color: rgba(255, 255, 255, 0.05);
    --text-main: #f8fafc; --text-muted: #94a3b8; --input-bg: #0f172a;
    --btn-main-bg: #38bdf8; --btn-main-text: #0f172a; --btn-sec-bg: #334155; --btn-sec-hover: #475569;
    --preview-dash: #475569; --dropzone1-bg: #1e293b; --dropzone1-border: #064e3b;
    --dropzone2-bg: #1e293b; --dropzone2-border: #1e3a8a;
    --dl-btn: #38bdf8; --share-btn: #34d399;
}

/* 2. GRAPHITE (Monochrome/Corporate) */
[data-theme='graphite-light'] {
    --bg-body: #f4f4f5; --panel-bg: #ffffff; --box-bg: #fafafa; --border-color: #e4e4e7;
    --text-main: #18181b; --text-muted: #71717a; --input-bg: #ffffff;
    --btn-main-bg: #27272a; --btn-main-text: #ffffff; --btn-sec-bg: #f4f4f5; --btn-sec-hover: #e4e4e7;
    --preview-dash: #d4d4d8; --dropzone1-bg: #f4f4f5; --dropzone1-border: #d4d4d8;
    --dropzone2-bg: #f4f4f5; --dropzone2-border: #d4d4d8;
    --dl-btn: #52525b; --share-btn: #3f3f46;
}
[data-theme='graphite-dark'] {
    --bg-body: #000000; --panel-bg: #18181b; --box-bg: #27272a; --border-color: #3f3f46;
    --text-main: #f4f4f5; --text-muted: #a1a1aa; --input-bg: #18181b;
    --btn-main-bg: #f4f4f5; --btn-main-text: #000000; --btn-sec-bg: #27272a; --btn-sec-hover: #3f3f46;
    --preview-dash: #52525b; --dropzone1-bg: #18181b; --dropzone1-border: #52525b;
    --dropzone2-bg: #18181b; --dropzone2-border: #52525b;
    --dl-btn: #e4e4e7; --share-btn: #d4d4d8;
}

/* 3. TERRA (Sunset/Warm) */
[data-theme='terra-light'] {
    --bg-body: #fffbeb; --panel-bg: #ffffff; --box-bg: #fef3c7; --border-color: #fde68a;
    --text-main: #78350f; --text-muted: #b45309; --input-bg: #ffffff;
    --btn-main-bg: #d97706; --btn-main-text: #ffffff; --btn-sec-bg: #fef3c7; --btn-sec-hover: #fde68a;
    --preview-dash: #fcd34d; --dropzone1-bg: #fff1f2; --dropzone1-border: #fecdd3;
    --dropzone2-bg: #fff7ed; --dropzone2-border: #ffedd5;
    --dl-btn: #e11d48; --share-btn: #ea580c;
}
[data-theme='terra-dark'] {
    --bg-body: #451a03; --panel-bg: #78350f; --box-bg: #92400e; --border-color: #b45309;
    --text-main: #fef3c7; --text-muted: #fde68a; --input-bg: #78350f;
    --btn-main-bg: #f59e0b; --btn-main-text: #451a03; --btn-sec-bg: #92400e; --btn-sec-hover: #b45309;
    --preview-dash: #b45309; --dropzone1-bg: #4c0519; --dropzone1-border: #9f1239;
    --dropzone2-bg: #431407; --dropzone2-border: #9a3412;
    --dl-btn: #fb7185; --share-btn: #fb923c;
}

/* 4. OBSIDIAN (Royal Purple/Gold) */
[data-theme='obsidian-light'] {
    --bg-body: #f5f3ff; --panel-bg: #ffffff; --box-bg: #ede9fe; --border-color: #ddd6fe;
    --text-main: #312e81; --text-muted: #5b21b6; --input-bg: #ffffff;
    --btn-main-bg: #4f46e5; --btn-main-text: #ffffff; --btn-sec-bg: #ede9fe; --btn-sec-hover: #ddd6fe;
    --preview-dash: #c4b5fd; --dropzone1-bg: #fefce8; --dropzone1-border: #fef08a;
    --dropzone2-bg: #faf5ff; --dropzone2-border: #e9d5ff;
    --dl-btn: #7c3aed; --share-btn: #d97706;
}
[data-theme='obsidian-dark'] {
    --bg-body: #1e1b4b; --panel-bg: #312e81; --box-bg: #3730a3; --border-color: #4338ca;
    --text-main: #e0e7ff; --text-muted: #c7d2fe; --input-bg: #312e81;
    --btn-main-bg: #818cf8; --btn-main-text: #1e1b4b; --btn-sec-bg: #3730a3; --btn-sec-hover: #4338ca;
    --preview-dash: #4f46e5; --dropzone1-bg: #422006; --dropzone1-border: #b45309;
    --dropzone2-bg: #2e1065; --dropzone2-border: #6b21a8;
    --dl-btn: #a78bfa; --share-btn: #fbbf24;
}

/* 5. FROST (Mint/Forest) */
[data-theme='frost-light'] {
    --bg-body: #f0fdf4; --panel-bg: #ffffff; --box-bg: #dcfce7; --border-color: #a7f3d0;
    --text-main: #064e3b; --text-muted: #047857; --input-bg: #ffffff;
    --btn-main-bg: #059669; --btn-main-text: #ffffff; --btn-sec-bg: #dcfce7; --btn-sec-hover: #a7f3d0;
    --preview-dash: #6ee7b7; --dropzone1-bg: #ecfdf5; --dropzone1-border: #6ee7b7;
    --dropzone2-bg: #f7fee7; --dropzone2-border: #d9f99d;
    --dl-btn: #059669; --share-btn: #65a30d;
}
[data-theme='frost-dark'] {
    --bg-body: #022c22; --panel-bg: #064e3b; --box-bg: #065f46; --border-color: #047857;
    --text-main: #d1fae5; --text-muted: #a7f3d0; --input-bg: #064e3b;
    --btn-main-bg: #34d399; --btn-main-text: #022c22; --btn-sec-bg: #065f46; --btn-sec-hover: #047857;
    --preview-dash: #059669; --dropzone1-bg: #022c22; --dropzone1-border: #059669;
    --dropzone2-bg: #1a2e05; --dropzone2-border: #4d7c0f;
    --dl-btn: #34d399; --share-btn: #a3e635;
}

/* 6. HORIZON (Neon Cyber) */
[data-theme='horizon-light'] {
    --bg-body: #ecfeff; --panel-bg: #ffffff; --box-bg: #cffafe; --border-color: #a5f3fc;
    --text-main: #164e63; --text-muted: #0891b2; --input-bg: #ffffff;
    --btn-main-bg: #0891b2; --btn-main-text: #ffffff; --btn-sec-bg: #cffafe; --btn-sec-hover: #a5f3fc;
    --preview-dash: #67e8f9; --dropzone1-bg: #fdf2f8; --dropzone1-border: #fbcfe8;
    --dropzone2-bg: #f0fdfa; --dropzone2-border: #ccfbf1;
    --dl-btn: #db2777; --share-btn: #0d9488;
}
[data-theme='horizon-dark'] {
    --bg-body: #083344; --panel-bg: #164e63; --box-bg: #155e75; --border-color: #0e7490;
    --text-main: #cffafe; --text-muted: #67e8f9; --input-bg: #164e63;
    --btn-main-bg: #22d3ee; --btn-main-text: #083344; --btn-sec-bg: #155e75; --btn-sec-hover: #0e7490;
    --preview-dash: #0891b2; --dropzone1-bg: #500724; --dropzone1-border: #9d174d;
    --dropzone2-bg: #042f2e; --dropzone2-border: #0f766e;
    --dl-btn: #f43f5e; --share-btn: #14b8a6;
}

/* NATIVE APP FEEL */
* {
    -webkit-touch-callout: none; 
    -webkit-user-select: none;   
    user-select: none;           
}
input, textarea {
    -webkit-touch-callout: default;
    -webkit-user-select: auto;
    user-select: auto;
}
::-webkit-scrollbar { display: none; }
html, body { -ms-overflow-style: none; scrollbar-width: none; }

/* APP HEADER */
.app-header {
    width: 100%;
    max-width: 620px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--panel-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    box-sizing: border-box;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.app-title { font-weight: 800; font-size: 18px; color: var(--text-main); }
.header-right { display: flex; gap: 10px; }
.header-right button { 
    background: var(--btn-sec-bg); color: var(--text-main); 
    border: none; padding: 8px; border-radius: 50%; font-size: 18px; 
    width: 40px; height: 40px; display: flex; justify-content: center; align-items: center;
    box-shadow: none; transition: background 0.2s;
}
.header-right button:hover { background: var(--btn-sec-hover); }

/* GLOBE STATUS INDICATOR */
.globe-online { color: #10b981; filter: none; }
.globe-offline { color: var(--text-muted); filter: grayscale(100%) opacity(0.5); }

/* CONTAINER & CORE SECTIONS */
.container {
    width: 100%; max-width: 620px; display: flex; flex-direction: column; gap: 20px;
    padding: 30px; border-radius: var(--radius-lg); background: var(--panel-bg);
    box-shadow: var(--shadow); box-sizing: border-box; position: relative; transition: background 0.3s ease;
}

.upload-section { display: flex; justify-content: space-between; align-items: stretch; gap: 16px; }
.upload-box {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px;
    border-radius: var(--radius-md); background: var(--box-bg); width: 100%; min-width: 0;
    border: 1px solid var(--border-color); transition: background-color 0.2s, border-color 0.2s;
}

#dropZone1 { background: var(--dropzone1-bg); border-color: var(--dropzone1-border); }
#dropZone2 { background: var(--dropzone2-bg); border-color: var(--dropzone2-border); }
.upload-box.drag-over { opacity: 0.7; transform: scale(0.98); }

.color-preview {
    width: 100%; height: 125px; border-radius: var(--radius-md); display: flex; align-items: center;
    justify-content: center; color: var(--text-muted); font-weight: 600; font-size: 14px;
    border: 2px dashed var(--preview-dash); box-sizing: border-box; background-color: var(--panel-bg);
    overflow: hidden; margin-bottom: 4px; text-align: center; padding: 5px;
}

/* BUTTONS */
button, .btn {
    background: var(--btn-main-bg); color: var(--btn-main-text); border: none; padding: 10px 18px;
    border-radius: var(--radius-pill); font-weight: 700; cursor: pointer; text-align: center;
    font-size: 13px; box-sizing: border-box; transition: all 0.2s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; letter-spacing: 0.5px;
}
button:active, .btn:active { transform: translateY(2px); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
button.secondary { background: var(--btn-sec-bg); border: 1px solid var(--border-color); color: var(--text-main); box-shadow: none; }
button.secondary:hover { background: var(--btn-sec-hover); }

.icon-row { display: flex; gap: 6px; width: 100%; }
.icon-row .btn { flex: 1; font-size: 16px; padding: 10px 0; background: var(--btn-main-bg); color: var(--btn-main-text);}

.middle-actions { display: flex; flex-direction: column; justify-content: space-between; padding: 12px 0; width: 40px; flex-shrink: 0; align-items: center; }
.middle-actions button { padding: 0; font-size: 18px; width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; }

input[type="file"] { display: none; }
input[type="text"], input[type="number"], select, textarea {
    width: 100%; padding: 10px 14px; border-radius: var(--radius-pill); border: 1px solid var(--border-color);
    text-align: center; box-sizing: border-box; background-color: var(--input-bg);
    color: var(--text-main); font-family: inherit; font-size: 16px; font-weight: 500; transition: all 0.2s;
}
input[type="text"]:focus, select:focus, textarea:focus { outline: none; border-color: var(--text-muted); }

#text1, #text2 { padding: 8px 12px; font-size: 14px; height: 38px; font-weight: 800; }
#text1 { background-color: var(--dropzone1-border); color: var(--text-main); }
#text2 { background-color: var(--dropzone2-border); color: var(--text-main); }
select.pos-select { padding: 8px 12px; font-size: 14px; height: 38px; } 
textarea { text-align: left; resize: vertical; min-height: 80px; margin-top: 10px; line-height: 1.5; border-radius: var(--radius-md); white-space: pre-wrap; word-wrap: break-word;}
select { appearance: none; cursor: pointer; }
option { background-color: var(--panel-bg); color: var(--text-main); }

/* SWITCH & SETTINGS */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--btn-sec-hover); transition: .3s; border-radius: var(--radius-pill); }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: #ffffff; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--btn-main-bg); }
input:checked + .slider:before { transform: translateX(20px); }

.settings-panel { display: none; width: 100%; flex-direction: column; animation: fadeIn 0.3s ease; }
.settings-panel.open { display: flex; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; padding: 20px; border-radius: var(--radius-md); background: var(--box-bg); border: 1px solid var(--border-color); }
.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-row-inline { display: flex; align-items: center; gap: 10px; }
.control-label { color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; display: block; text-align: center; width: 100%; }
.value-display { font-size: 12px; color: var(--text-main); font-weight: 800; background: var(--panel-bg); padding: 2px 6px; border-radius: 8px;}
input[type="range"] { width: 100%; accent-color: var(--btn-main-bg); cursor: pointer; }
input[type="color"] { background: none; border: none; width: 100%; height: 36px; cursor: pointer; border-radius: var(--radius-md); padding: 0; }

/* CANVAS PREVIEW */
.canvas-container { width: 100%; display: flex; justify-content: center; border-radius: var(--radius-md); overflow: hidden; background: var(--box-bg); padding: 15px; box-sizing: border-box; border: 1px solid var(--border-color); }
canvas { max-width: 100%; height: auto; display: block; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); }

/* DESCRIPTION & TOOLBAR */
.description-container { background: var(--box-bg); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 15px; width: 100%; box-sizing: border-box; }
.desc-header { display: flex; justify-content: space-between; align-items: center; background: var(--input-bg); padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--border-color); flex-wrap: wrap; gap: 8px; }
.desc-control-wrap { display: flex; align-items: center; gap: 6px; }
.color-btn-icon { position: relative; display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--radius-md); background: var(--btn-sec-bg); border: 1px solid var(--border-color); color: var(--text-main); cursor: pointer; overflow: hidden; transition: all 0.2s; }
.color-btn-icon:hover { background: var(--btn-sec-hover); }
.color-btn-icon input[type="color"] { position: absolute; top: -10px; left: -10px; width: 60px; height: 60px; opacity: 0; cursor: pointer; }
.format-btn { background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-main); cursor: pointer; font-family: serif; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 15px; border-radius: var(--radius-md); box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); transition: all 0.2s; }
.format-btn.active { background: var(--btn-main-bg); border-color: var(--btn-main-bg); color: var(--btn-main-text); }
#descFormatToolbar { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.format-row { display: flex; align-items: center; gap: 8px; justify-content: flex-start;}
#descFontSize { width: 70px !important; padding: 8px; border-radius: var(--radius-md); }
#descFont { width: auto !important; flex: 1; padding: 8px; min-width: 110px; border-radius: var(--radius-md); }
.desc-format-btn { width: 40px !important; padding: 0 !important; }

/* ACTION BAR & FOOTER */
.action-bar { display: flex; gap: 12px; margin-top: 0px; width: 100%; }
.action-bar button { flex: 1; padding: 16px; font-size: 15px; letter-spacing: 0.5px; border-radius: var(--radius-pill); width: 100%; }
#downloadBtn { background: var(--dl-btn); color: #ffffff; } 
#shareBtn { background: var(--share-btn); color: #ffffff; } 
#tipsBtn { background: var(--btn-sec-bg); color: var(--text-main); border: 1px solid var(--border-color); box-shadow: none;} 
.footer-credit { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; margin-top: 0px; margin-bottom: 0px; width: 100%; }
.footer-credit span { color: var(--text-muted); font-family: 'Quicksand', sans-serif; font-weight: 800; text-transform: uppercase; font-size: 13px; letter-spacing: 2px; }
.footer-credit img { height: 24px; width: auto; max-width: 120px; object-fit: contain; opacity: 0.7; transition: opacity 0.2s;}
.footer-credit img:hover { opacity: 1; }

/* GLASS UI MODALS (Soft & Strict) */
.glass-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: none; align-items: center; justify-content: center; z-index: 9999;
    padding: 20px; box-sizing: border-box;
}
.glass-overlay.visible { display: flex; }
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 30px; box-sizing: border-box;
    color: var(--text-main); width: 100%; max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    max-height: 90vh; overflow-y: auto;
}

/* Original Tips Content Styles adapted for Glass UI */
.tips-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; border-bottom: 2px solid var(--border-color); padding-bottom: 15px; }
.tips-title { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; }
.close-tips { background: var(--btn-sec-bg); border: none; color: var(--text-main); height: 40px; width: 40px; border-radius: 50%; font-size: 20px; cursor: pointer; display: flex; justify-content: center; align-items: center;}
.close-tips:hover { background: var(--btn-sec-hover); }
.tips-content { font-size: 14px; line-height: 1.7; display: flex; flex-direction: column; gap: 20px; }
.tips-section { margin-bottom: 5px; background: var(--panel-bg); padding: 15px; border-radius: var(--radius-md); box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);}
.tips-section-title { font-weight: 800; margin-bottom: 8px; font-size: 15px; color: var(--text-main);}
.tips-content ul { margin: 0; padding-left: 20px; color: var(--text-muted); }
.tips-content li { margin-bottom: 6px; }

/* MOBILE RESPONSIVE */
@media (max-width: 600px) {
    .container { padding: 15px; border-radius: 24px; }
    .controls-grid { grid-template-columns: 1fr; padding: 15px;}
    .upload-section { gap: 10px; }
    .color-preview { height: 105px; } 
    .middle-actions { width: 36px; padding: 4px 0;} 
    .middle-actions button.secondary { width: 36px; height: 36px; font-size: 16px; }
    .icon-row .btn { font-size: 15px; }
    input[type="text"], input[type="number"], select, textarea { font-size: 16px; padding: 12px; }
    .action-bar { flex-direction: row; gap: 8px; }
    .action-bar button { padding: 12px 4px; font-size: 13px; }
    .desc-header { justify-content: space-between; padding: 10px 8px; flex-wrap: nowrap; gap: 4px; }
    .desc-header .control-label { font-size: 11px !important; }
    .color-btn-icon { width: 30px; height: 30px; }
    #descHiddenControls { gap: 4px !important; }
}

/* ADD THIS TO app.css (for Header Animations) */

@keyframes pulse-green {
    0% { filter: drop-shadow(0 0 2px #10b981); }
    50% { filter: drop-shadow(0 0 10px #10b981) drop-shadow(0 0 15px #10b981); }
    100% { filter: drop-shadow(0 0 2px #10b981); }
}

@keyframes pulse-red {
    0% { filter: drop-shadow(0 0 2px #e11d48); }
    50% { filter: drop-shadow(0 0 10px #e11d48) drop-shadow(0 0 15px #e11d48); }
    100% { filter: drop-shadow(0 0 2px #e11d48); }
}

.globe-online { 
    color: #10b981; 
    animation: pulse-green 2s infinite; 
    display: flex;
}

.globe-offline { 
    color: #e11d48; 
    animation: pulse-red 2s infinite; 
    display: flex;
}