/* --- 1. Font Import --- */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200..1000&display=swap');

/* --- Global Styling and Variables --- */
:root {
  --primary: #d8417d; /* Raspberry Pink */
  --primary-light: #ffc0d8; /* Light Pink */
  --background-soft: #fff0f5; /* Soft Blush Background */
  --text-dark: #3d0f21; /* Deep Magenta/Burgundy */
  --shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  --border-radius: 12px;
}

body {
  font-family: 'Cairo', sans-serif;
  background-color: var(--background-soft);
  color: var(--text-dark);
  direction: rtl;
  margin: 0;
  padding: 0;
}

.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Typography and Structure --- */

h1,
h2,
h3,
h4 {
  color: var(--text-dark);
}
.section-title {
  color: var(--primary);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 5px;
  margin-top: 30px;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
  text-align: right;
}

/* ------------------------------------------- */
/* --- HEADER/LOGO FIXES --- */
/* ------------------------------------------- */

.main-header {
  background-color: #f5f5f5;
  padding: 15px 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  width: 100%;
  flex-shrink: 0;
}

.header-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Logo Grouping */
.logo-group {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: 10px;
}

.logo-img {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.logo-title {
  color: var(--primary);
  font-size: 1.8em;
  font-weight: 800;
  margin: 0;
}

/* Header Actions (Welcome & Logout) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.welcome-message {
  color: var(--text-dark);
  font-size: 1em;
  font-weight: 500;
}

/* ------------------------------------------- */
/* --- BUTTONS & FORMS --- */
/* ------------------------------------------- */

input[type='text'],
input[type='password'],
input[type='file'],
select {
  padding: 10px 15px;
  border: 1px solid var(--primary-light);
  border-radius: 8px;
  width: 100%;
  margin-bottom: 15px;
  box-sizing: border-box;
  font-size: 16px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: bold;
  transition: background-color 0.2s, transform 0.2s;
}

/* Primary Button (Login, Add, Upload) */
.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: #a33464;
  transform: translateY(-1px);
}

/* Logout Button */
.btn-logout {
  background: var(--primary-light);
  color: var(--text-dark);
  padding: 8px 15px;
  font-size: 0.9em;
  width: auto !important;
}
.btn-logout:hover {
  background-color: var(--primary);
  color: white;
}

/* ------------------------------------------- */
/* --- MAIN CONTENT & CONTAINERS --- */
/* ------------------------------------------- */

.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

.container {
  max-width: 900px;
  width: 90%;
  margin: 40px auto;
  padding: 25px;
  background-color: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-container {
  max-width: 400px;
  padding: 30px;
  margin: auto;
}

/* --- Admin Creation Form (Grid Layout) --- */
.admin-creation-form h4 {
  margin-top: 0;
  color: var(--text-dark);
}

.user-creation-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
}
.user-creation-fields input,
.user-creation-fields select,
.user-creation-fields button {
  margin: 0;
  width: auto;
}
.user-creation-fields button {
  padding: 10px 20px;
  font-size: 0.9em;
  white-space: nowrap;
}

/* ------------------------------------------- */
/* --- USER AND FILE CARDS (Full Width Fix) --- */
/* ------------------------------------------- */

/* Ensure the main sections stretch 100% within the centered container */
.admin-section,
.user-section {
  width: 100%;
}

/* Ensure all lists take full width */
.user-list,
.file-list,
.file-card-container,
#usersList,
#myFilesList {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.card {
  padding: 15px;
  background-color: var(--background-soft);
  border: 1px solid var(--primary-light);
  border-radius: var(--border-radius);
  transition: all 0.2s;
  /* Card itself must be 100% wide */
  width: 100%;
  box-sizing: border-box;
}
.card:hover {
  box-shadow: 0 2px 5px rgba(216, 65, 125, 0.2);
  border-color: var(--primary);
}

/* User Card (The main list item) */
.user-list .card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user-info {
  flex-grow: 1;
  color: var(--text-dark);
  font-size: 1.1em;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

/* Action Button Colors */
.action-btn {
  padding: 8px 12px;
  font-size: 0.9em;
  flex-shrink: 0;
}

.action-btn[onclick*='openFileModal'] {
  background-color: #ff69b4;
  color: white;
}
.action-btn[onclick*='changePass'] {
  background-color: #b0e0e6;
  color: var(--text-dark);
}
.delete-btn {
  background-color: #ff99aa;
  color: var(--text-dark);
}

/* File Card Style - Targets the inner content of the card */
.file-card-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  background-color: transparent;
  border: none;
  /* Ensure the inner file card content takes full width */
  width: 100%;
  box-sizing: border-box;
}

/* Grouping for the delete and download buttons in the Modal */
.file-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.file-actions a,
.file-list .card a,
.file-card-container .card a {
  /* Download link */
  background-color: var(--primary-light);
  color: var(--text-dark);
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 0.9em;
  font-weight: bold;
}
.file-actions .delete-btn {
  /* Delete button in modal */
  margin: 0;
  padding: 5px 10px;
}
.file-actions a:hover,
.file-list .card a:hover {
  background-color: #ffb3d3;
}

/* ------------------------------------------- */
/* --- FOOTER STYLING --- */
/* ------------------------------------------- */

footer {
  width: 100%;
  text-align: center;
  padding: 15px 0;
  border-top: 1px solid var(--primary-light);
  background-color: #f5f5f5;
  color: var(--text-dark);
  font-size: 0.9em;
  flex-shrink: 0;
}

.contact-links a {
  color: var(--primary);
  text-decoration: none;
  margin: 0 10px;
}
.separator {
  color: var(--primary-light) !important;
  font-weight: 100;
}

/* ------------------------------------------- */
/* --- RESPONSIVE ADJUSTMENTS & MODAL --- */
/* ------------------------------------------- */

@media (max-width: 768px) {
  .logo-title {
    font-size: 1.5em;
  }

  .user-creation-fields {
    grid-template-columns: 1fr;
  }
  .user-creation-fields button {
    width: 100%;
  }

  .user-list .card {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-actions {
    width: 100%;
    justify-content: space-between;
    margin-top: 10px;
  }
  .action-btn {
    width: calc(33% - 6px);
    font-size: 10px;
    padding: 8px 5px;
    text-align: center;
  }
}

/* --- Utility Class & Toast --- */
.hidden {
  display: none !important;
}

/* Modal and Toast styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
}
.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  width: 80%;
  max-width: 600px;
  position: relative;
}
.close-btn {
  color: #aaa;
  float: left;
  font-size: 28px;
  font-weight: bold;
  position: absolute;
  top: 10px;
  right: 15px;
}
.close-btn:hover,
.close-btn:focus {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}
#toast {
  visibility: hidden;
  min-width: 250px;
  background-color: var(--text-dark);
  color: white;
  text-align: center;
  border-radius: 8px;
  padding: 16px;
  position: fixed;
  z-index: 100;
  bottom: 30px;
  right: 30px;
  font-size: 17px;
  box-shadow: var(--shadow);
}
#toast.show {
  visibility: visible;
  -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
  animation: fadein 0.5s, fadeout 0.5s 2.5s;
}
@-webkit-keyframes fadein {
  from {
    bottom: 0;
    opacity: 0;
  }
  to {
    bottom: 30px;
    opacity: 1;
  }
}
@keyframes fadein {
  from {
    bottom: 0;
    opacity: 0;
  }
  to {
    bottom: 30px;
    opacity: 1;
  }
}
@-webkit-keyframes fadeout {
  from {
    bottom: 30px;
    opacity: 1;
  }
  to {
    bottom: 0;
    opacity: 0;
  }
}
@keyframes fadeout {
  from {
    bottom: 30px;
    opacity: 1;
  }
  to {
    bottom: 0;
    opacity: 0;
  }
}
