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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #ffffff 0%, #f5f0f2 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  border: 1px solid #eee;
}

.logo {
  display: block;
  width: 180px;
  margin: 0 auto 24px;
}

h1 {
  color: #df006e;
  text-align: center;
  margin-bottom: 8px;
}

.subtitle {
  color: #666;
  text-align: center;
  margin-bottom: 32px;
}

.btn {
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s, transform 0.1s;
}

/* Botones full-width solo dentro del login card */
.login-card .btn {
  width: 100%;
  display: flex;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.provider-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-microsoft {
  background: #fff;
  border: 1px solid #ddd;
  color: #333;
}

.btn-microsoft:hover {
  background: #f5f5f5;
}

.btn-google {
  background: #fff;
  border: 1px solid #ddd;
  color: #333;
}

.btn-google:hover {
  background: #f5f5f5;
}

.btn-github {
  background: #24292e;
  color: #fff;
}

.btn-github:hover {
  background: #2f363d;
}

.btn-primary {
  background: #df006e;
  color: white;
}

.btn-primary:hover {
  background: #c00060;
}

.btn-secondary {
  background: #f5f5f5;
  color: #333;
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: #999;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ddd;
}

.divider span {
  padding: 0 16px;
  font-size: 14px;
}

.email-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.email-form input {
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.2s;
}

.email-form input:focus {
  outline: none;
  border-color: #df006e;
}

.user-info {
  text-align: center;
}

.user-info p {
  margin-bottom: 8px;
}

.user-email {
  color: #666;
  font-size: 14px;
}

.user-roles {
  color: #df006e;
  font-size: 14px;
  margin-bottom: 20px;
}

.error {
  color: #d32f2f;
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.request-access-link,
.back-link {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: #666;
}

.request-access-link a,
.back-link a {
  color: #df006e;
  text-decoration: none;
}

.request-access-link a:hover,
.back-link a:hover {
  text-decoration: underline;
}

#request-access-form h2 {
  color: #df006e;
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
}

#request-access-form .subtitle {
  margin-bottom: 24px;
}

#request-access-form textarea {
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

#request-access-form textarea:focus {
  outline: none;
  border-color: #df006e;
}

/* Organization Selector */
.org-selector {
  margin: 16px 0;
}

.org-selector-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
  display: block;
}

.org-dropdown {
  position: relative;
  display: inline-block;
  width: 100%;
}

.org-dropdown-button {
  width: 100%;
  padding: 10px 36px 10px 14px;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.org-dropdown-button:hover {
  background: #f0f0f0;
  border-color: #ccc;
}

.org-dropdown-button::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-top-color: #666;
}

.org-dropdown-button.open::after {
  border-top-color: transparent;
  border-bottom-color: #666;
  transform: translateY(-80%);
}

.org-icon {
  width: 20px;
  height: 20px;
  background: #df006e;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.org-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin-top: 4px;
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}

.org-dropdown-menu.hidden {
  display: none !important;
}

.org-dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}

.org-dropdown-item:hover {
  background: #f5f5f5;
}

.org-dropdown-item.selected {
  background: #e8f0fe;
}

.org-dropdown-item:first-child {
  border-radius: 6px 6px 0 0;
}

.org-dropdown-item:last-child {
  border-radius: 0 0 6px 6px;
}

.org-dropdown-item:only-child {
  border-radius: 6px;
}

.no-orgs {
  color: #999;
  font-size: 13px;
  font-style: italic;
}

/* Notifications */
.notifications-section {
  position: relative;
  margin: 16px 0;
}

.notifications-btn {
  position: relative;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: all 0.2s;
  margin: 0 auto;
}

.notifications-btn:hover {
  background: #e8e8e8;
  color: #333;
}

.notifications-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #d32f2f;
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.notifications-badge.hidden {
  display: none !important;
}

.notifications-panel {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 320px;
  max-height: 400px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  margin-top: 8px;
  z-index: 200;
  overflow: hidden;
}

.notifications-panel.hidden {
  display: none !important;
}

.notifications-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
  font-size: 14px;
}

.mark-all-read {
  background: none;
  border: none;
  color: #df006e;
  font-size: 12px;
  cursor: pointer;
}

.mark-all-read:hover {
  text-decoration: underline;
}

.notifications-list {
  max-height: 320px;
  overflow-y: auto;
}

.notification-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}

.notification-item:hover {
  background: #f9f9f9;
}

.notification-item.unread {
  background: #e8f0fe;
}

.notification-item.unread:hover {
  background: #d4e4fc;
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-message {
  font-size: 13px;
  color: #333;
  margin-bottom: 4px;
}

.notification-time {
  font-size: 11px;
  color: #999;
}

.no-notifications {
  padding: 24px 16px;
  text-align: center;
  color: #999;
  font-size: 13px;
}

.no-notifications.hidden {
  display: none !important;
}

/* Secret Expiry Banner */
.secret-expiry-banner {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 16px;
  text-align: center;
}

.secret-expiry-banner.hidden {
  display: none !important;
}

.secret-expiry-banner.warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
}

.secret-expiry-banner.expired {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* ==========================================
   MODAL SERVICE
   ========================================== */
.ms-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: msFadeIn 0.15s ease-out;
}

.ms-overlay.ms-closing {
  animation: msFadeOut 0.15s ease-in forwards;
}

.ms-dialog {
  background: white;
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  animation: msSlideIn 0.15s ease-out;
}

.ms-closing .ms-dialog {
  animation: msSlideOut 0.15s ease-in forwards;
}

.ms-title {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.ms-message {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.5;
  color: #555;
  word-wrap: break-word;
}

.ms-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 14px;
  margin-top: 4px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}

.ms-input:focus {
  border-color: #df006e;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

.ms-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@keyframes msFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes msFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes msSlideIn { from { transform: scale(0.95) translateY(-10px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
@keyframes msSlideOut { from { transform: scale(1) translateY(0); opacity: 1; } to { transform: scale(0.95) translateY(-10px); opacity: 0; } }

/* Dark mode del sistema: solo fondo oscuro, card y contenido se mantienen light */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2028 100%) !important;
  }

  .login-card {
    background: #fff !important;
    border-color: #eee !important;
    color: initial !important;
  }

  .login-card h1 { color: #df006e !important; }
  .login-card .subtitle { color: #666 !important; }
  .login-card .btn-microsoft { background: #fff !important; border-color: #ddd !important; color: #333 !important; }
  .login-card .btn-primary { background: #df006e !important; color: #fff !important; }
  .login-card .logo { background: #fff !important; border-radius: 8px; padding: 4px; }
}
