/* ===== PM Prototype Framework - Global Styles ===== */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --sidebar-width: 260px;
  --header-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--gray-800);
  background-color: var(--gray-50);
  line-height: 1.6;
}

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

a:hover {
  text-decoration: underline;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: white;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.sidebar-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: 999px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav li {
  margin-bottom: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--gray-600);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-nav a .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--gray-200);
  font-size: 12px;
  color: var(--gray-400);
  text-align: center;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.top-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
}

.top-header-actions {
  display: flex;
  gap: 12px;
}

.page-content {
  flex: 1;
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ===== Components ===== */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

.card-body {
  padding: 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  text-decoration: none;
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-50);
  text-decoration: none;
}

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-success:hover {
  background: #15803d;
  text-decoration: none;
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-label .required::after {
  content: "*";
  color: var(--danger);
  margin-left: 4px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.form-hint {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 6px;
}

/* ===== Grid ===== */
.grid {
  display: grid;
  gap: 24px;
}

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

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

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

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .page-content {
    padding: 20px;
  }
}

/* ===== Dashboard Stats ===== */
.stat-card {
  padding: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.stat-info h3 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.stat-info p {
  font-size: 14px;
  color: var(--gray-500);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-icon.blue {
  background: var(--primary-light);
  color: var(--primary);
}

.stat-icon.green {
  background: #dcfce7;
  color: var(--success);
}

.stat-icon.orange {
  background: #fef3c7;
  color: var(--warning);
}

.stat-icon.purple {
  background: #f3e8ff;
  color: #9333ea;
}

/* ===== Table ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--gray-200);
}

.data-table th {
  font-weight: 600;
  color: var(--gray-600);
  background: var(--gray-50);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.data-table tr:hover td {
  background: var(--gray-50);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-badge.draft {
  background: var(--gray-100);
  color: var(--gray-600);
}

.status-badge.draft::before {
  background: var(--gray-400);
}

.status-badge.review {
  background: #fef3c7;
  color: #b45309;
}

.status-badge.review::before {
  background: var(--warning);
}

.status-badge.approved {
  background: #dcfce7;
  color: #15803d;
}

.status-badge.approved::before {
  background: var(--success);
}

/* ===== Prototype Canvas ===== */
.prototype-workspace {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  gap: 20px;
  height: calc(100vh - var(--header-height) - 64px);
  min-height: 600px;
}

.components-panel,
.properties-panel {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-900);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.canvas-area {
  background: var(--gray-100);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 32px;
}

.canvas-device {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 375px;
  min-height: 720px;
  padding: 24px;
  position: relative;
}

.component-item {
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  margin-bottom: 10px;
  cursor: grab;
  background: white;
  transition: all 0.2s;
  text-align: center;
  font-size: 13px;
  color: var(--gray-600);
}

.component-item:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.component-item:active {
  cursor: grabbing;
}

.component-item .icon {
  display: block;
  font-size: 24px;
  margin-bottom: 6px;
}

.canvas-element {
  margin-bottom: 16px;
  position: relative;
}

.canvas-element.selected {
  outline: 2px dashed var(--primary);
  outline-offset: 4px;
}

/* ===== Mock Components ===== */
.mock-button {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

.mock-button.secondary {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.mock-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: white;
  color: var(--gray-400);
  font-size: 14px;
}

.mock-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
  display: block;
}

.mock-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.mock-card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--gray-900);
}

.mock-card p {
  font-size: 13px;
  color: var(--gray-500);
}

.mock-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.mock-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
}

.mock-list-item:last-child {
  border-bottom: none;
}

.mock-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.mock-navbar .logo {
  font-weight: 700;
  color: var(--primary);
}

.mock-navbar .nav-links {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--gray-500);
}

.mock-image {
  width: 100%;
  height: 160px;
  background: var(--gray-100);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 13px;
}

/* ===== Review Mode ===== */
.review-container {
  max-width: 900px;
  margin: 0 auto;
}

.review-header {
  text-align: center;
  margin-bottom: 32px;
}

.review-header h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.review-header p {
  color: var(--gray-500);
}

.review-preview {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 32px;
  margin-bottom: 24px;
}

.review-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.feedback-box {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 24px;
}

.feedback-box h3 {
  font-size: 16px;
  margin-bottom: 16px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--gray-800);
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 20px;
  font-size: 14px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: white;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  min-width: 280px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideIn 0.3s ease-out;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-900);
}

.toast-message {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

.toast-close {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

.mt-1 {
  margin-top: 8px;
}

.mt-2 {
  margin-top: 16px;
}

.mt-3 {
  margin-top: 24px;
}

.mb-2 {
  margin-bottom: 16px;
}

.flex {
  display: flex;
}

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

.gap-2 {
  gap: 16px;
}

.hidden {
  display: none !important;
}

.divider {
  height: 1px;
  background: var(--gray-200);
  margin: 20px 0;
}

/* ===== Print ===== */
@media print {
  .sidebar,
  .top-header,
  .components-panel,
  .properties-panel,
  .review-actions {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  .canvas-device {
    box-shadow: none;
    border: 1px solid var(--gray-300);
  }
}
