:root {
  --background-color: #fcfdff;
  --card-background: rgba(255, 255, 255, 0.9);
  --text-color: #1a202c;
  --text-muted: #718096;
  --primary-color: #3671ff;
  --primary-hover-color: #275de8;
  --border-color: #e2e8f0;
  --input-background: #fdfdfe;
  --error-color: #e53e3e;
  --success-color: #38a169;
  --font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --box-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.07), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --border-radius: 0.5rem;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--background-color);
  color: var(--text-color);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

body::before,
body::after {
  content: '';
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(150px);
  opacity: 0.15;
}

body::before {
  background: radial-gradient(circle, #ff8a80, #ffc1b2);
  width: 350px;
  height: 350px;
  top: -100px;
  left: -100px;
}

body::after {
  background: radial-gradient(circle, #8c9eff, #c5cae9);
  width: 450px;
  height: 450px;
  bottom: -150px;
  right: -150px;
}

.hidden {
  display: none !important;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(5px);
  box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.app-header .logo img {
  height: 32px;
}
.app-header .logo h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-color);
}

.auth-nav {
  display: flex;
  gap: 0.75rem;
}
#auth-links {
  display: flex;
  gap: 0.75rem;
}
#user-session {
  display: flex;
  align-items: center;
  gap: 1rem;
}
#user-display {
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

#app {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem;
  min-height: calc(100vh - 72px);
}

.container {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 3rem;
  width: 100%;
  max-width: 1200px;
}

.controls-section {
  background-color: var(--card-background);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-lg);
  border: 1px solid var(--border-color);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.75rem 1rem;
  border: none;
  background-color: transparent;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  position: relative;
  transition: color 0.2s ease-in-out;
  flex-shrink: 0;
}

.tab-btn.active {
  color: var(--primary-color);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--primary-color);
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

.form-group {
  margin-bottom: 1.25rem;
}
.form-group-inline {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.form-group-inline .form-group {
  width: 100%;
  margin-bottom: 0;
}


label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-color);
}

input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background-color: var(--input-background);
  font-size: 1rem;
  font-family: var(--font-family);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(54, 113, 255, 0.2);
}

.color-picker-group { display: flex; gap: 1rem; }
.color-picker-wrapper { display: flex; align-items: center; gap: 0.5rem; position: relative; }
.color-picker-wrapper label { margin-bottom: 0; }
input[type="color"] {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  width: 2.5rem; height: 2.5rem; padding: 0; border: 1px solid var(--border-color);
  border-radius: 50%; cursor: pointer; background: transparent;
}
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 50%; }

.file-upload-wrapper input[type="file"] { display: none; }
.file-upload-label {
  display: flex; align-items: center; justify-content: center; width: 100%;
  padding: 2rem; border: 2px dashed var(--border-color); border-radius: 0.375rem;
  cursor: pointer; transition: border-color 0.2s, background-color 0.2s;
  text-align: center; color: var(--text-muted);
}
.file-upload-label:hover { border-color: var(--primary-color); background-color: rgba(245, 247, 250, 0.5); }
#file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.btn {
  display: inline-block; padding: 0.75rem 1.5rem; font-size: 1rem;
  font-weight: 600; text-align: center; border-radius: 0.375rem;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: all 0.3s ease-in-out;
}
.btn-primary { 
  background-color: var(--primary-color);
  color: #fff; 
  width: 100%;
  box-shadow: 0 4px 15px 0 rgba(54, 113, 255, 0.25);
}
.btn-primary:hover { 
  background-color: var(--primary-hover-color);
  box-shadow: 0 6px 20px 0 rgba(54, 113, 255, 0.35);
  transform: translateY(-1px);
}
.btn-secondary { background-color: var(--card-background); color: var(--primary-color); border: 1px solid var(--border-color); }
.btn-secondary:hover { background-color: var(--input-background); border-color: var(--primary-color); }
.btn-tertiary { width: 100%; margin-top: 0.75rem; background-color: transparent; color: var(--error-color); border: none; padding: 0.5rem; }
.btn-tertiary:hover { background-color: rgba(229, 62, 62, 0.1); }

.output-section {
  display: flex; flex-direction: column; justify-content: flex-start; align-items: center;
  gap: 2rem; position: sticky; top: calc(72px + 2rem);
}
#qr-code-container {
  width: 100%; max-width: 384px; aspect-ratio: 1 / 1; display: flex;
  justify-content: center; align-items: center; background-color: var(--card-background);
  border-radius: var(--border-radius); padding: 1rem;
  box-shadow: var(--box-shadow-lg); border: 1px solid var(--border-color);
  position: relative;
}
#qr-code-container.blurred > canvas,
#qr-code-container.blurred > svg {
    filter: blur(5px);
    transition: filter 0.3s ease;
}
#qr-blur-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 1rem;
    border-radius: var(--border-radius);
    z-index: 1;
}
#qr-blur-overlay p {
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 1rem;
}
#qr-blur-overlay .btn-primary {
    width: auto;
    padding: 0.75rem 2rem;
}

#qr-code-container canvas, #qr-code-container svg {
  width: 100% !important; height: 100% !important; border-radius: 0.375rem;
}

.download-options {
    background: var(--card-background); padding: 1rem 1.5rem; border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg); border: 1px solid var(--border-color);
    width: 100%; max-width: 384px; text-align: center;
}
#save-qr-btn {
    margin-bottom: 1rem;
}
.download-options p { font-weight: 500; margin-bottom: 1rem; }
.download-buttons { display: flex; justify-content: center; gap: 0.5rem; }
.btn-download {
    flex-grow: 1; padding: 0.75rem; border: 1px solid var(--border-color);
    background-color: var(--input-background); border-radius: 0.375rem;
    font-weight: 500; cursor: pointer; transition: all 0.2s ease-in-out;
}
.btn-download:hover { background-color: var(--primary-color); color: #fff; border-color: transparent; }

/* My QRs Panel */
#my-qrs-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.saved-qr-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}
.saved-qr-item:hover {
    background-color: var(--input-background);
}
.qr-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow: hidden;
}
.qr-item-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qr-item-content {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qr-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}
.qr-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}
.qr-item-actions button:hover {
    background-color: var(--border-color);
}
.qr-item-actions svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
}
.no-qrs-message {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Modal Styles */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex; justify-content: center; align-items: center;
  z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
}
.modal-overlay:not(.hidden) { opacity: 1; visibility: visible; }
.modal-content {
  background-color: var(--card-background); padding: 2rem; border-radius: var(--border-radius);
  box-shadow: var(--box-shadow-lg); width: 100%; max-width: 420px; position: relative;
  transform: scale(0.95) translateY(10px); transition: transform 0.3s ease, opacity 0.3s ease;
}
.modal-overlay:not(.hidden) .modal-content { transform: scale(1) translateY(0); }
.modal-content h3 { font-size: 1.5rem; margin-bottom: 1rem; text-align: center; font-weight: 600; }
.modal-description { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }
.modal-close-btn {
  position: absolute; top: 0.5rem; right: 0.75rem; background: none; border: none;
  font-size: 2rem; color: var(--text-muted); cursor: pointer; line-height: 1;
}
.modal-footer { margin-top: 1.5rem; text-align: center; font-size: 0.9rem; color: var(--text-muted); }
.auth-switch-link { color: var(--primary-color); text-decoration: none; font-weight: 500; }
.auth-switch-link:hover { text-decoration: underline; color: var(--primary-hover-color); }

#toast-container {
    position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    background-color: var(--text-color); color: white; padding: 1rem 1.5rem; border-radius: 0.375rem;
    box-shadow: var(--box-shadow-lg); opacity: 0; transform: translateX(100%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.success { background-color: var(--success-color); }
.toast.error { background-color: var(--error-color); }
.toast.info { background-color: var(--primary-color); }

@media (max-width: 992px) {
  .container { 
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .output-section { 
    position: static; 
    order: -1; 
    margin-bottom: 2rem;
  }
}

@media (max-width: 768px) {
    .app-header { 
      padding: 1rem;
    }
    .app-header .logo h2 { 
      display: none; 
    }
    #app { 
      padding: 1rem; 
    }
    .modal-content { 
      width: 90%;
      padding: 1.5rem;
    }
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        -ms-overflow-style: none; /* IE and Edge */
        scrollbar-width: none; /* Firefox */
    }
    .tabs::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }
}

@media (max-width: 480px) {
    body {
        font-size: 15px;
    }
    #user-display {
      max-width: 100px;
    }
    .auth-nav .btn {
      padding: 0.6rem 1rem;
      font-size: 0.9rem;
    }
    .form-group-inline {
        flex-direction: column;
        gap: 0;
    }
    .form-group-inline .form-group {
        margin-bottom: 1.25rem;
    }
    .form-group-inline .form-group:last-child {
        margin-bottom: 0;
    }
    .download-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }
}
