/* Import Cairo font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;700&display=swap');

/* Base Styles */
html {
  font-size: 100%;
  overflow-y: scroll;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-size: 14px;
  line-height: 1.6; /* Increased line-height for better readability */
  padding: 0;
  font-family: 'Cairo', sans-serif; /* Apply Cairo font */
  color: #333; /* Slightly softer black for better aesthetics */
  background: url('../images/page_bg.png') top left repeat-x #f0f2f5; /* Lighter background for a modern feel */
}

/* Universal font application */
body,
input,
select,
textarea,
button { /* Added button to ensure font consistency */
  font-family: 'Cairo', sans-serif;
  color: #333;
}

/* Headings and bold text */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700; /* Use bold weight for headings */
  color: #222;
  margin-bottom: 0.5em; /* Add some space below headings */
}

h1 {
  color: #007bff; /* Modern blue for main headings */
  font-size: 2.2em; /* Larger heading for prominence */
}

h2 {
  font-size: 1.8em;
  color: #333;
}

h3 {
  font-size: 1.5em;
}

b,
strong {
  font-weight: bold;
}

blockquote {
  margin: 1em 20px; /* Reduced margin for blockquote */
  padding-left: 15px;
  border-left: 4px solid #007bff;
  color: #555;
  font-style: italic;
}

hr {
  display: block;
  height: 1px;
  border: 0;
  border-top: 1px solid #eee; /* Lighter border for hr */
  margin: 1.5em 0;
  padding: 0;
}

small {
  font-size: 85%;
}

ul,
ol {
  margin: 1em 0;
  padding: 0 0 0 25px; /* Slightly reduced padding */
}

img {
  border: 0;
  vertical-align: middle;
  max-width: 100%; /* Essential for responsiveness */
  height: auto;
  display: block; /* Ensures images behave as blocks for easier centering */
}

form {
  margin: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

label {
  cursor: pointer;
  display: block; /* Labels as blocks for better form layout */
  margin-bottom: 5px;
}

input,
select,
textarea {
  font-size: 1em;
  padding: 8px 10px; /* Increased padding for better usability */
  border: 1px solid #ccc; /* Softer border */
  border-radius: 4px; /* Rounded corners for input fields */
  margin: 0;
  vertical-align: baseline;
  box-sizing: border-box; /* Include padding and border in the element's total width and height */
  width: 100%; /* Default to full width for better mobile experience */
}

input[type="checkbox"],
input[type="radio"] {
  width: auto; /* Override 100% width for checkboxes/radios */
}

input[type="button"],
input[type="reset"],
input[type="submit"] {
  cursor: pointer;
  -webkit-appearance: none; /* Reset default button styles */
  background: #007bff; /* Default button color */
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  transition: background-color 0.3s ease; /* Smooth transition on hover */
}

input[type="button"]:hover,
input[type="reset"]:hover,
input[type="submit"]:hover {
  background-color: #0056b3;
}

textarea {
  overflow: auto;
  vertical-align: top;
  resize: vertical;
  min-height: 100px; /* Minimum height for textareas */
}

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%; /* Ensure tables are responsive */
  margin-bottom: 1em;
}

th,
td {
  vertical-align: top;
  padding: 10px 8px; /* Consistent padding for table cells */
  border: 1px solid #eee; /* Lighter table borders */
  text-align: left;
}

th {
  font-weight: 600; /* Slightly bolder table headers */
  background-color: #f8f9fa; /* Light background for headers */
}

/* Typography */
a,
.link {
  color: #007bff;
  text-decoration: none;
  transition: color 0.3s ease, border-bottom 0.3s ease;
}

a:hover,
.link:hover {
  color: #0056b3;
  border-bottom: 1px dotted #0056b3;
  cursor: pointer;
}

/* Helpers */
.centered {
  text-align: center;
}

.clear {
  clear: both;
  height: 1px;
  visibility: hidden; /* Use hidden instead of none if you need layout space */
}

.hidden {
  display: none;
}

.faded {
  color: #888;
}

/* Pagination */
#pagination {
  border: 0;
  margin: 1.5em 0 2.5em 0; /* More vertical space */
  padding: 0;
  text-align: center; /* Center pagination */
}

#pagination li {
  list-style: none;
  display: inline-block; /* Use inline-block for better spacing control */
  margin: 0 4px; /* Space between page numbers */
}

#pagination li a,
#pagination .active,
#pagination .previousOff,
#pagination .nextOff {
  display: block;
  padding: 6px 12px;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#pagination li a {
  color: #007bff;
  background-color: #e9ecef;
}

#pagination li a:hover {
  color: #fff;
  background-color: #007bff;
}

#pagination .previousOff,
#pagination .nextOff {
  color: #6c757d;
  background-color: #f8f9fa;
  cursor: not-allowed;
  font-weight: normal;
}

#pagination .active {
  color: #fff;
  background-color: #007bff;
  font-weight: bold;
}

#pagination .next a,
#pagination .previous a {
  font-weight: bold;
}

/* Alerts & Notices */
#msg_notice,
#msg_warning,
.warning-banner,
#msg_error,
#msg_info {
  margin: 0 0 15px 0; /* Consistent bottom margin */
  padding: 10px 15px 10px 45px; /* More padding for better spacing */
  line-height: 1.4;
  border-radius: 5px;
  background-size: 24px; /* Icon size */
  background-position: 15px center; /* Icon position */
  background-repeat: no-repeat;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Subtle shadow for alerts */
}

#msg_notice {
  border: 1px solid #28a745;
  background-image: url('../images/icons/ok.png');
  background-color: #d4edda;
  color: #155724;
}

#msg_warning,
.warning-banner {
  border: 1px solid #ffc107;
  background-image: url('../images/icons/alert.png');
  background-color: #fff3cd;
  color: #856404;
}

#msg_error {
  border: 1px solid #dc3545;
  background-image: url('../images/icons/error.png');
  background-color: #f8d7da;
  color: #721c24;
}

#msg_info {
  border: 1px solid #17a2b8;
  background-image: url('../images/icons/info.png'); /* Assuming you have an info icon */
  background-color: #d1ecf1;
  color: #0c5460;
}

.warning {
  background: #fff8dc;
  font-style: italic;
  padding: 10px;
  border: 1px solid #ffecb5;
  border-radius: 4px;
}

.warning strong {
  text-transform: uppercase;
  color: #dc3545;
  font-style: normal;
}

.error {
  color: #dc3545;
}

.error input {
  border: 1px solid #dc3545;
}

/* Buttons */
.button,
.button:visited {
  display: inline-flex; /* Use flexbox for better content alignment */
  align-items: center;
  justify-content: center;
  font-size: 1em; /* Adjusted font size */
  padding: 8px 20px; /* Adjusted padding */
  text-align: center;
  color: #fff;
  text-decoration: none;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* Softer shadow */
  text-shadow: none; /* Removed text shadow */
  border-bottom: none; /* Removed border bottom */
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease; /* Smooth transitions for all properties */
}

.button:hover {
  transform: translateY(-2px); /* Slight lift effect on hover */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.button:active {
  top: 1px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transform: translateY(0);
}

.green.button,
.green.button:visited {
  background-color: #28a745;
}

.green.button:hover {
  background-color: #218838;
}

.blue.button,
.blue.button:visited {
  background-color: #007bff;
}

.blue.button:hover {
  background-color: #0056b3;
}

/* Layout */
body {
  background: url('../images/page_bg.png') top left repeat-x #f0f2f5;
}

#container {
  background: #fff;
  width: 80%; /* Default desktop width, adjusted by media query */
  max-width: 1200px; /* Max width for larger screens */
  margin: 20px auto; /* Add margin top/bottom for breathing room */
  border-radius: 8px; /* Rounded corners for the main container */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Softer, more modern shadow */
  overflow: hidden; /* Clear floats inside */
}

#header {
  position: relative;
  height: 80px; /* Slightly increased height */
  padding: 0 20px;
  display: flex; /* Use flexbox for centering logo and text */
  align-items: center; /* Vertically center items */
  justify-content: center; /* Horizontally center items */
  background-color: #fff;
  border-bottom: 1px solid #eee; /* Subtle border below header */
}

#logo {
  height: 100%;
  display: flex; /* Flexbox for logo content */
  align-items: center;
  justify-content: center;
}

#header #logo img {
  max-height: 60px; /* Adjusted logo size */
  max-width: 300px;
  width: auto;
  height: auto;
  vertical-align: middle;
}

#header p {
  margin: 0;
  padding: 0 0 0 20px; /* Added padding to separate from logo */
  text-align: left;
}

/* Navigation */
#nav {
  margin: 0; /* Remove side margins for full width on mobile */
  padding: 0; /* Reset padding to be controlled by li a */
  height: auto; /* Allow height to adjust for content */
  background: #f8f9fa; /* Lighter background for nav */
  border-top: 1px solid #e9ecef;
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.05); /* Subtle inner shadow */
  display: flex; /* Use flexbox for nav items */
  justify-content: space-around; /* Distribute items evenly */
  align-items: center;
  flex-wrap: wrap; /* Allow items to wrap on smaller screens */
}

#nav li {
  margin: 0;
  padding: 0;
  list-style: none;
  flex-grow: 1; /* Allow items to grow to fill space */
  text-align: center;
}

#nav li a {
  display: block; /* Make links fill their list item space */
  width: auto;
  height: 40px; /* Larger touch target */
  line-height: 40px;
  text-align: center;
  padding: 0 10px 0 40px; /* Adjusted padding for larger icon space */
  color: #555;
  border-radius: 0; /* Remove border-radius here, apply to container if needed */
  background-position: 10px center; /* Center icon vertically */
  background-size: 24px 24px; /* Icon size */
  background-repeat: no-repeat;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.rtl #nav li a {
  background-position: calc(100% - 10px) center;
  padding-left: 10px;
  padding-right: 40px;
}

#nav li a.active,
#nav li a:hover {
  background-color: #e2f0ff; /* Lighter hover/active state */
  color: #007bff;
}

#nav li a.home {
  background-image: url('../images/icons/home.png');
}
#nav li a.kb {
  background-image: url('../images/icons/kb.png');
}
#nav li a.new {
  background-image: url('../images/icons/new.png');
}
#nav li a.status {
  background-image: url('../images/icons/status.png');
}
#nav li a.tickets {
  background-image: url('../images/icons/tix.png');
}

#content {
  padding: 30px; /* Increased padding */
  margin: 0;
  height: auto !important;
  min-height: 400px; /* Increased min-height */
  box-sizing: border-box; /* Ensure padding is included in height */
}

#footer {
  text-align: center;
  font-size: 0.9em;
  color: #777;
  padding: 20px 0; /* Added padding */
  border-top: 1px solid #eee;
  background-color: #f8f9fa;
}

#footer a {
  color: #777;
  text-decoration: underline;
}

#footer p {
  margin: 5px 0 0 0;
}

#footer #poweredBy {
  display: block;
  width: 126px;
  height: 23px;
  outline: none;
  text-indent: -9999px;
  margin: 10px auto; /* Centered with margin */
  background: url('../images/poweredby.png') top left no-repeat;
  background-size: auto 20px;
  opacity: 0.8; /* Slightly faded for better integration */
}

/* Landing Page Specifics */
.front-page-buttons-container { /* New container to center buttons */
  display: flex;
  justify-content: center; /* Center horizontally */
  align-items: flex-start; /* Align items to the top */
  flex-wrap: wrap; /* Allow wrapping on smaller screens */
  margin-top: 40px;
}

#landing_page #new_ticket,
#landing_page #check_status {
  width: 320px; /* Slightly wider buttons */
  padding: 20px; /* More padding */
  padding-top: 80px; /* Space for the background icon */
  background-position: center 20px; /* Center icon at the top */
  background-repeat: no-repeat;
  text-align: center;
  margin: 0 15px 30px; /* Spacing between buttons */
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  transition: all 0.3s ease;
}

#landing_page #new_ticket:hover,
#landing_page #check_status:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.12);
}

#landing_page #new_ticket {
  background-image: url('../images/new_ticket_icon.png');
}
#landing_page #check_status {
  background-image: url('../images/check_status_icon.png');
}

#landing_page h1,
#landing_page h2,
#landing_page h3 {
  margin-bottom: 15px;
  text-align: center; /* Center main landing page headings */
}

/* FAQ Section */
#faq {
  clear: both;
  margin: 20px 0;
  padding: 15px;
  background-color: #f9f9f9;
  border-radius: 8px;
  border: 1px solid #eee;
}

#faq ol {
  font-size: 1.1em;
  margin-left: 0;
  padding-left: 0;
  border-top: 1px solid #ddd;
}

#faq ol li {
  list-style: none;
  margin: 0;
  padding: 0;
  color: #666;
}

#faq ol li a {
  display: flex; /* Use flexbox for icon and text alignment */
  align-items: center;
  padding: 10px 0;
  height: auto !important;
  overflow: hidden;
  margin: 0;
  border-bottom: 1px solid #eee;
  line-height: 1.4;
  padding-left: 0;
  background: none; /* Remove old background icon */
  color: #333;
}

#faq ol li a:before { /* New icon for FAQ list items */
  content: "•"; /* Or use a FontAwesome icon */
  font-size: 1.2em;
  color: #007bff;
  margin-right: 10px;
}

#faq ol li a:hover {
  background-color: #eaf6ff; /* Lighter hover background */
  color: #0056b3;
}

#faq .article-meta {
  padding: 8px 10px;
  background: #fdfdfd;
  font-size: 0.9em;
  color: #888;
  border-top: 1px solid #eee;
}

/* Knowledge Base */
#kb {
  margin: 15px 0;
  padding: 10px;
  overflow: hidden;
}

#kb > li {
  padding: 15px;
  height: auto !important;
  overflow: hidden;
  margin-bottom: 10px;
  background: #fff; /* Solid background */
  border: 1px solid #eee;
  border-radius: 8px;
  display: flex; /* Use flex for icon and content */
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#kb > li:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

#kb > li h4 {
  margin: 0;
  flex-grow: 1; /* Allow h4 to take available space */
}

#kb > li h4 span {
  color: #777;
  font-weight: normal;
}

#kb > li h4 a {
  font-size: 1.2em;
  color: #007bff;
  text-decoration: none;
}

#kb > li > i {
  display: flex; /* Use flexbox for centering icon */
  align-items: center;
  justify-content: center;
  width: 48px; /* Larger icon container */
  height: 48px;
  flex-shrink: 0; /* Prevent icon from shrinking */
  margin-right: 15px; /* More space */
  background: #e9f0ff; /* Light background for icon */
  border-radius: 50%; /* Make it round */
  color: #007bff; /* Icon color */
  font-size: 2em; /* Larger icon font size */
  background-image: url(../images/kb_large_folder.png); /* Fallback image */
  background-size: 60%;
  background-position: center;
  background-repeat: no-repeat;
}

.featured-category {
  margin-top: 20px;
  width: 48%; /* Slightly less to prevent overflow with margins */
  display: inline-block;
  box-sizing: border-box;
  vertical-align: top;
  padding: 15px;
  border: 1px solid #eee;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-right: 2%; /* Space between columns */
}
.featured-category:nth-child(2n) {
    margin-right: 0; /* No right margin for the second column */
}

.category-name {
  display: inline-block;
  font-weight: 600;
  font-size: 1.3em;
  color: #007bff;
  margin-bottom: 10px;
}

.featured-category i {
  color: #007bff;
  text-shadow: none; /* Removed text shadow */
  display: inline-block;
  vertical-align: middle;
  font-size: 1.5em; /* Larger icon */
  margin-right: 8px;
}

.article-headline {
  margin-left: 0; /* Reset margin */
  padding-left: 34px; /* Use padding for alignment with icons */
  font-size: 1.1em;
  margin-bottom: 5px;
}

.rtl .article-headline {
  margin-left: 0;
  padding-right: 34px;
  padding-left: 0;
}

.article-teaser {
  font-size: 0.9em;
  line-height: 1.4em;
  height: auto; /* Allow full text to show, or use fixed height with ellipsis */
  max-height: 3.5em; /* Max lines for teaser */
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 34px; /* Align with icon space */
  color: #666;
}

.rtl .article-teaser {
  margin-left: 0;
  margin-right: 34px;
}

.article-title {
  font-weight: 600;
  color: #333;
}

.faq-content .article-title {
  font-size: 1.8em;
  margin-top: 15px;
  color: #007bff;
}

/* KB Search */
#kb-search {
  padding: 20px;
  background-color: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.05);
}

#kb-search div {
  clear: both;
  overflow: hidden;
  padding-top: 10px;
  display: flex; /* Use flex for alignment of search inputs */
  flex-wrap: wrap;
  gap: 10px; /* Space between flex items */
}

#kb-search #query,
#kb-search #cid,
#kb-search #topic-id {
  flex: 1 1 200px; /* Allow items to grow/shrink, with a base of 200px */
  margin-right: 0; /* Remove fixed margin */
}

#kb-search #topic-id {
  flex-basis: 100%; /* Take full width if needed */
}

#kb-search #searchSubmit {
  flex-basis: auto; /* Allow button to take its natural width */
  position: static; /* Remove relative positioning */
  margin-top: 10px; /* Space above button */
  width: auto;
}

#kb-search #breadcrumbs {
  color: #666;
  margin-bottom: 15px;
  font-size: 0.9em;
}

#kb-search #breadcrumbs a {
  color: #007bff;
}

/* Forms (Ticket Form, Client Login) */
#ticketForm div.clear,
#clientLogin div.clear {
  clear: both;
  padding: 5px 0;
  overflow: hidden;
}

#ticketForm div input,
#clientLogin div input,
#ticketForm div textarea,
#clientLogin div textarea {
  width: 100%; /* Full width for inputs in forms */
  max-width: 600px; /* Max width for consistency */
  border: 1px solid #ddd;
  background: #fefefe;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 10px;
}

#ticketForm div input[type=file],
#clientLogin div input[type=file] {
  border: 0;
  padding: 0;
  margin-bottom: 0;
}

#ticketForm div select,
#clientLogin div select {
  width: 100%;
  max-width: 600px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 10px;
}

#ticketForm div div.captchaRow,
#clientLogin div div.captchaRow {
  display: flex; /* Use flexbox for captcha row */
  align-items: center;
  gap: 10px;
  line-height: normal;
}

#ticketForm div div.captchaRow input,
#clientLogin div div.captchaRow input {
  position: static; /* Remove relative positioning */
  margin-bottom: 0;
  flex-grow: 1; /* Allow input to grow */
  max-width: 150px; /* Max width for captcha input */
}

#ticketForm > table,
#clientLogin > table {
  width: 100%;
  table-layout: fixed;
}

#ticketForm > table td,
#clientLogin > table td {
  width: auto; /* Allow columns to adapt */
  padding: 8px;
}

#ticketForm > table td:first-child,
#clientLogin > table td:first-child {
  width: 180px; /* Fixed width for labels */
  font-weight: 600;
  color: #555;
}

#ticketForm td textarea,
#clientLogin td textarea,
#ticketForm div textarea,
#clientLogin div textarea {
  width: 100%;
  max-width: none; /* Allow textarea to expand within its cell */
  min-height: 150px;
}

#ticketForm td em,
#clientLogin td em,
#ticketForm div em,
#clientLogin div em {
  color: #777;
  font-size: 0.9em;
  display: block;
  margin-top: 5px;
}

#ticketForm td .captcha,
#clientLogin td .captcha,
#ticketForm div .captcha,
#clientLogin div .captcha {
  width: 100px; /* Larger captcha image space */
  height: 40px; /* Consistent height */
  background: #000;
  display: block;
  flex-shrink: 0; /* Prevent captcha image from shrinking */
  margin-right: 0;
  border-radius: 4px;
}

#ticketForm td label.inline,
#clientLogin td label.inline,
#ticketForm div label.inline,
#clientLogin div label.inline {
  width: auto;
  padding: 0 10px;
  display: inline-flex; /* Use inline flex for better alignment */
  align-items: center;
}
#ticketForm td label.inline input,
#clientLogin td label.inline input {
    width: auto; /* Reset width for inline inputs */
    margin-right: 5px;
    margin-bottom: 0;
}

#ticketForm div.error input,
#clientLogin div.error input {
  border: 1px solid #dc3545;
}

#ticketForm div.error label,
#clientLogin div.error label {
  color: #dc3545;
}

/* Ticket Table */
#ticketTable {
  border: 1px solid #ddd; /* Softer border */
  border-radius: 8px; /* Rounded corners for the table */
  overflow: hidden; /* Ensures rounded corners are visible */
  margin-bottom: 20px;
}

#ticketTable caption {
  padding: 12px 15px;
  text-align: left;
  color: #fff; /* White text on blue background */
  background: #007bff; /* Primary blue background */
  border: none;
  font-weight: bold;
  font-size: 1.1em;
}

#ticketTable th {
  height: auto;
  line-height: normal;
  background: #e9f0ff; /* Lighter background for table headers */
  border: 1px solid #ddd;
  padding: 10px 15px;
  font-weight: 600;
  color: #333;
}
#ticketTable th:first-child {
    border-top-left-radius: 8px;
}
#ticketTable th:last-child {
    border-top-right-radius: 8px;
}

#ticketTable th a {
  color: #007bff;
  text-decoration: none;
}

#ticketTable td {
  padding: 10px 15px;
  border: 1px solid #eee;
}

#ticketTable tr.alt td {
  background: #fcfcfc; /* Very light alternative row background */
}

/* Client Login */
#clientLogin {
  display: flex; /* Use flexbox for layout */
  flex-wrap: wrap; /* Allow wrapping */
  margin-top: 30px;
  padding: 30px; /* More padding */
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1); /* Softer shadow */
  background: #fefefe;
  background-image: url('../images/lock.png'); /* Lock icon */
  background-size: 80px; /* Larger icon */
  background-position: calc(100% - 30px) center; /* Positioned to the right */
  background-repeat: no-repeat;
}

.rtl #clientLogin {
  background-position: 30px center; /* Positioned to the left in RTL */
}

#clientLogin .instructions {
  flex: 1 1 50%; /* Take half width, allow grow/shrink */
  padding-right: 120px; /* Space for the icon */
  box-sizing: border-box;
}

.rtl #clientLogin .instructions {
  padding-left: 120px;
  padding-right: 0;
}

#clientLogin p {
  clear: both;
  margin-bottom: 10px;
}

#clientLogin strong {
  font-size: 1em;
  color: #dc3545;
  display: block;
  margin-bottom: 10px;
}

#clientLogin #email,
#clientLogin #ticketno {
  margin-right: 0;
  width: 100%;
  max-width: 300px; /* Max width for input fields */
}

#clientLogin input[type=text],
#clientLogin input[type=password] {
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 15px;
  border: 1px solid #ccc;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.075);
}

#clientLogin input[type=submit] {
  padding: 10px 20px;
  border-radius: 5px;
  background-color: #007bff;
  color: #fff;
  border: none;
  transition: background-color 0.3s ease;
}
#clientLogin input[type=submit]:hover {
    background-color: #0056b3;
}

/* Reply Section */
#reply {
  margin-top: 20px;
  padding: 20px;
  background: #fdfdfd;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

#reply h2 {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee; /* Softer border */
  color: #007bff;
  font-size: 1.5em;
}

#reply > table {
  width: 100%; /* Full width for reply table */
}

#reply table td {
  vertical-align: top;
  padding: 8px 0;
}
#reply table td:first-child {
    width: 150px; /* Adjust label column width */
}

#reply textarea {
  width: 100% !important; /* Full width for reply textarea */
  max-width: none;
  min-height: 200px; /* Larger reply area */
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  padding: 10px;
  box-sizing: border-box;
}

#reply input[type=text],
#reply #response_options textarea {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 4px;
  padding: 10px;
  box-sizing: border-box;
}

/* Ticket Icons */
.Icon {
  padding-left: 28px; /* More space for icon */
  background-size: 20px; /* Consistent icon size */
  background-position: left center;
  background-repeat: no-repeat;
  color: #007bff; /* Primary color for icons */
  text-decoration: none;
  display: inline-flex; /* Use flexbox for icon and text alignment */
  align-items: center;
  gap: 5px; /* Space between icon and text */
}

.Icon.Ticket { background-image: url('../images/icons/ticket.gif'); }
.Icon.webTicket { background-image: url('../images/icons/ticket_source_web.gif'); }
.Icon.emailTicket { background-image: url('../images/icons/ticket_source_email.gif'); }
.Icon.phoneTicket { background-image: url('../images/icons/ticket_source_phone.gif'); }
.Icon.otherTicket, .Icon.apiTicket { background-image: url('../images/icons/ticket_source_other.gif'); }
.Icon.attachment { background-image: url('../images/icons/attachment.gif'); }
.Icon.file { background-image: url('../images/icons/attachment.gif'); }
.Icon.refresh { background-image: url('../images/icons/refresh.gif'); }
.Icon.thread {
  font-weight: bold;
  font-size: 1.1em;
  background-image: url('../images/icons/thread.gif');
}

i.refresh {
  color: #28a745;
  font-size: 90%;
  vertical-align: middle;
}

.states small {
  font-size: 75%;
  color: #6c757d;
}

.active.state {
  font-weight: bold;
  color: #007bff;
}

.search.well {
  padding: 15px;
  background-color: #f8f9fa;
  margin-bottom: 15px;
  margin-top: 0;
  border-radius: 8px;
  border: 1px solid #eee;
}

.infoTable {
  background: #e9f0ff; /* Lighter background */
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.infoTable th {
  text-align: left;
  padding: 10px 15px;
  background-color: #d1e2ff; /* Slightly darker header for info table */
  color: #333;
}
.infoTable td {
    padding: 10px 15px;
}

.action-button {
  border-radius: 5px;
  color: #555 !important;
  display: inline-flex;
  align-items: center;
  border: 1px solid #ccc;
  cursor: pointer;
  font-size: 0.9em;
  background-color: #f0f0f0;
  background-image: linear-gradient(to bottom, #fefefe 0%, #e0e0e0 100%);
  padding: 6px 12px; /* Adjusted padding */
  text-decoration: none;
  line-height: normal;
  margin-left: 8px; /* More space */
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}
.action-button:hover {
    background-image: linear-gradient(to bottom, #e0e0e0 0%, #fefefe 100%);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.action-button span,
.action-button a {
  color: #555 !important;
  display: inline-block;
  float: none; /* Reset float */
}

.action-button a {
  text-decoration: none;
}

table.padded tr > td,
table.padded tr > th {
  height: auto;
  padding-bottom: 8px;
  padding-top: 8px;
}

.external-auth + .external-auth {
  margin-top: 8px; /* More space between external auth options */
}

a.external-sign-in {
  text-decoration: none;
  display: block; /* Make it block to take full width */
}

.external-auth-box {
  vertical-align: middle;
  border-radius: 5px;
  border: 1px solid #ddd;
  display: flex; /* Use flexbox for layout */
  align-items: center;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: all 0.2s ease;
}
.external-auth-box:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.external-auth-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  width: 45px; /* Larger icon area */
  height: 45px;
  padding: 5px;
  border-right: 1px solid #eee;
  background-color: #f8f9fa;
  flex-shrink: 0;
}

.external-auth-name {
  color: #333;
  flex-grow: 1; /* Allow name to take remaining space */
  padding: 5px 15px;
  line-height: 1.4;
  font-size: 1em;
  font-weight: 600;
}

img.sign-in-image {
  border: none;
  max-height: 30px; /* Adjusted image size */
  max-width: 120px;
  width: auto;
  height: auto;
}

.login-box {
  width: 48%; /* Slightly less than 50% for spacing */
  display: table-cell; /* Kept for compatibility, consider flex in outer container */
  box-shadow: 6px 0 10px -10px rgba(0,0,0,0.2); /* Softer shadow */
  padding: 20px;
  box-sizing: border-box;
}

.rtl .login-box {
  box-shadow: -6px 0 10px -10px rgba(0,0,0,0.2);
}

.flush-right { text-align: right; }
.flush-left { text-align: left; }

.sidebar {
  margin-bottom: 25px;
  margin-left: 20px;
  width: 280px; /* Wider sidebar */
  float: right; /* Default float */
}

.rtl .sidebar {
  margin-left: 0;
  margin-right: 20px;
  float: left;
}

.sidebar .content {
  padding: 15px;
  border: 1px solid #dbe2ed; /* Softer border */
  background: #f7f9fc; /* Lighter background */
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.sidebar .content:empty {
  display: none;
}

.sidebar section .header {
  font-weight: 700;
  margin-bottom: 0.5em;
  color: #007bff;
  font-size: 1.1em;
  border-bottom: 1px dashed #eee;
  padding-bottom: 5px;
}

.sidebar section + section {
  margin-top: 25px;
}

.search-form {
  padding-top: 15px;
}

.searchbar .search,
.search-form .search {
  display: block; /* Make search inputs block level for better flow */
  width: 100%; /* Full width */
  border-radius: 5px;
  border: 1px solid #ccc;
  padding: 10px 15px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.075);
  box-sizing: border-box;
  margin-bottom: 10px;
}

.bleed {
  margin: 0 !important;
  padding: 0 !important;
}

.row {
  display: flex; /* Use flexbox for row layout */
  flex-wrap: wrap;
  margin: 0 -10px; /* Counteract padding from children */
}
.row > [class*="span"] {
    padding: 0 10px; /* Add padding to children */
}

.span4 {
  width: 33.333%; /* Standard 1/3 width */
  box-sizing: border-box;
}

.span8 {
  width: 66.666%; /* Standard 2/3 width */
  box-sizing: border-box;
}

.truncate {
  display: inline-block;
  width: auto;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.image-hover a.action-button:hover,
.image-hover a.action-button {
  color: inherit !important;
  text-decoration: none;
}

table.custom-data {
  margin-top: 20px;
  border-collapse: separate; /* Allow border-radius on cells */
  border-spacing: 0;
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden; /* For rounded corners */
}

table.custom-data th {
  width: 25%;
  background-color: #f8f9fa;
  padding: 12px 15px;
  font-weight: 600;
  color: #555;
}
table.custom-data td {
    padding: 12px 15px;
    border-top: 1px solid #eee;
}

table .headline,
table.custom-data .headline {
  border-bottom: 1px solid #ddd; /* Softer border */
  font-weight: bold;
  background-color: #f0f0f0; /* Lighter background */
  padding: 10px 15px;
  color: #333;
}

#ticketInfo h1 {
  padding-bottom: 15px;
  margin-bottom: 15px;
  border-bottom: 1px dashed #ddd; /* Dashed border */
  font-size: 2em;
  color: #007bff;
}

#ticketInfo h1 small {
  font-weight: normal;
  color: #6c757d;
  font-size: 0.6em;
  display: block; /* Move small to new line */
}

/* Thread Entries */
.thread-entry {
  margin-bottom: 25px;
  display: flex; /* Use flexbox for avatar and content */
  align-items: flex-start;
  gap: 15px; /* Space between avatar and content */
}

.thread-entry.response {
  flex-direction: row-reverse; /* Avatar on the right for responses */
}

.thread-entry > .avatar {
  flex-shrink: 0; /* Prevent avatar from shrinking */
  width: 50px; /* Consistent avatar size */
  height: 50px;
  border-radius: 50%; /* Make avatar round */
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  background-color: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thread-entry.response > .avatar {
    margin-left: 0; /* Reset margin */
    margin-right: 0; /* Reset margin */
}

img.avatar {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Ensure image covers the avatar circle */
}

.thread-entry .header {
  flex-grow: 1; /* Header takes remaining space */
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 8px 8px 0 0;
  background-color: #f0f4f8; /* Light background for general thread entry */
  position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  font-size: 0.95em;
  color: #555;
}

/* Speech bubble arrows */
.thread-entry .header:before {
  content: '';
  position: absolute;
  top: 15px; /* Adjust vertical position */
  border-style: solid;
  border-width: 8px 0 8px 8px; /* Arrow pointing right */
  border-color: transparent transparent transparent #ddd;
  left: -8px; /* Position to the left */
}
.thread-entry .header:after {
    content: '';
    position: absolute;
    top: 15px;
    border-style: solid;
    border-width: 8px 0 8px 8px;
    border-color: transparent transparent transparent #f0f4f8; /* Matches header background */
    left: -7px;
}


.thread-entry.response .header {
  background: #e9f0ff; /* Lighter background for responses */
}
.thread-entry.response .header:before {
    border-width: 8px 8px 8px 0; /* Arrow pointing left */
    border-color: transparent #ddd transparent transparent;
    right: -8px; /* Position to the right */
    left: auto;
}
.thread-entry.response .header:after {
    border-width: 8px 8px 8px 0;
    border-color: transparent #e9f0ff transparent transparent; /* Matches response header background */
    right: -7px;
    left: auto;
}

.thread-entry.message .header {
  background: #dbeaff; /* Distinct color for messages */
}
.thread-entry.message .header:before {
    border-color: transparent transparent transparent #add0ff; /* Darker border for message arrow */
}
.thread-entry.message .header:after {
    border-color: transparent transparent transparent #dbeaff; /* Matches message header background */
}

.thread-entry .header .title {
  max-width: none; /* Allow title to take full width */
  display: block; /* Make title block level */
  margin-left: 0;
  font-weight: 600;
  color: #333;
}
.thread-entry .header .time {
    font-size: 0.85em;
    color: #888;
    margin-top: 5px;
    display: block;
}


.thread-entry .thread-body {
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 15px;
  background-color: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  flex-grow: 1; /* Body takes remaining space */
}
.thread-entry.response .thread-body {
    border-radius: 0 0 8px 8px; /* Same rounding for responses */
}

.thread-body .attachments {
  background-color: #f7f9fc; /* Light background for attachments */
  margin: 15px -15px -15px; /* Extend to edges of body, adjust top margin */
  padding: 10px 15px;
  border-top: 1px dotted #e0e0e0;
  border-radius: 0 0 8px 8px;
}
.thread-body .attachments:empty {
    display: none; /* Hide if no attachments */
}

.thread-body .attachments .filesize {
  margin-left: 0.8em;
  color: #777;
  font-size: 0.9em;
}

.thread-body .attachments a,
.thread-body .attachments a:hover {
  text-decoration: none;
  color: #007bff;
}

.thread-body .attachment-info {
  margin-right: 15px;
  display: inline-flex; /* Use inline-flex for icon and filename */
  align-items: center;
  width: auto;
  max-width: 48%; /* Max width for each item */
  gap: 5px;
  white-space: nowrap; /* Prevent wrapping */
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}
.thread-body .attachment-info:last-child {
    margin-bottom: 0;
}
.thread-body .attachment-info .filename {
  max-width: calc(100% - 30px); /* Account for icon width */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label {
  font-size: 0.8em; /* Smaller label font */
  padding: 3px 8px; /* More padding */
  border-radius: 4px;
  font-weight: bold;
  line-height: 1;
  color: #fff;
  vertical-align: middle;
  white-space: nowrap;
  text-shadow: none;
  background-color: #6c757d; /* Default gray label */
}

.label-bare {
  background-color: transparent;
  border: 1px solid #6c757d;
  color: #6c757d;
  text-shadow: none;
}

.thread-event {
  padding: 10px 0 20px; /* Adjusted padding */
  margin-left: 65px; /* Offset for timeline */
  position: relative;
}
.thread-event:last-child {
    padding-bottom: 0; /* No padding at the very end */
}

.type-icon {
  border-radius: 50%; /* Round icon */
  background-color: #e9ecef;
  padding: 8px; /* More padding for a larger circle */
  margin-right: 10px;
  text-align: center;
  display: flex; /* Flex for centering content */
  align-items: center;
  justify-content: center;
  font-size: 1.2em; /* Larger icon font */
  border: 1px solid #dee2e6;
  vertical-align: top;
  width: 40px; /* Fixed width and height for circle */
  height: 40px;
  flex-shrink: 0;
  position: absolute; /* Position icon relative to timeline */
  left: -65px; /* Pull it into the timeline */
  top: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
}

.type-icon.dark {
  border-color: #495057;
  background-color: #343a40;
  color: #fff;
}

.thread-event img.avatar {
  vertical-align: middle;
  border-radius: 3px;
  width: 32px; /* Consistent small avatar size */
  height: 32px;
  margin: -3px 5px 0 0;
  object-fit: cover;
}

.thread-event .description {
  margin-left: 0; /* Reset margin */
  padding-top: 0;
  padding-left: 0;
  display: flex; /* Use flex for icon and text */
  align-items: center;
  flex-grow: 1;
  line-height: 1.5em;
  color: #444;
}
.thread-event .description p {
    margin: 0; /* Remove default paragraph margins */
}
.thread-event .description .meta {
    font-size: 0.85em;
    color: #888;
    margin-left: 10px;
}

/* Timeline specific styling */
#ticketThread {
  z-index: 0;
  position: relative;
  padding-left: 80px; /* Space for the timeline line */
  border-bottom: 1px solid #eee; /* Subtle bottom border for the whole thread */
  margin-bottom: 20px;
}

#ticketThread::before {
  border-left: 2px solid #e0e0e0; /* Timeline line */
  position: absolute;
  top: 0;
  bottom: 0;
  left: 55px; /* Position the line in the center of icons */
  content: "";
  z-index: -1;
}

.freetext-files {
  padding: 15px;
  margin-top: 20px;
  border: 1px dashed #e0e0e0;
  border-radius: 8px;
  background-color: #fcfcfc;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}

.freetext-files .file {
  margin-right: 15px;
  display: inline-flex; /* Inline flex for icon and filename */
  align-items: center;
  width: calc(50% - 15px); /* Adjusted width for two columns with gap */
  padding-top: 0.5em;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.freetext-files .file:nth-child(2n) {
    margin-right: 0;
}

.freetext-files .title {
  font-weight: bold;
  margin-bottom: 0.5em;
  font-size: 1.2em;
  color: #007bff;
}


/* Responsive Media Queries */
@media (min-width: 992px) {
  #container {
    width: 70%; /* Desktop width: 70% */
  }

  /* Desktop specific layout adjustments */
  .main-content {
    width: calc(100% - 320px); /* Adjusted width to account for sidebar */
    float: left;
    padding-right: 20px; /* Space between main content and sidebar */
    box-sizing: border-box;
  }
  .sidebar {
      float: right;
      margin-left: 0;
  }
  .rtl .main-content {
      float: right;
      padding-right: 0;
      padding-left: 20px;
  }
  .rtl .sidebar {
      float: left;
  }

  /* Adjustments for buttons when centered in desktop view */
  .front-page-buttons-container {
      flex-direction: row;
      justify-content: center;
      margin-top: 60px; /* More space above buttons on desktop */
  }
  #landing_page #new_ticket,
  #landing_page #check_status {
      margin: 0 20px; /* Consistent margin for spacing between buttons */
  }
}

@media (max-width: 991px) {
  /* General mobile adjustments */
  body {
    font-size: 16px; /* Larger base font for mobile readability */
  }
  h1 { font-size: 1.8em; }
  h2 { font-size: 1.5em; }
  h3 { font-size: 1.3em; }

  #container {
    width: 100%; /* Full width on mobile */
    margin: 0; /* Remove margin */
    border-radius: 0; /* No rounded corners for full screen */
    box-shadow: none; /* No shadow */
  }

  #header {
    height: auto;
    padding: 15px;
    flex-direction: column; /* Stack logo and text vertically */
    text-align: center;
  }

  #header #logo img {
    max-height: 50px;
    margin-bottom: 10px;
  }

  #header p {
    padding: 0;
  }

  /* Mobile Navigation as Icons */
  #nav {
    flex-wrap: nowrap; /* Prevent wrapping for fixed icon row */
    overflow-x: auto; /* Allow horizontal scroll if too many items */
    -webkit-overflow-scrolling: touch;
    justify-content: space-between; /* Distribute items with space */
    padding: 0 10px; /* Add slight padding on sides */
  }

  #nav li {
    flex-basis: 20%; /* Each item takes 20% for 5 items */
    min-width: 60px; /* Minimum width for each icon */
  }

  #nav li a {
    padding: 5px 0; /* Adjust padding for icon-only display */
    height: 60px; /* Larger touch target for icons */
    line-height: normal;
    text-indent: -9999px; /* Hide text */
    overflow: hidden;
    white-space: nowrap; /* Prevent text from wrapping if not hidden */
    background-position: center 10px; /* Center icon vertically */
    background-size: 32px 32px; /* Larger icons for touch */
  }

  .rtl #nav li a {
    background-position: center 10px;
  }

  /* Front page buttons mobile */
  .front-page-buttons-container {
      flex-direction: column; /* Stack buttons vertically */
      align-items: center; /* Center them horizontally */
      margin-top: 20px;
  }
  #landing_page #new_ticket,
  #landing_page #check_status {
    width: 90%; /* Take more width on mobile */
    max-width: 400px; /* Optional: cap max width */
    margin: 10px 0; /* Stack vertically with spacing */
    padding-top: 100px; /* More space for larger icon */
    background-size: 64px; /* Larger icons for mobile buttons */
    background-position: center 20px;
  }

  #content {
    padding: 20px 15px; /* Adjusted padding for mobile */
    min-height: 300px;
  }

  /* General form and table adjustments */
  #ticketForm div input,
  #clientLogin div input,
  #ticketForm div textarea,
  #clientLogin div textarea,
  #ticketForm div select,
  #clientLogin div select {
    max-width: 100%; /* Ensure full width on mobile */
  }

  #ticketForm > table td:first-child,
  #clientLogin > table td:first-child {
      width: 120px; /* Adjust label column width for mobile */
  }

  #clientLogin {
    flex-direction: column; /* Stack login content vertically */
    background-position: center bottom 20px; /* Move lock icon to bottom center */
    padding-bottom: 100px; /* Add padding for icon at bottom */
    background-size: 60px;
  }

  #clientLogin .instructions {
    padding-right: 0;
    text-align: center;
    margin-bottom: 20px;
  }

  .rtl #clientLogin .instructions {
    padding-left: 0;
  }

  .login-box {
    width: 100%;
    box-shadow: none;
    padding: 0;
  }

  .row {
    flex-direction: column; /* Stack columns */
    margin: 0; /* Remove negative margin */
  }
  .row > [class*="span"] {
      padding: 0; /* Remove padding */
  }

  .span4,
  .span8 {
    width: 100%; /* Full width */
    margin-bottom: 20px; /* Add vertical spacing */
  }

  .sidebar {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    margin-top: 20px;
  }

  /* Thread entry mobile adjustments */
  .thread-entry {
    flex-direction: column; /* Stack avatar and content vertically */
    align-items: center; /* Center them */
    gap: 10px;
  }
  .thread-entry.response {
      flex-direction: column; /* Maintain vertical stack */
  }

  .thread-entry > .avatar {
    margin-bottom: 10px; /* Space below avatar */
    width: 60px; /* Slightly larger avatar */
    height: 60px;
  }

  .thread-entry .header {
    width: 100%; /* Full width for header */
    box-sizing: border-box;
    border-radius: 8px; /* Full rounded corners */
  }
  .thread-entry .header:before,
  .thread-entry .header:after {
    content: none; /* Hide speech bubble arrows on mobile */
  }

  .thread-entry .thread-body {
    width: 100%; /* Full width for body */
    box-sizing: border-box;
    border-radius: 8px;
    border-top: 1px solid #ddd; /* Add a top border as header is now rounded */
  }

  .thread-body .attachment-info {
    width: 100%;
    max-width: none;
    margin-bottom: 8px;
  }

  .thread-event {
    margin-left: 0;
    padding-left: 0;
  }
  .thread-event .type-icon {
      position: static; /* Remove absolute positioning */
      margin: 0 auto 10px; /* Center icon */
  }
  .thread-event .description {
      flex-direction: column; /* Stack icon and text */
      text-align: center;
      align-items: center;
      width: 100%;
      padding-left: 0;
  }
  .thread-event .description img.avatar {
      margin-right: 0;
      margin-bottom: 5px;
  }

  #ticketThread {
    padding-left: 0; /* Remove timeline line space */
  }
  #ticketThread::before {
    content: none; /* Hide timeline line */
  }

  .freetext-files .file {
    width: 100%; /* Stack files vertically */
    margin-right: 0;
    margin-bottom: 8px;
  }
}