/**
 * Copyright 2025 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Standalone login page styles for Cloud Cuttlefish Orchestrator.
 * Design inspired by Google Cloud Console login.
 */

/* Google Cloud color palette */
:root {
  /* Google Blue */
  --google-blue-500: #4285f4;
  --google-blue-600: #1a73e8;
  --google-blue-700: #1967d2;
  --google-blue-50: #e8f0fe;

  /* Google Grey */
  --google-grey-50: #f8f9fa;
  --google-grey-100: #f1f3f4;
  --google-grey-200: #e8eaed;
  --google-grey-300: #dadce0;
  --google-grey-500: #9aa0a6;
  --google-grey-700: #5f6368;
  --google-grey-900: #202124;

  /* Google Red */
  --google-red-500: #ea4335;
  --google-red-50: #fce8e6;

  /* Google Green */
  --google-green-500: #34a853;
  --google-green-50: #e6f4ea;

  /* Semantic colors */
  --primary-color: var(--google-blue-600);
  --primary-hover: var(--google-blue-700);
  --text-primary: var(--google-grey-900);
  --text-secondary: var(--google-grey-700);
  --text-hint: var(--google-grey-500);
  --border-color: var(--google-grey-300);
  --surface: #ffffff;
  --background: var(--google-grey-50);
  --error-color: var(--google-red-500);
  --error-bg: var(--google-red-50);
  --success-color: var(--google-green-500);
  --success-bg: var(--google-green-50);

  /* Shadows - Google Material Design */
  --shadow-1: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --shadow-2: 0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
  --shadow-3: 0 4px 8px 3px rgba(60, 64, 67, 0.15), 0 1px 3px rgba(60, 64, 67, 0.3);
}

/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Google Sans', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--background);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Main container - centered card layout like Google sign-in */
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Login card - Google style elevated card */
.login-card {
  width: 100%;
  max-width: 450px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--google-grey-200);
  box-shadow: var(--shadow-1);
  padding: 48px 40px;
}

/* Header */
.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  width: 75px;
  height: 75px;
  margin-bottom: 16px;
}

.login-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 400;
}

/* Error message - Google style */
.error-message {
  padding: 16px;
  background: var(--error-bg);
  border-radius: 4px;
  margin-bottom: 24px;
  border-left: 4px solid var(--error-color);
}

.error-message.hidden {
  display: none;
}

.error-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.error-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.error-text {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
}

.retry-button {
  padding: 8px 16px;
  background: var(--surface);
  color: var(--error-color);
  border: 1px solid var(--error-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  margin-top: 12px;
}

.retry-button:hover {
  background: var(--error-bg);
}

/* Primary action button - Google blue filled button */
.primary-button {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--primary-color);
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-1);
}

.primary-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--google-blue-50), 0 0 0 4px var(--primary-color);
}

.primary-button .icon {
  width: 20px;
  height: 20px;
}

/* Secondary action button - outlined style */
.secondary-button {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary-color);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.secondary-button:hover {
  background: var(--google-blue-50);
  border-color: var(--primary-color);
}

/* Google sign-in button */
.google-button {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.google-button:hover {
  background: var(--google-grey-50);
  box-shadow: var(--shadow-1);
}

.google-icon {
  width: 18px;
  height: 18px;
}

/* Tenant selection section */
.tenant-section {
  margin-bottom: 24px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.section-header .icon {
  color: var(--primary-color);
  font-size: 20px;
}

.section-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.section-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: auto;
}

/* Partner dropdown */
.partner-dropdown {
  position: relative;
  margin-bottom: 24px;
}

.partner-dropdown-trigger {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.partner-dropdown-trigger:hover {
  border-color: var(--text-hint);
}

.partner-dropdown-trigger:focus {
  outline: none;
  border-color: var(--primary-color);
}

.partner-dropdown-trigger .chevron {
  font-size: 18px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.partner-dropdown-trigger.open .chevron {
  transform: rotate(180deg);
}

.partner-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  box-shadow: var(--shadow-2);
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}

.partner-dropdown-menu.open {
  display: block;
}

.partner-dropdown-item {
  width: 100%;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}

.partner-dropdown-item:hover {
  background: var(--google-grey-100);
}

.partner-dropdown-item .partner-icon {
  font-size: 20px;
}

.partner-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--google-grey-200);
}

.divider span {
  padding: 0 16px;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Email form */
.email-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 16px;
  color: var(--text-primary);
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 1px var(--primary-color);
}

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

/* Submit button */
.submit-button {
  width: 100%;
  height: 48px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

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

.submit-button:disabled {
  background: var(--google-grey-300);
  cursor: not-allowed;
}

/* Help links */
.help-links {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--google-grey-200);
}

.help-links a {
  color: var(--primary-color);
  font-size: 14px;
  text-decoration: none;
  font-weight: 500;
}

.help-links a:hover {
  text-decoration: underline;
}

/* Footer */
.login-footer {
  margin-top: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.gcp-logo {
  height: 20px;
  opacity: 0.8;
}

/* Emergency access link */
.emergency-access {
  margin-top: 24px;
  text-align: center;
}

.emergency-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.emergency-link:hover {
  color: var(--text-primary);
  background: var(--google-grey-100);
}

.emergency-link .icon {
  font-size: 14px;
}

/* Loading indicator - Google style */
.loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: 1000;
}

.loader.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--google-grey-200);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loader p {
  color: var(--text-secondary);
  font-size: 16px;
}

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

/* Sign out complete */
.signout-content {
  text-align: center;
  padding: 24px 0;
}

.signout-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  background: var(--success-bg);
  color: var(--success-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.signout-content p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 32px;
}

.signin-link {
  display: inline-block;
  padding: 12px 32px;
  background: var(--primary-color);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s ease;
}

.signin-link:hover {
  background: var(--primary-hover);
}

/* Tenant label for sign-in */
.tenant-label {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--google-blue-50);
  border-radius: 4px;
  border: 1px solid var(--google-blue-500);
}

.tenant-label strong {
  color: var(--primary-color);
  font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .login-container {
    padding: 16px;
  }

  .login-card {
    padding: 32px 24px;
  }

  .login-header h1 {
    font-size: 20px;
  }
}
