/* ----------------- Design Tokens ----------------- */
:root {
  --bg-blur: 8px;
  --bg-opacity: 0.6;
  --brand: #2b6a74;
  --brand-dark: #21525b;
  --border: #b6dce5;
  --border-soft: #cde6ec;
  --surface: #ffffffdd;
  --shadow: 0 4px 12px rgba(0, 115, 145, 0.1);
  --radius: 12px;
  --space: 30px;
  --font-base: clamp(14px, 1.6vw, 16px);
  --tap-min: 44px; /* ελάχιστο ύψος στόχου αφής */
}

/* ----------------- Blurred Background ----------------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: url("../images/1.png") no-repeat center center / cover fixed;
  filter: blur(var(--bg-blur));
  opacity: var(--bg-opacity);
  z-index: -1;
}

/* ----------------- Γενικά ----------------- */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #eaf4f8;
  color: #222;
  margin: 0;
  padding: max(0px, env(safe-area-inset-top)) max(0px, env(safe-area-inset-right)) max(0px, env(safe-area-inset-bottom)) max(0px, env(safe-area-inset-left));
  font-size: var(--font-base);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%; /* αποφυγή auto zoom σε iOS */
}

/* Καλύτερα states για πληκτρολόγιο/κινητό */
:focus-visible {
  outline: 2px solid #79b9c6;
  outline-offset: 2px;
}

/* ----------------- Κουτιά Περιεχομένου ----------------- */
.container,
.dashboard,
.admin-panel {
  background-color: var(--surface);
  padding: var(--space) calc(var(--space) - 5px);
  max-width: 800px;
  margin: 40px auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: saturate(120%);
}

/* ----------------- Τίτλοι & Σύνδεσμοι ----------------- */
h2, h3 {
  color: var(--brand);
  margin-top: 0;
  font-weight: 600;
}
a { color: var(--brand); text-decoration: none; }
a:active { opacity: 0.85; }

/* Μικρό γενικό κουμπί δράσης (π.χ. "Ενέργειες") */
.btn.small {
  display: inline-block;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f0f7f9;
  font-size: 13px;
  line-height: 1;
  min-height: var(--tap-min);
}
.btn.small:hover { background: var(--brand); color: #fff; border-color: var(--brand-dark); }

/* ----------------- Inputs & Buttons ----------------- */
input[type="text"],
input[type="email"],
input[type="password"],
button {
  padding: 12px 15px;
  margin-top: 12px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  min-height: var(--tap-min);
}

input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(43, 106, 116, 0.2);
}

button {
  background-color: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.06s ease, background-color 0.2s ease;
  will-change: transform;
  touch-action: manipulation;
}
button:hover { background-color: var(--brand-dark); }
button:active { transform: translateY(1px); }

/* Αποτροπή zoom σε iOS όταν tap σε inputs */
@supports (-webkit-touch-callout: none) {
  input, button { font-size: 16px; }
}

/* ----------------- Εργαλειοθήκη πίνακα (Search) ----------------- */
.table-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.table-toolbar input[type="search"] {
  width: 320px;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ----------------- Πίνακες ----------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  font-size: 14px;
  table-layout: fixed;
  overflow: hidden;
  border-radius: 8px;
}
th {
  background-color: #d7eef4;
  color: var(--brand);
  font-weight: 600;
}
th, td {
  padding: 12px;
  border: 1px solid var(--border-soft);
  text-align: center;
  word-wrap: break-word;
}
tr:nth-child(even) { background-color: #f5fbfd; }
tr:hover { background-color: #e1f1f5; }

/* Καλύτερη συμπεριφορά header/body στο οριζόντιο scroll */
table { display: block; }
thead, tbody, tr { display: table; width: 100%; table-layout: fixed; }

/* ----------------- Σελιδοποίηση ----------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pagination .page-btn {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  min-height: var(--tap-min);
}
.pagination .page-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand-dark);
  font-weight: 600;
}
.pagination .page-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pagination span {
  padding: 0 6px;
  color: #666;
}

/* ----------------- Κουμπί Προσθήκης + ----------------- */
button#toggle-form {
  position: sticky;
  top: 20px;
  float: right;
  background-color: var(--brand);
  color: #fff;
  font-size: 28px;
  font-weight: bold;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
  transition: background-color 0.2s ease, transform 0.15s ease;
  z-index: 10;
}
button#toggle-form:hover { background-color: var(--brand-dark); transform: scale(1.05); }
button#toggle-form:active { transform: scale(0.98); }

/* ----------------- Φόρμα Προσθήκης ----------------- */
#add-patient-form input,
#add-patient-form button { margin-top: 10px; }

/* ----------------- Copy Button Style ----------------- */
.copy-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.copy-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  background-color: #f0f7f9;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
  color: var(--brand);
  word-break: break-all;
}
.copy-btn {
  background-color: #eef7f9;
  border: 1px solid var(--border-soft);
  color: var(--brand);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.06s ease;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-min);
}
.copy-btn:hover { background-color: var(--brand-dark); color: #fff; }
.copy-btn:active { transform: translateY(1px); }
.copy-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  margin-left: 6px;
}
.flash-messages { margin-bottom: 15px; }

.flash.error {
  color: #fff;
  background: #e74c3c;
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
}

/* ----------------- Responsive Βελτιστοποίηση ----------------- */
@media (max-width: 768px) {
  /* Ήπιοτερο background για επιδόσεις & αναγνωσιμότητα */
  body::before {
    background-attachment: scroll;
    filter: blur(5px);
    opacity: 0.5;
  }

  /* Κεντράρισμα περιεχομένου σε σελίδες όπως το login */
  body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
  }

  .container,
  .dashboard,
  .admin-panel {
    padding: 20px 14px;
    margin: 20px auto;
    max-width: 96%;
    border-radius: 10px;
  }

  h2, h3 {
    font-size: 1.25rem;
    text-align: center;
  }

  button#toggle-form {
    top: 12px;
    width: 44px;
    height: 44px;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }

  .table-toolbar { justify-content: center; }
  table { font-size: 13px; }
  th, td { padding: 10px; }

  .copy-container { flex-direction: column; align-items: stretch; }
  .copy-btn { margin-top: 6px; align-self: flex-end; }
}

@media (max-width: 480px) {
  body { font-size: 14px; }

  input, button {
    font-size: 16px;   /* αποφυγή zoom */
    padding: 10px 12px;
  }

  h2, h3 { font-size: 1.1rem; }

  .copy-code { font-size: 13px; }
}

/* ----------------- Login Container ----------------- */
.login-container {
  background-color: #ffffffee;
  padding: 40px 25px;
  max-width: 400px; /* default για desktop */
  margin: 60px auto;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}

/* -------- Ισορροπημένη εμφάνιση σε κινητά -------- */
@media (max-width: 768px) {
  .login-container {
    width: 85vw;              /* ισορροπημένο πλάτος */
    max-width: 420px;         /* όριο για tablets */
    margin: 0 auto;
    padding: 24px 20px;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.2);
    background-color: #ffffffee;
  }

  .login-container h2 {
    font-size: 1.4rem;
    text-align: center;
    margin-bottom: 20px;
  }

  .login-container input[type="text"],
  .login-container input[type="password"] {
    font-size: 16px;
    padding: 12px 14px;
    min-height: 46px;
  }

  .login-container button {
    font-size: 16px;
    padding: 12px;
    min-height: 46px;
    border-radius: 8px;
  }
}

@media (max-width: 480px) {
  .login-container {
    width: 90vw;       /* λίγο πιο πλατύ σε πολύ μικρές οθόνες */
    padding: 20px 16px;
  }

  .login-container h2 { font-size: 1.2rem; }
}

/* ----------------- Προσβασιμότητα/Κίνηση ----------------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
