/* ========================================
   MODALS STYLES
   ======================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 450px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-bg);
  color: var(--color-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

[dir="ltr"] .modal-close {
  right: auto;
  left: 1rem;
}

.modal-close:hover {
  background: var(--color-error);
  color: white;
}

/* Auth Forms */
.auth-form {
  padding: 2.5rem 2rem;
}

.auth-form.hidden {
  display: none;
}

.auth-form h2 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  color: var(--color-accent);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-accent);
}

.form-group input {
  width: 100%;
  padding: 0.9rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-accent);
  transition: all 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(130, 207, 226, 0.2);
}

.form-group input::placeholder {
  color: var(--color-muted);
}

/* Email Input Group */
.email-input-group {
  display: flex;
  align-items: stretch;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-bg);
  transition: all 0.3s ease;
}

.email-input-group:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(130, 207, 226, 0.2);
}

.email-input-group input {
  flex: 1;
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0.9rem 1rem;
}

.email-input-group input:focus {
  box-shadow: none;
}

.email-domain {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 0.85rem;
  font-family: monospace;
  border-right: 1px solid var(--color-border);
  direction: ltr;
}

[dir="ltr"] .email-domain {
  border-right: none;
  border-left: 1px solid var(--color-border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px -10px rgba(130, 207, 226, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

/* Auth Switch */
.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.auth-switch a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
  margin-right: 5px;
}

[dir="ltr"] .auth-switch a {
  margin-right: 0;
  margin-left: 5px;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* Email View Modal */
.email-view-modal {
  max-width: 800px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.email-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.modal-back {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.modal-back:hover {
  background: rgba(130, 207, 226, 0.1);
}

[dir="ltr"] .modal-back i {
  transform: rotate(180deg);
}

.email-modal-actions {
  display: flex;
  gap: 0.5rem;
}

.email-action-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.email-action-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.email-action-btn.danger:hover {
  background: var(--color-error);
  border-color: var(--color-error);
}

.email-view {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.email-view__header {
  margin-bottom: 1.5rem;
}

.email-view__header h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-accent);
  line-height: 1.4;
}

.email-sender {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-bg);
  border-radius: 12px;
}

.sender-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
}

.sender-info {
  flex: 1;
}

.sender-name {
  display: block;
  font-weight: 600;
  color: var(--color-accent);
  margin-bottom: 0.2rem;
}

.sender-to {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.email-date {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.email-view__body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--color-accent);
  padding: 1.5rem 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  margin: 1rem 0;
}

.email-view__body p {
  margin-bottom: 1rem;
}

.email-view__body a {
  color: var(--color-primary);
}

.email-view__body img {
  max-width: 100%;
  border-radius: 8px;
}

.email-view__footer {
  padding-top: 1rem;
}

.reply-btn-large {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  border: 2px dashed var(--color-border);
  border-radius: 12px;
  background: transparent;
  color: var(--color-muted);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.reply-btn-large:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(130, 207, 226, 0.05);
}

@media (max-width: 768px) {
  .email-view-modal {
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  
  .email-modal-header {
    padding: 0.8rem 1rem;
  }
  
  .email-view {
    padding: 1rem;
  }
  
  .email-view__header h3 {
    font-size: 1.2rem;
  }
  
  .email-sender {
    flex-wrap: wrap;
  }
  
  .email-date {
    width: 100%;
    margin-top: 0.5rem;
  }
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 3000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.toast i {
  font-size: 1.2rem;
  color: var(--color-success);
}

.toast.error i {
  color: var(--color-error);
}

.toast span {
  font-weight: 500;
  color: var(--color-accent);
}

/* Responsive */
@media (max-width: 480px) {
  .modal {
    max-width: 100%;
    border-radius: var(--radius-md);
  }
  
  .auth-form {
    padding: 2rem 1.5rem;
  }
  
  .email-input-group {
    flex-direction: column;
  }
  
  .email-domain {
    border-right: none;
    border-top: 1px solid var(--color-border);
    justify-content: center;
    padding: 0.7rem;
  }
  
  [dir="ltr"] .email-domain {
    border-left: none;
  }
}
