# Call Active-State, Camera Orientation, Mobile Bottom Controls, and Minimize Fixes

Build tag: `20260603g`

## 1. False “A call is already active” alert

Changed files:
- `js/app.js`
- `api/call.php`

What changed:
- Added frontend stale-call detection before blocking a new call.
- If the local browser still remembers a finished, missing, declined, ended, or timed-out ringing call, the app clears that local state automatically instead of showing a false active-call alert.
- Added server-side cleanup for unanswered ringing calls older than 90 seconds.
- `pollActiveCall()` now clears timed-out ringing calls instead of leaving the browser stuck in an active-call state.

Expected result:
- Users can start or join calls without being blocked by stale call state.
- A real active call still prevents starting a second call, but the existing call window is restored instead of only showing a browser alert.

## 2. Natural camera orientation

Changed file:
- `css/app.css`

What changed:
- Forced `#local-video` and `#remote-video` to use `transform:none!important`.
- This prevents accidental horizontal mirroring from stale/older CSS.

Expected result:
- Local and remote camera feeds display in their natural orientation by default.

## 3. Mobile call panel buttons at the bottom

Changed file:
- `css/app.css`

What changed:
- On mobile width, the call action buttons are now fixed to the bottom safe area.
- The More panel and in-call chat panel also open from the bottom area.
- Extra bottom padding was added to the call video area so controls do not cover the video feed.

Expected result:
- Mobile users can reach Mute, Speaker, Camera, More, Accept, and End from the bottom of the screen.

## 4. Minimize active call window

Changed files:
- `index.php`
- `js/app.js`
- `css/app.css`

What changed:
- Added a minimize button to the call top bar.
- Added a floating minimized active-call pill outside the call modal.
- Tapping the pill restores the call window.
- The End button on the pill ends the active call without reopening the full call window.
- For the configured auto-logout account, hiding the page during an active call minimizes the call instead of immediately logging out from a visibility-change event.

Expected result:
- Video/voice calls stay active while the user minimizes the call window and continues using the app.

## Deployment notes

1. Upload/replace these files on the server:
   - `index.php`
   - `js/app.js`
   - `css/app.css`
   - `api/call.php`
   - Optional documentation: `CALL_ACTIVE_MINIMIZE_FIXES.md`
2. Clear browser cache or hard refresh after upload.
3. Test with two logged-in users:
   - Start a voice call.
   - End it.
   - Start another call immediately.
   - Start a video call and confirm the camera is not mirrored.
   - On mobile, confirm controls stay at the bottom.
   - Minimize the call, then tap the floating pill to restore it.
