/* =======================================================
   💎 X (TWITTER) CARD MAKER - ULTRA-PRO CSS
   ======================================================= */
:root {
    --primary: #1da1f2; /* X/Twitter Blue for accent */
    --dark: #0f172a; --terminal-bg: #1e293b; 
    --terminal-text: #a5b4fc; --terminal-highlight: #38bdf8; 
    --border: #e2e8f0; --bg-light: #f8fafc; --danger: #ef4444;
}

.dw-saas-wrapper { max-width: 1250px; margin: 40px auto; padding: 0 20px; font-family: 'Plus Jakarta Sans', sans-serif; box-sizing: border-box; }
.dw-saas-wrapper * { box-sizing: border-box; }

.text-gradient { background: linear-gradient(135deg, #1da1f2 0%, #000000 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 800; }
.dw-saas-header { text-align: center; margin-bottom: 40px; }
.dw-saas-chip { display: inline-block; padding: 6px 16px; background: #e8f5fd; color: var(--primary); border-radius: 100px; font-size: 12px; font-weight: 700; margin-bottom: 12px; letter-spacing: 0.5px; }

/* 🚀 MAIN GRID */
.dw-main-grid { display: grid; grid-template-columns: 1fr 480px; gap: 30px; align-items: start; }
.dw-card { background: #fff; border-radius: 24px; border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,0.04); overflow: hidden; }
.dw-card-header { padding: 20px 25px; border-bottom: 1px solid var(--border); background: var(--bg-light); }
.dw-card-header h3 { font-size: 18px; font-weight: 800; margin: 0; color: var(--dark); }

.dw-form-body { padding: 25px; }
.dw-form-group { margin-bottom: 22px; }
.dw-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.dw-label { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; margin-bottom: 8px; color: var(--dark); }
.dw-counter { font-size: 12px; color: #64748b; font-weight: 600; transition: 0.3s; }
.dw-counter.over-limit { color: var(--danger); font-weight: 800; }

.dw-input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--border); font-size: 14px; outline: none; transition: 0.3s; color: #334155; background: #fff; font-family: inherit;}
.dw-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(29, 161, 242, 0.1); }
select.dw-input { height: 48px; padding: 0 16px; cursor: pointer; }
.dw-textarea { resize: vertical; min-height: 100px; line-height: 1.5; }
.dw-divider { border: 0; height: 1px; background: var(--border); margin: 30px 0; }

/* 💻 PREVIEW PANEL (Right) */
.dw-terminal-panel { background: #fff; border-color: var(--border); display: flex; flex-direction: column; align-self: start; position: sticky; top: 20px; border-radius: 24px; overflow: hidden; }

/* Tabs Protection */
.dw-preview-tabs { display: flex; background: var(--bg-light); padding: 0 15px; border-bottom: 1px solid var(--border); }
.dw-tab-btn { flex: 1; padding: 16px 2px !important; background: transparent !important; border: none !important; font-size: 14px !important; font-weight: 700 !important; color: #64748b !important; cursor: pointer; border-bottom: 3px solid transparent !important; transition: 0.3s; border-radius: 0 !important; box-shadow: none !important; text-align: center; }
.dw-tab-btn:hover { background: transparent !important; color: var(--primary) !important; }
.dw-tab-btn.active { color: var(--primary) !important; border-bottom-color: var(--primary) !important; }

/* Container & Contents */
.dw-preview-container { flex-grow: 1; display: flex; flex-direction: column; background: var(--terminal-bg); min-height: 100%; }
.dw-tab-content { display: none; flex-direction: column; flex-grow: 1; }
.dw-tab-content.active { display: flex; }

/* 1. Terminal Styles (With unbreakable string fix) */
.dw-terminal-window { padding: 25px; flex-grow: 1; max-height: 500px; overflow-y: auto; }
.dw-terminal-window::-webkit-scrollbar { width: 8px; }
.dw-terminal-window::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
.dw-terminal-window::-webkit-scrollbar-thumb { background: #475569; border-radius: 4px; }
#live-code-output { 
    margin: 0 !important; padding: 0 !important; background: transparent !important; 
    border: none !important; color: var(--terminal-text) !important; 
    font-family: 'Courier New', Courier, monospace; font-size: 14px; line-height: 1.6; 
    white-space: pre-wrap !important; 
    word-break: break-all !important; /* 🔥 Fixes long strings without spaces */
    overflow-wrap: anywhere !important; 
}

/* Actions Bottom Lock */
.dw-terminal-actions { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; background: var(--terminal-bg); border-top: 1px solid rgba(255,255,255,0.05); margin-top: auto !important; flex-shrink: 0 !important; }
.dw-terminal-actions button { border-radius: 12px !important; padding: 14px 10px !important; font-size: 15px !important; font-weight: 800 !important; width: 100% !important; height: 50px !important; margin: 0 !important; cursor: pointer; transition: 0.3s; border: none !important; color: #fff !important; }
.dw-btn-secondary { background: rgba(255,255,255,0.1) !important; border: 1px solid rgba(255,255,255,0.2) !important; }
.dw-btn-secondary:hover { background: rgba(255,255,255,0.2) !important; }
.dw-btn-ultimate { background: var(--primary) !important; box-shadow: 0 10px 20px rgba(29, 161, 242, 0.3) !important; }
.dw-btn-ultimate:hover { transform: translateY(-3px) !important; box-shadow: 0 15px 30px rgba(29, 161, 242, 0.4) !important; }

/* 🌐 X (TWITTER) LIVE PREVIEW UI */
.dw-social-canvas { background: #fff; padding: 30px 20px; height: 100%; display: flex; align-items: flex-start; justify-content: center; }
.dw-x-feed-item { display: flex; gap: 12px; width: 100%; max-width: 420px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.dw-x-avatar { width: 40px; height: 40px; border-radius: 50%; background: #cbd5e1; flex-shrink: 0; }
.dw-x-post-content { flex-grow: 1; min-width: 0; }
.dw-x-user-info { font-size: 15px; line-height: 20px; margin-bottom: 2px; }
.dw-x-user-info strong { color: #0f1419; }
.dw-x-user-info span { color: #536471; }
.dw-x-tweet-text { font-size: 15px; color: #0f1419; margin-bottom: 12px; line-height: 20px; }

/* The Dynamic Card Styles */
.dw-tw-card { background: #fff; border-radius: 16px; border: 1px solid #cfd9de; overflow: hidden; cursor: pointer; transition: background 0.2s; text-decoration: none; display: block; }
.dw-tw-card:hover { background: #f7f9f9; }

.dw-img-ph { background: #e4e6eb; display: flex; align-items: center; justify-content: center; background-size: cover; background-position: center; color: #65676b; font-weight: 600; font-size: 14px; }
.dw-tw-text { padding: 12px; display: flex; flex-direction: column; justify-content: center; }
.dw-tw-domain { color: #536471; font-size: 13px; line-height: 16px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-tw-title { font-weight: 400; color: #0f1419; font-size: 15px; line-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dw-tw-desc { color: #536471; font-size: 15px; line-height: 20px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Large Image Layout */
.dw-card-large { display: flex; flex-direction: column; }
.dw-card-large .dw-img-ph { width: 100%; height: 210px; border-bottom: 1px solid #cfd9de; border-right: none; }

/* Small Summary Layout */
.dw-card-small { display: flex; flex-direction: row; height: 130px; }
.dw-card-small .dw-img-ph { width: 130px; height: 100%; border-right: 1px solid #cfd9de; border-bottom: none; flex-shrink: 0; }
.dw-card-small .dw-tw-text { flex-grow: 1; min-width: 0; padding: 10px 12px; }
.dw-card-small .dw-tw-desc { display: none; /* Twitter hides desc on small cards usually */ }

/* App Layout */
.dw-card-app { display: flex; flex-direction: column; }
.dw-card-app .dw-img-ph { width: 100%; height: 210px; border-bottom: 1px solid #cfd9de; }
.dw-card-app .dw-tw-desc { color: var(--primary); font-weight: 700; margin-top: 5px; } /* Simulating "View on App Store" link */


/* Media Queries */
@media (max-width: 1024px) {
    .dw-main-grid { grid-template-columns: 1fr; }
    .dw-terminal-panel { position: static; height: auto; min-height: 550px; }
}
@media (max-width: 768px) {
    .dw-saas-header h1 { font-size: 30px; }
    .dw-grid-2 { grid-template-columns: 1fr; gap: 15px; }
}
@media (max-width: 480px) {
    .dw-saas-wrapper { padding: 0 15px; margin: 20px auto; }
    .dw-form-body { padding: 20px 15px; }
    .dw-terminal-actions { grid-template-columns: 1fr; }
    .dw-social-canvas { padding: 20px 10px; }
}