/* 
 * US Address & Transcript Generator
 * Modern Theme with Glassmorphism - Dark/Light Mode Support
 */

/* =====================================================
   CSS Variables - Design Tokens (Dark Theme - Default)
   ===================================================== */
:root {
  /* Shared Colors */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);

  /* Dark Theme Colors */
  --bg-dark: #0f0f1a;
  --bg-card: rgba(30, 30, 50, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-input: rgba(255, 255, 255, 0.08);

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);

  --border-glass: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(102, 126, 234, 0.5);

  --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.3);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);

  /* Background Animation Colors */
  --bg-gradient-1: rgba(102, 126, 234, 0.15);
  --bg-gradient-2: rgba(118, 75, 162, 0.15);
  --bg-gradient-3: rgba(79, 172, 254, 0.1);

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* =====================================================
   Light Theme Variables
   ===================================================== */
[data-theme="light"] {
  --bg-dark: #f0f2f5;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-glass: rgba(0, 0, 0, 0.02);
  --bg-input: rgba(0, 0, 0, 0.05);

  --text-primary: #1a1a2e;
  --text-secondary: rgba(26, 26, 46, 0.7);
  --text-muted: rgba(26, 26, 46, 0.5);

  --border-glass: rgba(0, 0, 0, 0.1);
  --border-focus: rgba(102, 126, 234, 0.5);

  --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.1);

  --bg-gradient-1: rgba(102, 126, 234, 0.08);
  --bg-gradient-2: rgba(118, 75, 162, 0.08);
  --bg-gradient-3: rgba(79, 172, 254, 0.05);
}

/* System preference: auto-detect light mode */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg-dark: #f0f2f5;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-glass: rgba(0, 0, 0, 0.02);
    --bg-input: rgba(0, 0, 0, 0.05);

    --text-primary: #1a1a2e;
    --text-secondary: rgba(26, 26, 46, 0.7);
    --text-muted: rgba(26, 26, 46, 0.5);

    --border-glass: rgba(0, 0, 0, 0.1);
    --border-focus: rgba(102, 126, 234, 0.5);

    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.15);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.1);

    --bg-gradient-1: rgba(102, 126, 234, 0.08);
    --bg-gradient-2: rgba(118, 75, 162, 0.08);
    --bg-gradient-3: rgba(79, 172, 254, 0.05);
  }
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 80%, var(--bg-gradient-1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, var(--bg-gradient-2) 0%, transparent 50%),
    radial-gradient(circle at 40% 40%, var(--bg-gradient-3) 0%, transparent 40%);
  pointer-events: none;
  z-index: -1;
  animation: backgroundPulse 15s ease-in-out infinite;
  transition: background var(--transition-slow);
}

@keyframes backgroundPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* =====================================================
   Typography
   ===================================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--spacing-md);
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.25rem;
}

/* =====================================================
   Layout
   ===================================================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-xl);
}

.app-header {
  text-align: center;
  padding: var(--spacing-2xl) var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
}

.app-header h1 {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--spacing-sm);
}

.app-header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: var(--spacing-xl);
}

@media (max-width: 1024px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   Cards & Glass Effects
   ===================================================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-glass);
}

.card-header h2 {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: 0;
  font-size: 1.25rem;
}

.card-header .icon {
  font-size: 1.5rem;
}

/* =====================================================
   Address Card
   ===================================================== */
.address-card {
  margin-bottom: var(--spacing-xl);
}

.address-card.animate-in {
  animation: slideIn 0.5s ease-out;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.info-row {
  display: flex;
  align-items: flex-start;
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  min-width: 100px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.info-value {
  flex: 1;
  font-weight: 500;
}

.copy-btn {
  background: var(--bg-input);
  border: none;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.copy-btn.copied {
  background: rgba(56, 239, 125, 0.2);
  color: #38ef7d;
}

/* =====================================================
   Form Elements
   ===================================================== */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: var(--spacing-xs);
}

.form-control {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-success {
  background: var(--success-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(56, 239, 125, 0.3);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(56, 239, 125, 0.4);
}

.btn-danger {
  background: var(--secondary-gradient);
  color: white;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-group {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 87, 108, 0.2);
  color: #f5576c;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: bold;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(245, 87, 108, 0.4);
}

/* Loading Spinner */
.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

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

/* =====================================================
   Course Table
   ===================================================== */
.course-table-container {
  overflow-x: auto;
  margin-top: var(--spacing-md);
}

.course-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.course-table th,
.course-table td {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  border-bottom: 1px solid var(--border-glass);
}

.course-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.course-table tbody tr:hover {
  background: var(--bg-glass);
}

.level-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.level-standard {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.level-honors {
  background: rgba(79, 172, 254, 0.2);
  color: #4facfe;
}

.level-ap {
  background: rgba(102, 126, 234, 0.2);
  color: #667eea;
}

.level-ib {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
}

/* =====================================================
   Inline Edit & New Features
   ===================================================== */
.hidden {
  display: none !important;
}

.inline-edit {
  background: var(--bg-input);
  border: 1px solid var(--border-focus);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 100%;
  max-width: 200px;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 0.875rem;
}

.form-control-inline {
  width: auto;
  min-width: 150px;
  display: inline-block;
}

/* Logo Preview */
.logo-preview-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
}

.logo-preview {
  max-width: 80px;
  max-height: 80px;
  border-radius: 8px;
  object-fit: contain;
}

/* School Logo in Transcript */
.school-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
  margin-bottom: 10px;
}

/* Watermark Effect - Logo Based */
.watermark-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40%;
  height: 40%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
}

.watermark-logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0.08;
  filter: grayscale(100%);
}

/* Signature Section */
.signature-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 20px;
  padding: 15px 30px;
}

.signature-left {
  flex: 1;
  text-align: center;
  max-width: 200px;
}

.signature-right {
  flex: 1;
  text-align: center;
  max-width: 150px;
}

.signature-display {
  font-family: 'Great Vibes', 'Dancing Script', cursive;
  font-size: 24px;
  color: #1a1a2e;
  min-height: 35px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2px;
}

.signature-line {
  border-bottom: 1px solid #333;
  margin-bottom: 5px;
}

.signature-label {
  font-size: 0.75rem;
  color: #666;
  margin: 0;
}

.signature-date {
  display: block;
  font-weight: 500;
  padding-bottom: 5px;
  border-bottom: 1px solid #333;
  margin-bottom: 5px;
}

/* Verification Note */
.verification-note {
  font-size: 0.8rem;
  color: #666;
  margin-top: 8px;
}

/* =====================================================
   Transcript Preview
   ===================================================== */
.transcript-preview {
  background: white;
  color: #1a1a2e;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.transcript-inner {
  padding: var(--spacing-xl);
  position: relative;
  z-index: 2;
}

.transcript-header {
  text-align: center;
  border-bottom: 2px solid #1a1a2e;
  padding-bottom: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.transcript-header h2 {
  color: #1a1a2e;
  font-size: 1.5rem;
  margin-bottom: var(--spacing-xs);
}

.transcript-header p {
  color: #666;
  font-size: 0.875rem;
  margin: 0;
}

.transcript-section {
  margin-bottom: var(--spacing-lg);
}

.transcript-section h3 {
  color: #1a1a2e;
  font-size: 1rem;
  border-bottom: 1px solid #ddd;
  padding-bottom: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
}

.transcript-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-sm) var(--spacing-lg);
}

.transcript-row {
  display: flex;
  gap: var(--spacing-sm);
}

.transcript-label {
  color: #666;
  font-size: 0.875rem;
  min-width: 120px;
}

.transcript-value {
  color: #1a1a2e;
  font-weight: 500;
}

/* Transcript Table */
.transcript-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: var(--spacing-sm);
}

.transcript-table th,
.transcript-table td {
  padding: 6px 8px;
  text-align: left;
  border: 1px solid #ddd;
}

.transcript-table th {
  background: #f5f5f5;
  color: #333;
  font-weight: 600;
}

.transcript-table tbody tr:nth-child(even) {
  background: #fafafa;
}

/* Credit Summary */
.credit-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
}

.credit-item {
  text-align: center;
  padding: var(--spacing-sm);
  background: #f5f5f5;
  border-radius: var(--radius-sm);
}

.credit-item .label {
  font-size: 0.7rem;
  color: #666;
  display: block;
}

.credit-item .value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1a2e;
}

/* Transcript Footer */
.transcript-footer {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-md);
  border-top: 1px solid #ddd;
  font-size: 0.75rem;
  color: #666;
  text-align: center;
}

.transcript-footer p {
  margin: var(--spacing-xs) 0;
}

.disclaimer {
  font-style: italic;
  color: #999;
}

/* =====================================================
   School Info Card
   ===================================================== */
.school-info {
  background: linear-gradient(135deg, rgba(17, 153, 142, 0.1), rgba(56, 239, 125, 0.05));
  border: 1px solid rgba(56, 239, 125, 0.2);
}

/* =====================================================
   Responsive Design
   ===================================================== */
@media (max-width: 768px) {
  .container {
    padding: var(--spacing-md);
  }

  .app-header h1 {
    font-size: 1.75rem;
  }

  .card {
    padding: var(--spacing-md);
  }

  .transcript-grid {
    grid-template-columns: 1fr;
  }

  .credit-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-row {
    flex-direction: column;
    gap: var(--spacing-xs);
  }

  .info-label {
    min-width: auto;
  }
}

/* =====================================================
   Utility Classes
   ===================================================== */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.text-small {
  font-size: 0.875rem;
}

.mt-sm {
  margin-top: var(--spacing-sm);
}

.mt-md {
  margin-top: var(--spacing-md);
}

.mt-lg {
  margin-top: var(--spacing-lg);
}

.mb-sm {
  margin-bottom: var(--spacing-sm);
}

.mb-md {
  margin-bottom: var(--spacing-md);
}

.mb-lg {
  margin-bottom: var(--spacing-lg);
}

/* =====================================================
   Theme Toggle Button
   ===================================================== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-card);
}

.theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.theme-toggle-icon {
  font-size: 1.25rem;
  transition: transform var(--transition-normal);
}

.theme-toggle:hover .theme-toggle-icon {
  transform: rotate(15deg);
}

.theme-toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-normal);
}

.theme-toggle:hover .theme-toggle-label {
  color: var(--text-primary);
}

/* Responsive: hide label on small screens */
@media (max-width: 600px) {
  .theme-toggle {
    padding: var(--spacing-sm);
  }

  .theme-toggle-label {
    display: none;
  }
}

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

  body::before {
    display: none;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .btn,
  .copy-btn {
    display: none;
  }
}