/* ==========================================================================
   PIHU WEB TOOLS SUITE - UNIFIED PROFESSIONAL DESIGN SYSTEM
   Clean, Human-Crafted, High-Utility SaaS & Cyber/Print Studio UI
   ========================================================================== */

:root {
  /* Color Palette - Clean Light Theme */
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-surface-elevated: #ffffff;
  
  --border-color: #e2e8f0;
  --border-color-hover: #cbd5e1;
  --border-color-focus: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  /* Brand / Action Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active: #1e40af;
  --primary-subtle: #eff6ff;
  --primary-text: #1d4ed8;

  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-subtle: #ecfeff;

  --success: #16a34a;
  --success-hover: #15803d;
  --success-subtle: #f0fdf4;
  --success-text: #166534;

  --warning: #d97706;
  --warning-hover: #b45309;
  --warning-subtle: #fffbeb;
  --warning-text: #92400e;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-subtle: #fef2f2;
  --danger-text: #991b1b;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

  /* Layout & Geometry */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --header-height: 64px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-heading: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-surface-subtle: #1f2937;
  --bg-surface-elevated: #1e293b;

  --border-color: #1f293d;
  --border-color-hover: #334155;
  --border-color-focus: #60a5fa;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-active: #2563eb;
  --primary-subtle: #1e293b;
  --primary-text: #93c5fd;

  --accent: #06b6d4;
  --accent-hover: #22d3ee;
  --accent-subtle: #164e63;

  --success: #22c55e;
  --success-hover: #4ade80;
  --success-subtle: #14532d;
  --success-text: #86efac;

  --warning: #f59e0b;
  --warning-hover: #fbbf24;
  --warning-subtle: #78350f;
  --warning-text: #fde68a;

  --danger: #ef4444;
  --danger-hover: #f87171;
  --danger-subtle: #7f1d1d;
  --danger-text: #fca5a5;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

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

html {
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100%;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
  width: 100%;
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

.container-sm { max-width: 900px; }
.container-fluid { max-width: 100%; padding-left: 16px; padding-right: 16px; }

/* ==========================================================================
   Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
}

h1 { font-size: 2rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; letter-spacing: -0.015em; }
h4 { font-size: 1.1rem; }
p { color: var(--text-secondary); margin-bottom: 0.75rem; }
small { font-size: 0.825rem; color: var(--text-muted); }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--primary-hover);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 800;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  font-size: 1.1rem;
}

.brand-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background-color: var(--primary-subtle);
  color: var(--primary-text);
  letter-spacing: 0.5px;
}

.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.header-search-input {
  width: 100%;
  padding: 8px 14px 8px 38px;
  font-size: 0.9rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.header-search-input:focus {
  border-color: var(--primary);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.header-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
}

.header-search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  padding: 2px 6px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   Buttons & Controls
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--bg-surface-subtle);
  border-color: var(--border-color-hover);
}

.btn-outline {
  background-color: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background-color: var(--primary-subtle);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
  border-color: var(--success);
}
.btn-success:hover {
  background-color: var(--success-hover);
}

.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background-color: var(--danger-hover);
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 22px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: var(--radius-md); }

/* Form Elements */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Range Slider */
.form-range-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-range {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-color);
  border-radius: 4px;
  outline: none;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition-fast);
}

.form-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-badge {
  min-width: 54px;
  padding: 3px 8px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

/* ==========================================================================
   Cards & Layout Components
   ========================================================================== */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

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

/* Tool Grid Cards */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 14px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.tool-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tool-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  background-color: var(--primary-subtle);
  color: var(--primary);
}

.tool-card-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-subtle);
  color: var(--text-muted);
}

.tool-card-badge.popular {
  background-color: var(--success-subtle);
  color: var(--success-text);
}

.tool-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.tool-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 14px;
  flex: 1;
}

.tool-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

/* ==========================================================================
   Upload Dropzone
   ========================================================================== */
.dropzone {
  border: 2px dashed var(--border-color-hover);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  background-color: var(--bg-surface-subtle);
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background-color: var(--primary-subtle);
}

.dropzone-icon {
  font-size: 2.2rem;
  color: var(--primary);
  margin-bottom: 10px;
}

.dropzone-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dropzone-sub {
  font-size: 0.825rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Workspace Layout (Tools Studio)
   ========================================================================== */
.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

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

.workspace-sidebar {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.workspace-main {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow: auto;
  position: relative;
  min-height: 360px;
}

.canvas-container canvas {
  max-width: 100%;
  height: auto;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Pills, Tabs & Badges
   ========================================================================== */
.nav-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}

.pill-item {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.pill-item:hover {
  border-color: var(--border-color-hover);
  color: var(--text-primary);
}

.pill-item.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
}
.badge-primary { background-color: var(--primary-subtle); color: var(--primary-text); }
.badge-success { background-color: var(--success-subtle); color: var(--success-text); }
.badge-warning { background-color: var(--warning-subtle); color: var(--warning-text); }
.badge-danger { background-color: var(--danger-subtle); color: var(--danger-text); }

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 380px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error { border-left: 4px solid var(--danger); }
.toast.toast-info { border-left: 4px solid var(--primary); }

/* ==========================================================================
   Global Mobile Perfection (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .site-header {
    height: 56px;
  }
  .header-inner {
    padding: 0 12px;
    gap: 8px;
  }
  .header-search {
    display: none;
  }
  .brand-logo {
    font-size: 1rem;
    gap: 6px;
  }
  .brand-tag {
    display: none;
  }
  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
  .workspace {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 14px;
  }
  .workspace-sidebar, .workspace-main {
    padding: 14px;
    border-radius: var(--radius-md);
    max-height: none;
  }
  .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  .toast {
    max-width: calc(100vw - 32px);
    right: 16px;
    bottom: 16px;
  }
}

/* ==========================================================================
   Print Optimization
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .site-header, .workspace-sidebar, .workspace-toolbar, .site-footer, .no-print {
    display: none !important;
  }
  .workspace {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .workspace-main {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .canvas-container {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
  }
}
