/* ============================================
   OnePage Builder - Template 3 (Formal Corporate)
   Base styles inherited from accounting_office_view_3.css
   Header/Footer จาก Template 2 + Formal content area
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ============ Reset & Grid (standalone, no Bootstrap) ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Sarabun", sans-serif; background: var(--formal-bg, #f8fafc); color: #0f172a; min-height: 100vh; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 15px; }
.note-editable img, .about-content img, .custom-tab-content-area img, .formal-text img { max-width: 100%; height: auto; }
.about-content, .custom-tab-content-area { overflow: hidden; }

/* ============ Builder Toolbar ============ */
.builder-toolbar { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 9999; background: #fff; padding: 10px 20px; border-radius: 50px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 12px; user-select: none; transition: box-shadow 0.2s; }
.builder-toolbar.dragging { box-shadow: 0 8px 30px rgba(0,0,0,0.25); cursor: grabbing; }
.builder-toolbar .tb-drag { cursor: grab; color: #adb5bd; font-size: 14px; display: flex; align-items: center; padding: 2px 0; transition: color 0.2s; }
.builder-toolbar .tb-drag:hover { color: #6c757d; }
.builder-toolbar.dragging .tb-drag { cursor: grabbing; color: #1e3a8a; }
.builder-toolbar .tb-label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: #495057; }
.builder-toolbar .tb-sep { width: 1px; height: 24px; background: #dee2e6; }
.tb-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 50px; border: none; font-size: 13px; font-weight: 500; cursor: pointer; font-family: "Sarabun", sans-serif; transition: all 0.2s; }
.tb-btn-back { background: #f8f9fa; color: #495057; }
.tb-btn-back:hover { background: #e9ecef; }
.tb-btn-preview { background: #1e3a8a; color: #fff; }
.tb-btn-preview:hover { background: #172554; }
.tb-btn-save { background: #00b894; color: #fff; }
.tb-btn-save:hover { background: #00a381; }
.tb-btn-reset { background: #fee2e2; color: #dc2626; padding: 8px 12px; }
.tb-btn-reset:hover { background: #dc2626; color: #fff; }

/* Toast */
.toast-msg { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: #1e293b; color: #fff; padding: 12px 24px; border-radius: 8px; z-index: 99999; opacity: 0; transition: all 0.3s; font-family: "Sarabun", sans-serif; font-size: 14px; }
.toast-msg.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ============ Builder Mode (Edit Controls) ============ */
.editable-section { position: relative; }
.editable-section::before { content: ''; position: absolute; inset: 0; border: 2px dashed transparent; pointer-events: none; z-index: 40; }
.builder-mode .editable-section:hover::before { border-color: #1e3a8a; background: rgba(30,58,138,0.02); }
.edit-btn { position: absolute; top: 8px; right: 8px; z-index: 50; opacity: 0; transition: opacity 0.2s; background: #1e3a8a; color: #fff; border: none; width: 32px; height: 32px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.builder-mode .editable-section:hover .edit-btn { opacity: 1; }
.inline-edit { outline: none; cursor: text; }
.builder-mode .inline-edit:hover { background: rgba(30,58,138,0.08); }
.preview-mode .edit-btn, .preview-mode .item-controls, .preview-mode .add-item-btn { display: none !important; }
.preview-mode .editable-section::before { display: none !important; }
.editable-item { position: relative; }
.item-controls { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; opacity: 0; z-index: 45; }
.builder-mode .editable-item:hover .item-controls { opacity: 1; }
.builder-mode .formal-slide:hover .item-controls { opacity: 1; }
.item-controls button { width: 26px; height: 26px; border-radius: 4px; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; font-size: 12px; }
.item-controls .ctrl-del { background: #fee2e2; color: #dc2626 !important; }
.item-controls .ctrl-del:hover { background: #dc2626; color: #fff !important; }
.ctrl-del i { color: inherit !important; }
.add-item-btn { border: 2px dashed #cbd5e1; background: #f8fafc; padding: 12px; display: flex; align-items: center; justify-content: center; gap: 6px; color: #64748b; font-weight: 500; cursor: pointer; font-family: "Sarabun", sans-serif; font-size: 13px; transition: all 0.2s; width: 100%; margin-top: 12px; }
.add-item-btn:hover { border-color: #1e3a8a; background: #eff6ff; color: #1e3a8a; }

/* Upload overlay */
.upload-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; opacity: 0; transition: opacity 0.3s; cursor: pointer; z-index: 41; }
.builder-mode .upload-overlay:hover { opacity: 1; }
.upload-overlay i { font-size: 24px; color: #fff; }
.upload-overlay span { color: #fff; font-size: 13px; }

/* Fix: .editable-item has position:relative which breaks absolute positioning of slides */
.formal-slide.editable-item {
    position: absolute !important;
    inset: 0;
}
/* Show add/delete controls on active slide hover */
.builder-mode .formal-slide.active .item-controls {
    opacity: 1;
    z-index: 10;
}

/* Tab content visibility */
.formal-tab-content { display: none; }
.formal-tab-content.active { display: block; }

/* Summernote modal z-index fix */
.note-editor .note-modal { z-index: 10050 !important; }
.note-editor .note-modal .note-modal-backdrop { z-index: 10049 !important; }
.note-editor .note-modal .modal-dialog { z-index: 10051 !important; }
.modal-backdrop { z-index: 10001 !important; }

/* ============ Navbar (same as Template 2) ============ */
.navbar-onepage { background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%); padding: 14px 0; box-shadow: 0 2px 20px rgba(0,0,0,0.08); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid rgba(30,58,138,0.1); }
.navbar-onepage .container { display: flex; justify-content: space-between; align-items: center; }
.navbar-brand-text { text-decoration: none; font-size: 18px; font-weight: 700; color: #0f172a; display: flex; align-items: center; gap: 10px; transition: color 0.2s; }
.navbar-brand-text:hover { opacity: 0.85; }
.navbar-brand-text i#navBrandIcon { font-size: 16px; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; flex-shrink: 0; transition: all 0.2s; }
.navbar-right { display: flex; align-items: center; gap: 8px; }
.navbar-contact-btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 22px; background: var(--formal-primary, #1e3a8a); color: #fff; border-radius: 4px; text-decoration: none; font-size: 14px; font-weight: 600; transition: all 0.3s; box-shadow: 0 4px 15px rgba(30,58,138,0.3); letter-spacing: 0.3px; }
.navbar-contact-btn:hover { background: #172554; color: #fff; }
.navbar-edit-btn { width: 36px; height: 36px; border-radius: 4px; border: 1px solid #e2e8f0; background: #fff; color: #64748b; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; transition: all 0.2s; }
.navbar-edit-btn:hover { background: #eff6ff; color: #1e3a8a; border-color: #1e3a8a; }
.preview-mode .navbar-edit-btn { display: none; }

/* ============ Builder Overrides for Formal Content ============ */
.formal-profile-row { overflow: visible; }
.builder-mode .formal-section:hover { transform: none; }

/* Footer (same as Template 2) */
.onepage-footer { background: #212529; color: #adb5bd; padding: 25px 0; text-align: center; font-size: 14px; }
.onepage-footer .navbar-edit-btn { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.2); color: #fff; }
.onepage-footer .navbar-edit-btn:hover { background: rgba(255,255,255,0.3); }
.preview-mode .onepage-footer .navbar-edit-btn { display: none; }

/* ============ Modal (Builder Only) ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 10000; display: none; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal-content { background: #fff; border-radius: 8px; padding: 24px; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal-content h3 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.modal-field { margin-bottom: 14px; }
.modal-field label { display: block; font-size: 13px; font-weight: 500; color: #495057; margin-bottom: 6px; }
.modal-field input, .modal-field select, .modal-field textarea { width: 100%; padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 4px; font-size: 14px; font-family: "Sarabun", sans-serif; }
.modal-field input:focus, .modal-field textarea:focus { outline: none; border-color: #1e3a8a; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button { flex: 1; padding: 10px; border-radius: 4px; font-size: 14px; font-weight: 500; cursor: pointer; font-family: "Sarabun", sans-serif; border: none; }
.modal-btn-cancel { background: #f1f5f9; color: #334155; }
.modal-btn-cancel:hover { background: #e2e8f0; }
.modal-btn-confirm { background: #1e3a8a; color: #fff; }
.modal-btn-confirm:hover { background: #172554; }

/* Icon Picker */
.icon-picker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; max-height: 180px; overflow-y: auto; padding: 8px; background: #f8fafc; border-radius: 4px; margin-top: 6px; }
.icon-picker-item { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 4px; cursor: pointer; background: #fff; border: 1px solid #e2e8f0; font-size: 16px; transition: all 0.2s; }
.icon-picker-item:hover { background: #eff6ff; border-color: #1e3a8a; }
.icon-picker-item.selected { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }

/* ============ Responsive ============ */
@media (max-width: 991px) {
    .formal-grid { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
    .builder-toolbar { padding: 8px 12px; gap: 8px; }
    .tb-btn span { display: none; }
    .formal-hero-container { border-radius: 0; }
    .formal-profile-row { flex-direction: column; text-align: center; }
    .formal-cta-group { align-items: center; width: 100%; }
    .formal-check-list { grid-template-columns: 1fr; }
}
