import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
import { 
  getAuth, 
  signInWithEmailAndPassword, 
  createUserWithEmailAndPassword, 
  onAuthStateChanged, 
  signOut 
} from "https://www.gstatic.com/firebasejs/10.12.2/firebase-auth.js";

import { 
  getFirestore, 
  collection, 
  addDoc, 
  getDocs, 
  query, 
  where, 
  orderBy, 
  limit, 
  doc, 
  getDoc, 
  setDoc, 
  increment, 
  arrayUnion, 
  runTransaction  // ✅ Added here
} from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";

// Firebase config
const firebaseConfig = {
  apiKey: "AIzaSyC-lsC7Xsp-K3gbdxXDdS7yTL5HzWggTx0",
  authDomain: "selftherapy-c61c6.firebaseapp.com",
  projectId: "selftherapy-c61c6",
  storageBucket: "selftherapy-c61c6.firebasestorage.app",
  messagingSenderId: "566396923513",
  appId: "1:566396923513:web:2affabac7c2072fbe62ea8"
};

// Init
const app = initializeApp(firebaseConfig);
export const auth = getAuth(app);
export const db = getFirestore(app);

// Exports
export { 
  signInWithEmailAndPassword, 
  createUserWithEmailAndPassword, 
  onAuthStateChanged, 
  signOut, 
  collection, 
  addDoc, 
  getDocs, 
  query, 
  where, 
  orderBy, 
  limit, 
  doc, 
  getDoc, 
  setDoc, 
  increment, 
  arrayUnion, 
  runTransaction // ✅ Exported so dashboard can use it
};
