/* =============================================================================
   STYLES.CSS - Reliable Gaskets USA App Hub
   ============================================================================= */

/* -- Color palette (brand colors from logo) ------------------------------ */
:root {
  --brand-blue:        #1E40AF;
  --brand-blue-dark:   #1E3A8A;
  --brand-blue-light:  #DBEAFE;
  --brand-red:         #DC2626;
  --brand-red-dark:    #B91C1C;
  --brand-grey:        #6B7280;
  --brand-grey-dark:   #374151;
  --brand-grey-light:  #F3F4F6;

  --text-primary:      #111827;
  --text-secondary:    #4B5563;
  --text-muted:        #9CA3AF;

  --bg-page:           #F9FAFB;
  --bg-card:           #FFFFFF;
  --bg-input:          #FFFFFF;

  --border-default:    #E5E7EB;
  --border-focus:      var(--brand-blue);

  --success-bg:        #D1FAE5;
  --success-text:      #065F46;
  --error-bg:          #FEE2E2;
  --error-text:        #991B1B;

  --shadow-sm:         0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:         0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg:         0 10px 15px rgba(0,0,0,0.08), 0 4px 6px rgba(0,0,0,0.05);

  --radius-sm:         6px;
  --radius-md:         10px;
  --radius-lg:         16px;
}

/* -- Reset / base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

input, button {
  font-family: inherit;
}

a {
  color: var(--brand-blue);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* -- App shell ----------------------------------------------------------- */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =============================================================================
   LOADING SCREEN
   ============================================================================= */
#screen-loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
#screen-loading .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--brand-grey-light);
  border-top-color: var(--brand-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================================================
   LOGIN AND PASSWORD SCREENS (centered card layout)
   ============================================================================= */
#screen-login,
#screen-password {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  background: var(--bg-card);
  padding: 40px 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
}

.auth-card .logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.auth-card .logo-wrap img {
  max-width: 280px;
  width: 100%;
  height: auto;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin: 0 0 8px;
  text-align: center;
  color: var(--text-primary);
}

.auth-card .subhead {
  text-align: center;
  color: var(--text-secondary);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

/* Form fields */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.field input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-blue-light);
}

/* Primary button */
.btn-primary {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--brand-blue);
  border: none;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  margin-top: 8px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-blue-dark);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Secondary button (e.g. sign out) */
.btn-secondary {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-blue);
  background: transparent;
  border: 1px solid var(--brand-blue);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--brand-blue);
  color: #fff;
}
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Forgot password link */
.forgot-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
}

/* Message bar (errors and success) */
.msg {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.msg-error {
  background: var(--error-bg);
  color: var(--error-text);
}
.msg-success {
  background: var(--success-bg);
  color: var(--success-text);
}

/* =============================================================================
   HUB SCREEN (logged in - header + tile grid)
   ============================================================================= */
#screen-hub {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hub-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-default);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hub-header .logo {
  height: 40px;
  width: auto;
}

.hub-header .user-area {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hub-header .greeting {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.hub-header .help-link {
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.hub-header .help-link:hover,
.hub-header .help-link:focus-visible {
  background: var(--bg-hover, #f3f4f6);
  color: var(--text-primary, #1f2937);
  text-decoration: none;
}

.hub-main {
  flex: 1;
  padding: 32px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.hub-intro {
  text-align: center;
  margin-bottom: 32px;
}
.hub-intro h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  color: var(--text-primary);
}
.hub-intro p {
  margin: 0;
  color: var(--text-secondary);
}

/*
  External Tools intro - sits between the in-house tile grid and the
  external tile grid. Extra top margin separates the two sections visually.
*/
.hub-intro-external {
  margin-top: 48px;
}

/* Tile grid */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.tile {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  text-align: center;
  text-decoration: none;
  color: var(--text-primary);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 200px;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-blue);
  text-decoration: none;
}

.tile:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--brand-blue-light);
}

.tile-icon {
  width: 56px;
  height: 56px;
  background: var(--brand-blue-light);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-blue);
  flex-shrink: 0;
}

.tile-icon svg {
  width: 32px;
  height: 32px;
}

.tile-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tile-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* =============================================================================
   EXTERNAL TILE VARIANT (Phase 11)
   Used for third-party bookmarks (Notion, Connecteam, Jobber). Differs from
   in-house tiles:
     - icon area is white with a subtle border (no blue tint), to let brand
       colors come through
     - icon is an <img> not an SVG <use>
     - small arrow badge in top-right corner signals "opens in a new tab"
   ============================================================================= */

.tile.tile-external .tile-icon {
  background: #fff;
  border: 1px solid var(--border-default);
  overflow: hidden;
  padding: 8px;
}

.tile.tile-external .tile-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tile-external-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-external-badge svg {
  width: 100%;
  height: 100%;
}

/* Empty state when user has no app permissions */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}
.empty-state p { margin: 4px 0; }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */
@media (max-width: 600px) {
  .auth-card { padding: 32px 20px; }
  .hub-header { padding: 12px 16px; }
  .hub-header .logo { height: 32px; }
  .hub-main { padding: 24px 16px; }
  .tile-grid { grid-template-columns: 1fr; gap: 16px; }
  .tile { min-height: 160px; padding: 24px 20px; }
  .hub-intro-external { margin-top: 32px; }
}
