/* MobiFone WebLookup — Responsive UI */
:root {
    --primary: #0078D4;
    --primary-dark: #005A9E;
    --success: #2E7D32;
    --error: #C62828;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

img { max-width: 100%; height: auto; }
img[src=""], img:not([src]) { display: none; }
iframe, embed, object { max-width: 100%; }

/* Hide watermark elements */
.watermark, [class*="watermark"], [id*="watermark"] { display: none !important; }
.raw-content .watermark, .raw-content [class*="watermark"] { display: none !important; }
div[style*="opacity: 0.1"], div[style*="opacity:0.1"], div[style*="opacity: 0.2"], div[style*="opacity:0.2"] { display: none !important; }
.invoice-preview .watermark, .invoice-preview [class*="watermark"] { display: none !important; }

body {
    font-family: 'Segoe UI', -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 12px;
}

.container { width: 100%; max-width: 1100px; }

/* ── Header ── */
header {
    background: linear-gradient(135deg, #1e3a5f, var(--primary));
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    text-align: center;
}
header h1 { font-size: 20px; margin-bottom: 4px; }
header .sub { opacity: 0.85; font-size: 13px; }

/* ── Form ── */
.lookup-form { background: var(--card); padding: 16px; border-bottom: 1px solid var(--border); }
.input-group { display: flex; gap: 10px; flex-wrap: wrap; }
.input-group input[type="text"] {
    flex: 1; min-width: 160px; padding: 10px 14px; font-size: 16px;
    border: 2px solid var(--border); border-radius: 8px; outline: none; transition: border-color 0.2s;
}
.input-group input:focus { border-color: var(--primary); }
.type-select { padding: 10px 8px; font-size: 14px; border: 2px solid var(--border); border-radius: 8px; outline: none; background: white; min-width: 160px; }
.type-select:focus { border-color: var(--primary); }
.month-row { padding: 8px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-row label { font-size: 13px; font-weight: 600; color: var(--text-light); }
.month-select { padding: 8px 10px; font-size: 14px; border: 2px solid var(--border); border-radius: 8px; outline: none; background: white; }
.input-group button {
    padding: 10px 20px; font-size: 14px; font-weight: 600; background: var(--primary);
    color: white; border: none; border-radius: 8px; cursor: pointer; white-space: nowrap; transition: background 0.2s; min-width: 120px;
}
.input-group button:hover { background: var(--primary-dark); }
.input-group button:disabled { opacity: 0.7; cursor: wait; }

/* ── Invoice ── */
.invoice-info { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 16px; background: #f0f9ff; border-bottom: 1px solid var(--border); font-size: 13px; }
.invoice-info span { color: var(--text-light); }
.invoice-info strong { color: var(--text); }
.invoice-table { padding: 12px 16px; overflow-x: auto; }
.invoice-table h3 { font-size: 15px; color: var(--primary-dark); margin-bottom: 8px; }
.invoice-table table { font-size: 12px; width: 100%; }
.invoice-preview { padding: 16px; border-top: 2px solid var(--primary); overflow: hidden; }
.invoice-preview h3 { font-size: 15px; color: var(--primary-dark); margin-bottom: 8px; }
.invoice-preview iframe { width: 100%; height: 800px; border: 1px solid var(--border); border-radius: 4px; max-width: 100%; }
.invoice-preview img { width: 100%; max-width: 100%; border: 1px solid var(--border); border-radius: 4px; image-rendering: high-quality; }
.invoice-link { display: inline-block; margin: 4px; padding: 8px 16px; background: #e2e8f0; border-radius: 6px; text-decoration: none; color: #1e293b; font-size: 13px; transition: background 0.2s; }
.invoice-link:hover { background: #cbd5e1; }

/* ── TBC ── */
.tbc-client-section { background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 8px; padding: 14px 16px; margin: 12px 16px; }
.tbc-client-section h3 { font-size: 15px; color: #0369a1; margin-bottom: 8px; }
.btn-tbc { padding: 10px 18px; font-size: 13px; font-weight: 600; background: var(--primary); color: white; border: none; border-radius: 8px; cursor: pointer; transition: background 0.2s; }
.btn-tbc:hover { background: var(--primary-dark); }
.btn-tbc.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-tbc.btn-secondary:hover { background: #cbd5e1; }

/* ── Alert ── */
.alert { padding: 12px 16px; border-radius: 0 0 8px 8px; font-size: 14px; }
.alert-error { background: #FEE2E2; color: var(--error); border-left: 4px solid var(--error); }

/* ── Result ── */
.result-card { background: var(--card); border-radius: 0 0 12px 12px; overflow: visible; box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.result-header { background: #f8fafc; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--primary); }
.result-header h2 { font-size: 16px; color: var(--primary-dark); }
.timestamp { font-size: 11px; color: var(--text-light); }
.result-body { padding: 0; overflow: hidden; }

/* ── Table ── */
.info-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.info-table th, .info-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.section-header { background: var(--primary); color: white; font-size: 13px; font-weight: 600; }
.field-label { font-weight: 600; color: var(--text); width: 160px; background: #f8fafc; white-space: nowrap; }
.field-value { color: var(--text); word-break: break-word; }

/* ── Raw HTML ── */
.raw-details { border-top: 2px solid var(--border); }
.raw-details summary { padding: 10px 16px; background: #f8fafc; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--primary-dark); }
.raw-details summary:hover { background: #e2e8f0; }
.raw-content { padding: 12px; overflow-x: auto; font-size: 12px; max-width: 100%; }
.raw-content table { border-collapse: collapse; table-layout: auto; }
.raw-content td, .raw-content th { padding: 4px 8px; border: 1px solid var(--border); word-break: break-word; max-width: 250px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.raw-content img { max-height: 600px; object-fit: contain; max-width: 100%; }

/* ── Footer ── */
footer { text-align: center; padding: 16px; color: var(--text-light); font-size: 11px; }
footer a { color: var(--primary); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Mobile ── */
@media (max-width: 600px) {
    body { padding: 6px; }
    header { padding: 14px; border-radius: 8px 8px 0 0; }
    header h1 { font-size: 17px; }
    .lookup-form { padding: 10px; }
    .input-group { flex-direction: column; gap: 8px; }
    .input-group input[type="text"] { min-width: 100%; }
    .type-select { min-width: 100%; }
    .input-group button { width: 100%; min-width: auto; }
    .month-row { flex-direction: column; align-items: stretch; gap: 6px; }
    .month-select { width: 100%; }
    .field-label { width: auto; min-width: 110px; }
    .result-header { flex-direction: column; gap: 4px; align-items: flex-start; }
    .result-header h2 { font-size: 14px; }
    .info-table th, .info-table td { padding: 6px 8px; font-size: 12px; }
    .invoice-preview iframe { height: 400px; }
    .invoice-preview { padding: 10px; }
    .invoice-info { padding: 10px; gap: 8px; }
    .invoice-table { padding: 10px; }
    .raw-content td, .raw-content th { max-width: 140px; font-size: 11px; }
    .tbc-client-section { margin: 8px; padding: 10px; }
    .btn-tbc { width: 100%; text-align: center; }
}

@media (min-width: 601px) and (max-width: 900px) {
    .container { max-width: 100%; }
}
