/** @format */

/* +++ GLOBAL STYLE ELEMENTS +++ */
:root {
	--main-background-colour: rgb(255, 255, 238);
	--table-line-highlight-colour: rgb(255, 196, 174);
	--display-font-size: clamp(8px, 2vw, 20px);
	--input-font-size: clamp(10px, 2vw, 20px);
	--border-radius: 6px;
}

body {
	padding: 5px;
	font-family: 'Montserrat', Helvetica, Arial, sans-serif;
	font-size: 18px;
	background-color: var(--main-background-colour);
	overflow: scroll;
	height: auto;
}

h1 {
	font-size: clamp(0.3rem, 4vw, 3rem);
	margin: 10px;
}

.header-container {
	position: relative;
	text-align: center;
}

h2 {
	font-size: clamp(0.2rem, 3vw, 2rem);
	text-align: center;
}

h3 {
	font-size: 20px;
	text-align: left;
	margin: 1em 5em 0 5em;
}

p {
	margin: 1em 5em 0 5em;
}

.leftControlBox {
	position: absolute;
	left: 0px;
	top: 0px;
	font-size: 12px;
	padding-left: 10px;
}

.rightControlBox {
	position: absolute;
	top: 0;
	right: 0;
	padding: 0;
	font-size: 12px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	text-align: right;
}

.rightControlBox p,
.rightControlBox a {
	width: 100%;
	box-sizing: border-box;
	margin: 0;
	text-align: right;
}

th {
	background-color: wheat;
	font-size: var(--display-font-size);
}

th,
td {
	padding: 10px;
	text-align: center;
	border: 1px solid black;
	font-size: var(--display-font-size);
}

tr:hover {
	background-color: var(--table-line-highlight-colour);
}

input {
	border: 1px solid #ccc;
	border-radius: var(--border-radius);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

input[type='checkbox'] {
	transform: scale(1.5);
}

input[type='text'],
input[type='password'],
input[type='email'] {
	width: clamp(10vw, 20vw, 25vw);
	padding: 10px 14px;
	font-size: var(--input-font-size);
	font-family: inherit;
}

select {
	appearance: none; /* remove default arrow */
	-webkit-appearance: none;
	-moz-appearance: none;

	width: clamp(10vw, 20vw, 25vw);
	padding: 10px 14px;
	font-size: var(--input-font-size);
	font-family: inherit;
	color: #333;
	background-color: #fff;
	border: 1px solid #ccc;
	border-radius: var(--border-radius);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
	cursor: pointer;
	transition: all 0.2s ease;
	/* space for custom arrow */
	background-image: url("data:image/svg+xml;utf8,<svg fill='gray' height='16' viewBox='0 0 24 24' width='16' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 16px;
}

select:focus {
	outline: none;
	border-color: #0077ff;
	box-shadow: 0 0 0 3px rgba(0, 119, 255, 0.25);
}

label {
	margin-right: 10px;
	font-weight: 500;
	text-align: right;
}

.modal {
	display: none;
	position: fixed;
	z-index: 1000;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.6);
	justify-content: center;
	align-items: center;
}

.modal .buttons {
	display: flex;
	justify-content: space-between; /* buttons to edges */
	margin-top: 20px; /* some spacing from form fields */
}

.modal .buttons .button {
	flex: 0 0 auto; /* don't stretch buttons */
}

.modal-caption {
	position: absolute;
	bottom: 10px;
	right: 10px;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	padding: 5px 10px;
	border-radius: var(--border-radius);
	font-size: 0.9rem;
	max-width: 250px;
}

/* +++ MANAGE USERS PAGE +++ */
.userList {
	font-size: 16px;
	width: 95%;
	border-collapse: collapse;
	margin: 0 auto;
	max-height: 400px;
	overflow-y: auto;
}

.userList td,
userList th {
	text-align: left;
}

.userList thead th {
	position: sticky;
	top: 0;
}

.userList td:first-child,
.userList td:nth-child(10),
.userList td:nth-child(11) {
	text-align: center;
}

.modal-content {
	background: rgb(211, 235, 235);
	margin: 10% auto;
	padding: 10px;
	border-radius: var(--border-radius);
	width: 400px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.close {
	float: right;
	font-size: 24px;
	cursor: pointer;
}

.form-row {
	display: flex;
	align-items: center;
	margin: 20px;
	padding-bottom: 10px;
}

/* +++ MANAGE SETTINGS PAGE +++ */
.settingsTable {
	width: 80%;
	padding: 20px;
	border-collapse: collapse;
	border-spacing: 0;
	margin: 0 auto;
}

.settingsInput {
	font-size: 20px;
	text-align: center;
	width: 100%;
	margin: 0 auto;
	box-sizing: border-box;
}

/* +++ ALBUM PICKER PAGE +++ */

.albumSection .button {
	display: inline-block;
	padding: 6px 12px;
	margin-bottom: 10px;
	position: relative;
	left: 10%; /* aligns with 80% centered table (half of 20%) */
}

.albumPicker {
	width: 80%;
	padding: 20px;
	border-collapse: collapse;
	border-spacing: 0;
	margin: 0px auto;
	font-size: var(--display-font-size);
}

.albumPicker th,
.albumPicker td {
	text-align: left;
}

.albumPicker th:nth-child(3),
.albumPicker td:nth-child(3) {
	text-align: center;
}

/* +++ GALLERY +++ */
.albumHeader {
	position: relative;
	display: flex;
	flex-direction: column; /* stack heading + folder row */
	align-items: center; /* center heading horizontally */
}

.title-and-selector {
	display: flex;
	flex-direction: column;
	align-items: center; /* center the heading */
}

.title-and-selector h2 {
	margin: 0;
	text-align: center; /* center text */
}

/* absolute box on the right */
.album-toolbar {
	position: absolute;
	top: 3em;
	right: 0;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
}

.album-toolbar .button {
	width: 100%;
	margin-left: 0;
}

.folder-row {
	display: flex;
	align-items: center;
	gap: 8px;
	justify-content: flex-start; /* left align */
	width: 100%; /* full width under the header */
}

.folder-row label {
	margin: 0;
}

.gallery {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 20px;
}

span#photoFileName {
	display: inline-block;
	max-width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

img#modalImg {
	max-width: 90%;
	max-height: 90%;
	border: 4px solid white;
	border-radius: var(--border-radius);
}

.thumb {
	max-width: 200px;
	max-height: 200px;
	display: block;
	margin-bottom: 5px;
	cursor: pointer;
	border: 4px solid transparent;
}

.thumb.selected {
	border: 4px solid red; /* highlight */
}

#modal .prev,
#modal .next {
	position: absolute;
	top: 50%;
	background-color: rgba(0, 0, 0, 0.4);
	color: #fff;
	font-size: 30px;
	padding: 10px 15px;
	border: none;
	cursor: pointer;
	border-radius: var(--border-radius);
	user-select: none;
	transform: translateY(-50%);
	text-decoration: none;
}

#modal .prev {
	left: 20px;
}
#modal .next {
	right: 20px;
}

.page-container {
	display: flex;
	flex-direction: column;
	height: 100vh; /* full viewport */
}

.header-section {
	flex: 0 0 auto; /* size to content */
	border-bottom: 1px solid #ccc;
	padding: 10px;
}

.gallery-container {
	flex: 1 1 auto; /* fills remaining space */
	overflow-y: auto; /* only this part scrolls */
	padding: 10px;
}

.toggle-comments {
	position: absolute;
	bottom: 100px;
	right: 10px;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	border-radius: var(--border-radius);
	padding: 6px 12px;
	cursor: pointer;
	font-weight: 600;
	transition: background 0.2s;
}
.toggle-comments:hover {
	background: white;
}
.rotate-button {
	position: absolute;
	bottom: 60px;
	right: 10px;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	border-radius: var(--border-radius);
	padding: 6px 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
}
.rotate-button:hover {
	background: rgba(255, 255, 255, 1);
}

.modal-comments {
	position: absolute;
	bottom: 140px;
	right: 10px;
	width: 320px;
	max-height: 300px;
	background: rgba(255, 255, 255, 0.8);
	padding: 10px;
	border-radius: var(--border-radius);
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
	display: flex;
	flex-direction: column;
}

.comment-list {
	flex: 1;
	overflow-y: auto;
	margin-bottom: 8px;
	font-size: 0.9em;
	white-space: pre-line;
}

.comment-input {
	display: flex;
	gap: 6px;
}

.comment-input textarea {
	flex: 1;
	resize: none;
	padding: 6px;
	border-radius: var(--border-radius);
	border: 1px solid #ccc;
	font-size: 0.9em;
}

.comment-input button {
	padding: 6px 10px;
	border: none;
	border-radius: var(--border-radius);
	background: #007bff;
	color: white;
	cursor: pointer;
}

.comment-input button:hover {
	background: #0056b3;
}

/* +++ LOGIN PAGE +++ */
.login {
	margin: 100px auto 20px auto;
	width: fit-content;
}

.login .button {
	display: block;
	margin: 0 auto 10px;
}

.form-row {
	display: flex;
	align-items: center; /* Vertical center */
	margin-bottom: 10px;
}

.form-row label {
	width: 150px; /* fixed width for alignment */
	margin-right: 10px; /* spacing between label and input */
	text-align: right; /* optional: aligns text to right side of label box */
}

.form-row input {
	flex: 1; /* input takes remaining space */
}

.password-wrapper {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
}

.password-wrapper input {
	width: 100%
}

.password-wrapper .toggle {
	position: absolute;
	right: 10px;
	cursor: pointer;
	user-select: none;
	font-size: 1.2em;
}

/* +++ UPLOAD PAGE +++ */
.drop-zone {
	display: flex;
	align-items: center;
	gap: 30px;
	justify-content: center;
	border: 3px dashed #aaa;
	border-radius: var(--border-radius);
	padding: 30px;
	text-align: center;
	color: #666;
	cursor: pointer;
	width: 350px;
	margin-bottom: 15px;
	transition: background-color 0.3s, border-color 0.3s;
}
.drop-zone.dragover {
	background-color: #f0f8ff;
	border-color: #3399ff;
	color: #3399ff;
}
.drop-zone .browse {
	color: #007bff;
	text-decoration: underline;
	cursor: pointer;
}

/* +++ LOG VIEWER PAGE +++ */
.logViewer {
	width: calc(100vw - 40px);
	padding: 0 20px;
	table-layout: inherit;
	border-collapse: collapse;
	box-sizing: border-box;
	margin: 0 auto;
	font-size: var(--display-font-size);
}

.logViewer th {
	position: sticky;
	top: 0;
	background-color: wheat;
	text-align: left;
}

.logViewer td {
	text-align: left;
	border-bottom: 1px solid cornsilk;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.logViewer td:nth-last-child(1),
th:nth-last-child(1) {
	max-width: 60vw;
}

#scrollArea {
	width: 100%;
	height: 700px;
	overflow-y: scroll;
	overflow-x: auto;
	border: none;
}

select#logType {
	position: absolute;
	right: 0px;
	top: 0px;
	margin: 0.5rem;
	font-size: 30px;
	padding-right: 10px;
	width: 100px;
}

/* +++ STANDARD BUTTONS +++ */
.button {
	border: none;
	background-color: #28a745;
	color: white;
	font-weight: normal;
	cursor: pointer;
	display: inline-block;
	margin: 0;
	font-size: clamp(0.2rem, 1rem, 1.5rem);
	padding: clamp(0.2rem, 0.5rem, 1rem) clamp(0.2rem, 0.5rem, 1rem);
	border-radius: var(--border-radius);
}

.button:hover {
	background-color: #218838;
	transition: 0.7s;
}

.nav-links {
	font-size: var(--display-font-size);
	padding-top: 20px;
	display: flex; /* line them up horizontally */
	justify-content: center; /* center the whole group */
	gap: 40px; /* even gap between each link */
}

/* +++ MESSAGE INDICATOR +++ */
.msg-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.msg-icon {
  font-size: 16px;
}

.msg-text {
  white-space: nowrap;
}

.msg-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #2525d9; /* red */
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-badge.hidden {
  display: none;
}

.msg-separator {
  opacity: 0.4;
  margin: 0 4px;
}

.logout-link {
  text-decoration: none;
  color: inherit;
}

.logout-link:hover {
  text-decoration: underline;
}
