/* base.css - Core styles, variables, and layout fundamentals */

:root {
  /* Color Scheme */
  --bg-main: #1a1a1a;
  --bg-surface: #2d2d2d;
  --bg-elevated: #363636;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-tertiary: #707070;
  --border-color: #404040;
  --accent-color: #ff6d14;
  --accent-hover: #e65c00;
  --accent-muted: rgba(255, 109, 20, 0.1);
  --error-color: #f44336;
  --success-color: #4caf50;
  --warning-color: #ff9800;
  --info-color: #2196f3;
  --code-bg: var(--bg-elevated);
  --code-border: var(--border-color);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Typography */
  --font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-mono: "Menlo", "Monaco", "Courier New", monospace;

  /* Z-index layers */
  --z-dropdown: 1000;
  --z-modal: 2000;
  --z-tooltip: 3000;
}

:root[data-theme="light"] {
  --bg-main: #fdfcf9;
  --bg-surface: #fdfbf1;
  --bg-elevated: #ece9dc;
  --text-primary: #1a1a1a;
  --text-secondary: #8b8b8b;
  --text-tertiary: #b4ad99;
  --border-color: #adadad;
  --accent-color: #ff6e14;
  --accent-hover: #e65c00;
  --accent-muted: rgba(255, 109, 20, 0.1);
  --error-color: #dc3545;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --info-color: #17a2b8;
  --code-bg: #ecebe1;
  --code-border: #adadad;
}

:root[data-theme="dark"] {
  --text-primary: #eeeeee;
  --text-secondary: #8b8b8b;
}

/* Reset & Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-main);
  min-height: 100%;
  overflow-x: hidden;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--space-md);
  line-height: 1.2;
  color: var(--text-primary);
  font-weight: 600;
}

h1 {
  font-size: 2rem;
}
h2 {
  font-size: 1.75rem;
}
h3 {
  font-size: 1.5rem;
}
h4 {
  font-size: 1.25rem;
}
h5 {
  font-size: 1.125rem;
}
h6 {
  font-size: 1rem;
}

p {
  margin: 0 0 var(--space-md);
}

a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Form Elements */
input,
textarea,
select {
  font-family: inherit;
  font-size: 1rem;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-muted);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

.project-indicator {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  margin: 0 auto;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.project-label {
  font-weight: 500;
  margin-right: 0.5rem;
}

.project-name {
  color: var(--text-primary);
  font-weight: 600;
}

#currentProjectName:not(:empty) {
  color: var(--text-primary);
}

/* Select Button Style */
select.button {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1em;
  transform: none;
}

select.button:hover {
  background-color: transparent;
  border-color: var(--text-secondary);
  transform: none;
}

select.button:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-muted);
  background-color: transparent;
  transform: none;
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}
.gap-md {
  gap: var(--space-md);
}
.gap-lg {
  gap: var(--space-lg);
}

/* Grid System */
.grid {
  display: grid;
  gap: var(--space-md);
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* Spacing Utilities */
.m-0 {
  margin: 0;
}
.p-0 {
  padding: 0;
}

.mt-sm {
  margin-top: var(--space-sm);
}
.mt-md {
  margin-top: var(--space-md);
}
.mt-lg {
  margin-top: var(--space-lg);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}
.mb-md {
  margin-bottom: var(--space-md);
}
.mb-lg {
  margin-bottom: var(--space-lg);
}

/* Cards */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  box-shadow: var(--shadow-md);
}

/* Alerts */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.alert-error {
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid var(--error-color);
  color: var(--error-color);
}

.alert-success {
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid var(--success-color);
  color: var(--success-color);
}

.alert-warning {
  background: rgba(255, 152, 0, 0.1);
  border: 1px solid var(--warning-color);
  color: var(--warning-color);
}

.alert-info {
  background: rgba(33, 150, 243, 0.1);
  border: 1px solid var(--info-color);
  color: var(--info-color);
}

/* Loading States */
.loading {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 0.8s linear infinite;
}

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

/* Tooltips */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: var(--z-tooltip);
}

[data-tooltip]:hover:before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-4px);
}

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

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

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

/* Selection */
::selection {
  background: var(--accent-color);
  color: white;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
  .grid-cols-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .container {
    padding: 0 var(--space-sm);
  }
}

@media (max-width: 480px) {
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
    color: black;
  }

  .no-print {
    display: none !important;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
