:root {
  --background: linear-gradient(30deg, #1360a4 30%, #3594e8);
  --primary: #1878cd;
  --primary-text: #fff;
  --border-width: 0.3rem;
  --border-radius-round: 100vmax;
  --focus: #df123b;
  --browser-ui-height: 0px;
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --dynamic-bottom-height: calc(12vh + var(--browser-ui-height) + var(--safe-area-inset-bottom));
}

/* Force APEX modals above camera interface */
.ui-dialog,
.ui-dialog.ui-widget.ui-widget-content,
div[class*="t-Dialog"] {
  z-index: 10000 !important;
}


.ui-widget-overlay,
.ui-widget-overlay.ui-front,
div[class*="t-Dialog-overlay"] {
  z-index: 9998 !important;
}

/* Remove border radius from main containers and camera elements */
#video, #canvas, .main, body, html {
  border-radius: 0 !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Camera region fills the viewport */
#camera-region {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 1000;
  background: var(--background, #000);
  overflow: hidden;
}

/* Camera preview always at the back with dynamic height */
#video, #canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  object-fit: cover;
  background: #000;
  z-index: 1;
  transition: height 0.3s ease;
}

#canvas {
  display: none;
}

.exit-btn-positioned {
  position: fixed !important;
  top: 20px !important;
  left: 20px !important;
  z-index: 9999 !important;
}

.exit-btn-positioned button {
  background: transparent !important;
  border: none !important;
  color: white !important;
  font-size: 24px !important;
  padding: 8px !important;
}

.top-controls {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 25;
}

.control-btn {
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}

.control-btn:hover {
 RZ

  background: rgba(0, 0, 0, 0.8);
  transform: scale(1.05);
}

.control-btn:active {
  transform: scale(0.95);
}

[data-action="help"] button {
  background: transparent !ultimate;
  border: none !important;
  color: white !important;
  font-size: 18px !important;
  padding: 0 !important;
}

/* Flash states */
.control-btn.flash-auto {
  color: #ffffff;
}

.control-btn.flash-on {
  color: #ffff00;
  background: rgba(0, 0, 0, 0.8);
}

.control-btn.flash-off {
  color: #888888;
  position: relative;
}

.control-btn.flash-off::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 24px;
  background: #ff0000;
  transform: translate(-50%, -50%) rotate(45deg);
}

/* Frame toggle active state */
.control-btn.frame-active {
  background: rgba(24, 120, 205, 0.8);
}

/* Camera frame overlay */
.camera-frame-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: calc(100vh - var(--dynamic-bottom-height));
  height: calc(100dvh - var(--dynamic-bottom-height));
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transition: height 0.3s ease;
  margin-top:21vh;
}

.camera-frame-box {
  position: relative;
  width: 70vw;
  max-width: 420px;
  height: 40vh;
  max-height: 70vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 6px solid #fff;
  border-radius: 8px;
  z-index: 3;
}

.top-left {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
}

.top-right {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
}

.bottom-left {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
}

.bottom-right {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
}

.frame-message {
  position: relative;
  color: #fff;
  font-size: 1.4rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7);
  background: rgba(0,0,0,0.2);
  padding: 0.6em 1.2em;
  border-radius: 1em;
  pointer-events: none;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: center;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.5em;
}

/* Bottom overlay */
.camera-bottom-overlay {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--dynamic-bottom-height);
  min-height: calc(120px + var(--browser-ui-height));
  width: 100%;
   /* Much more transparent white */
   background: rgba(255,255,255,0.9);
  //continue
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1001;
  pointer-events: none;
  transition: height 0.3s ease, bottom 0.3s ease;
  padding-bottom: calc(var(--browser-ui-height) + var(--safe-area-inset-bottom) + 0.5rem); /* Reduced padding */
}

.camera-bottom-overlay .actions {
  pointer-events: auto;
}

/* Actions at the bottom, inside the overlay */
.actions {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-bottom: 0.5rem;
  z-index: 20;
  position: relative;
  background: none;
}



/* Three-column layout */
.three-column-container {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  min-width: 0;
}

.column {
  flex: 1 1 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

#col2 {
  flex: 2 1 0;
  flex-direction: column;
  gap: 0.3rem;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding-top: 1.5rem; /* Increase this to move it down on desktop */
}



/* Camera buttons */

//upload button
.gallery-control-btn span {
    color: #2d5016; /* dark green */
    margin-top: -10px;
}

//Camera button(s)

button.camera-btn {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 50% !important;
}
.camera-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  touch-action: manipulation;
  transition: background 0.2s;
  font-size: 2.rem;
  padding: 0;
  width: 4.2rem;
  height: 4.2rem;
  border-radius: 50%;
  background: #1878cd;
  color: #fff;
  position: relative; /* Ensure buttons are positioned correctly */
}

#start-camera.camera-btn {
  background: #1878cd;
  color: #fff;
}

#start-camera .fa-camera {
  font-size: 2.5rem;
  color: #fff;
}

#start-camera.camera-btn:active {
  background: #145a9e;
}

/* Take Picture button - dark green background */
#take-photo.camera-btn {
  background: #1a3009;
  color: #fff;
}

/* Camera icon inside - white */
#take-photo .fa-camera {
  color: #fff;
  font-size: 2.5rem;
}

/* Take Picture LABEL - make it dark green too! */
.camera-button-label.green-label {
  color: #1a3009 !important; /* Dark green to match */
}

#take-photo.camera-btn:active {
  background: #234012;
}

.camera-button-label {
  margin-top: -0.3rem; /* Increased margin to ensure label is below button */
  font-size: 1.5rem;
  text-align: center;
  font-weight: 500;
  width: 100%;
  display: block;
  color: #1878cd !important;
  order: 2; /* Ensure label is always last in flex column */
}

.camera-button-label.blue-label {
  color: #1878cd !important;
}

.camera-button-label.green-label {
  color: #43A047 !important;
}

/* Feedback */
.feedback {
  color: #fff;
  font-size: 1.2rem;
  margin-top: 1rem;
  text-align: center;
}

.landscape-warning {
  display: none;
  position: fixed;
  z-index: 2000;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 2rem;
  align-items: center;
  justify-content: center;
  text-align: center;
}

@media (orientation: landscape) and (max-width: 900px) {
  .landscape-warning {
    display: flex;
  }

  #camera-region, .camera-bottom-overlay {
    filter: blur(2px) grayscale(0.7);
  }
}

@media (max-width: 600px) {
  .camera-bottom-overlay {
    min-height: calc(140px + var(--browser-ui-height)); /* More height */
    padding-top: .5rem; /* Add top padding */
  }
  
  #col2 {
    padding-top: .5rem; /* Increase from 0.3rem */
  }

  .camera-frame-overlay {
    margin-top: 14vh;
  }

  .actions {
    padding-bottom: 0.1rem; /* Further reduced */
  }

  .camera-bottom-overlay {
    min-height: calc(100px + var(--browser-ui-height));
    padding-bottom: calc(var(--browser-ui-height) + var(--safe-area-inset-bottom) + 0.3rem);
  }

  .three-column-container {
    gap: 0.5rem;
  }

  #col2 {
    padding-top: 0.3rem; /* Adjusted for smaller screens */
  }

  .camera-btn {
    width: 3.2rem;
    height: 3.2rem;
    font-size: 1.8rem;
  }

  #start-camera .fa-camera {
    font-size: 2rem;
  }

  #take-photo .fa-camera {
    font-size: 2rem;
  }

  .camera-button-label {
    margin-top: -0.3rem;
    font-size: 1.3rem;
  }
}