@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap");

:root {
  --primary-color: #4a90e2;
  --primary-hover: #357abd;
  --background-color: #eef2f5;
  --card-background: #ffffff;
  --text-color: #333;
  --text-light: #888;
  --border-color: #dde4e8;
  --error-color: #e74c3c;
  --success-color: #2ecc71;
}

body {
  font-family: "Poppins", sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  min-height: 100vh;
  padding: 0;
  margin: 0;
  display: block;
}

.card {
  background: var(--card-background);
  border-radius: 0;
  box-shadow: none;
  width: 100vw;
  min-height: 100vh;
  max-width: none;
  overflow: hidden;
  display: flex;
  flex-direction: row;
}

.card-header, .card-body {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
}

.card-header {
  border-radius: 0;
  align-items: center;
  padding: 2rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  text-align: center;
}

.card-body {
  border-radius: 0;
  padding: 2rem 4vw;
  overflow-y: auto;
}

.card-header .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}
.card-header h1 {
  margin: 0;
  font-weight: 600;
}
.card-header p {
  margin: 0.25rem 0 0;
  opacity: 0.8;
}

.hidden {
  display: none !important;
}

/* --- Inputs --- */
.input-group {
  position: relative;
  margin-bottom: 1.5rem;
}

.input-group i {
  position: absolute;
  top: 50%;
  left: 15px;
  transform: translateY(-50%);
  color: var(--text-light);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  box-sizing: border-box;
  transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

/* --- Buttons --- */
button {
  position: relative;
  width: 100%;
  padding: 12px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: background-color 0.3s;
}

button:hover {
  background-color: var(--primary-hover);
}

button.loading .button-text {
  visibility: hidden;
}
button.loading .spinner {
  display: block;
}

.spinner {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  margin-left: -10px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Messages --- */
.error,
.success {
  padding: 10px;
  border-radius: 8px;
  margin-top: 1rem;
  color: white;
  text-align: center;
}

.secondary-cta {
  margin-top: 0.75rem;
  background-color: #1f2937;
}

.secondary-cta:hover {
  background-color: #111827;
}
.error {
  background-color: var(--error-color);
}
.success {
  background-color: var(--success-color);
}

/* --- Switch Login/Register link --- */
.switch-view-text {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-light);
  font-size: 0.9rem;
}
.switch-view-text a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}
.switch-view-text a:hover {
  text-decoration: underline;
}

/* --- View title --- */
.view-title {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-color);
  font-weight: 600;
}

/* --- Welcome back --- */
.welcome-back {
  color: var(--text-light);
  text-align: center;
  margin-bottom: 1.5rem;
}
.welcome-back strong {
  color: var(--primary-color);
  font-weight: 600;
}

/* --- Dashboard --- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
#logout-button {
  width: auto;
  background: none;
  color: var(--text-light);
  padding: 8px;
  font-size: 1.2rem;
}
#logout-button:hover {
  color: var(--primary-color);
}

/* User info card */
.user-info-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-weight: 500;
}
.user-info-card i {
  font-size: 1.5rem;
  color: var(--primary-color);
}
.user-role-badge {
  margin-left: auto;
  background: var(--primary-color);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Token section */
.token-section {
  margin-bottom: 1.5rem;
}
.token-section h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.token-container {
  position: relative;
  background-color: #2c3e50;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  text-align: left;
  word-break: break-all;
}
#token-output {
  white-space: pre-wrap;
  font-family: "Courier New", Courier, monospace;
  color: #ecf0f1;
  font-size: 0.85rem;
  margin: 0;
}
#copy-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  cursor: pointer;
  color: #bdc3c7;
  font-size: 1.2rem;
  transition: color 0.3s, transform 0.3s;
}
#copy-icon:hover {
  color: white;
  transform: scale(1.1);
}
#copy-icon.copied {
  color: var(--success-color);
}
.token-info {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}
.token-info code {
  background-color: #eee;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.8rem;
}

/* --- Toggle buttons & collapsibles --- */
.toggle-button {
  background-color: #ecf0f1;
  color: var(--text-color);
  margin-top: 1rem;
}
.toggle-button:hover {
  background-color: #dfe6e9;
}

.collapsible {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease-in-out, padding 0.5s ease-in-out;
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 1rem;
  margin-top: 1rem;
}
.collapsible.open {
  max-height: 600px;
  padding: 1rem;
}

/* --- Admin panel --- */
#admin-panel form input {
  margin-bottom: 0.5rem;
}

.role-select {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.role-select label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--text-color);
}
.role-select input[type="checkbox"] {
  width: auto;
  accent-color: var(--primary-color);
}

/* --- Swagger button --- */
.swagger-button {
  background-color: #27ae60;
  margin-top: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.swagger-button:hover {
  background-color: #229954;
}

/* --- Responsive --- */
@media (min-width: 700px) {
  .card {
    display: flex;
    flex-direction: row;
    width: 100vw;
    min-height: 100vh;
    max-width: none;
    border-radius: 0;
  }
  .card-header, .card-body {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    border-radius: 0;
    padding: 2rem 1.5rem;
  }
}

@media (max-width: 699px) {
  .card {
    flex-direction: column;
    max-width: 420px;
  }
  .card-header, .card-body {
    border-radius: 0;
    padding: 2rem;
    min-height: auto;
  }
}
