/**
 * 🌞 Sunday App Framework — Base Styles
 * CSS reset and foundational styles.
 * 
 * Include after tokens.css:
 *   <link rel="stylesheet" href="/css/tokens.css">
 *   <link rel="stylesheet" href="/css/base.css">
 * 
 * @version 1.1.0
 */

/* ===== CSS Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--sunday-font-sans);
  font-size: var(--sunday-text-base);
  line-height: var(--sunday-leading-normal);
  color: var(--sunday-text);
  background: var(--sunday-bg);
  min-height: 100vh;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--sunday-font-bold);
  line-height: var(--sunday-leading-tight);
  color: var(--sunday-text);
}

h1 { font-size: var(--sunday-text-3xl); }
h2 { font-size: var(--sunday-text-2xl); }
h3 { font-size: var(--sunday-text-xl); }
h4 { font-size: var(--sunday-text-lg); }
h5 { font-size: var(--sunday-text-base); }
h6 { font-size: var(--sunday-text-sm); }

p {
  margin-bottom: var(--sunday-space-4);
}

a {
  color: var(--sunday-accent);
  text-decoration: none;
  transition: color var(--sunday-transition-fast);
}

a:hover {
  color: var(--sunday-accent-alt);
}

code, pre, kbd, samp {
  font-family: var(--sunday-font-mono);
  font-size: 0.9em;
}

code {
  padding: 2px 6px;
  background: var(--sunday-surface);
  border-radius: var(--sunday-radius-sm);
  border: 1px solid var(--sunday-line);
}

pre {
  padding: var(--sunday-space-4);
  background: var(--sunday-surface);
  border-radius: var(--sunday-radius-md);
  border: 1px solid var(--sunday-line);
  overflow-x: auto;
}

pre code {
  padding: 0;
  background: none;
  border: none;
}

/* ===== Images ===== */
img, video, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ===== Forms ===== */
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  background: var(--sunday-surface);
  border: 1px solid var(--sunday-line);
  border-radius: var(--sunday-radius-md);
  padding: var(--sunday-space-3) var(--sunday-space-4);
  transition: border-color var(--sunday-transition-fast), box-shadow var(--sunday-transition-fast);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sunday-accent);
  box-shadow: 0 0 0 3px var(--sunday-info-light);
}

input::placeholder, textarea::placeholder {
  color: var(--sunday-text-muted);
  opacity: 0.7;
}

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: var(--sunday-space-3) var(--sunday-space-4);
  text-align: left;
  border-bottom: 1px solid var(--sunday-line);
}

th {
  font-weight: var(--sunday-font-semibold);
  color: var(--sunday-text-muted);
  font-size: var(--sunday-text-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Lists ===== */
ul, ol {
  padding-left: var(--sunday-space-6);
}

li {
  margin-bottom: var(--sunday-space-2);
}

/* ===== Scrollbars ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--sunday-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--sunday-line);
  border-radius: var(--sunday-radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--sunday-text-muted);
}

/* ===== Selection ===== */
::selection {
  background: var(--sunday-accent);
  color: var(--sunday-bg);
}

/* ===== Focus Visible ===== */
:focus-visible {
  outline: 2px solid var(--sunday-accent);
  outline-offset: 2px;
}

/* ===== Animations ===== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Tooltips ===== */
/* Fix tooltips appearing above page tabs and other UI elements */
[title],
[data-tooltip],
.tooltip {
  position: relative;
}

/* Native browser tooltips */
[title]:hover {
  position: relative;
}

[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 6px 12px;
  background: var(--sunday-surface, #1a1f2e);
  color: var(--sunday-text, #fff);
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
  border: 1px solid var(--sunday-line, #2a3441);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 99999 !important; /* Above everything - page tabs (10), modals (1000), header */
  pointer-events: none;
  opacity: 0;
  animation: tooltipFadeIn 0.2s ease forwards;
}

@keyframes tooltipFadeIn {
  to { opacity: 1; }
}

/* Custom tooltip attribute */
[data-tooltip]:hover {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 6px 12px;
  background: var(--sunday-surface, #1a1f2e);
  color: var(--sunday-text, #fff);
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
  border: 1px solid var(--sunday-line, #2a3441);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 99999 !important;
  pointer-events: none;
  opacity: 0;
  animation: tooltipFadeIn 0.2s ease forwards;
}

/* Tooltip class */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  padding: 6px 12px;
  background: var(--sunday-surface, #1a1f2e);
  color: var(--sunday-text, #fff);
  font-size: 12px;
  white-space: nowrap;
  border-radius: 6px;
  border: 1px solid var(--sunday-line, #2a3441);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 99999 !important;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tooltip:hover::after {
  opacity: 1;
}

/* ===== FAB Stack — Right Side ===== */
/* Move all FABs to right side, stacked vertically, smaller */

.console-fab,
.ai-fab,
.sunday-fab,
[class*="fab-button"] {
  /* Smaller size */
  width: 44px !important;
  height: 44px !important;
  
  /* Move to right side */
  left: auto !important;
  right: 16px !important;
  
  /* Smaller icon */
  font-size: 18px !important;
}

.console-fab .console-fab-icon,
.ai-fab .fab-icon,
[class*="fab-button"] .fab-icon {
  font-size: 18px !important;
}

/* Stack FABs vertically on right side */
.console-fab,
.console-fab-bottom-left,
.console-fab-bottom-right,
.console-fab-middle-left {
  bottom: 80px !important; /* Above the dock */
  right: 16px !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
}

/* AI FAB stacks above Console FAB */
.ai-fab,
[data-fab="ai"] {
  bottom: 132px !important; /* 80 + 44 + 8 gap */
  right: 16px !important;
  left: auto !important;
  top: auto !important;
}

/* Third FAB if any */
[data-fab="actions"],
.actions-fab {
  bottom: 184px !important; /* 132 + 44 + 8 gap */
  right: 16px !important;
  left: auto !important;
  top: auto !important;
}

/* Smaller ring on hover */
.console-fab-ring {
  inset: -3px !important;
}

/* Adjust hover transforms for right-side position */
.console-fab:hover,
.ai-fab:hover,
[class*="fab-button"]:hover {
  transform: scale(1.08) !important;
}

.console-fab:active,
.ai-fab:active,
[class*="fab-button"]:active {
  transform: scale(0.95) !important;
}

