/* =============================================
   Hybrid Card Builder - Light Theme with Sidebar
   ============================================= */

:root {
  --bg: #f4f4f4;
  --fg: #111111;
  --card-bg: #ffffff;
  --sidebar-bg: #f0f2f5;
  --sidebar-border: #dcdcdc;
  --accent: #2c7be5;
  --card-border: #cccccc;
  --btn-bg: #e2e6ea;
  --btn-border: #dae0e5;
  --success: #28a745;
  --danger: #dc3545;
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.4;
}

/* ---- HEADER ---- */
.header {
  padding: 20px;
  background: #fff;
  border-bottom: 1px solid #ccc;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
}

/* ---- CONTAINER ---- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* ---- TOOLBAR ---- */
.toolbar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  background: #fff;
  padding: 16px;
  margin-bottom: 20px;
  border-radius: 8px;
  border: 1px solid #ccc;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar label {
  font-size: 13px;
  color: #555;
  font-weight: 500;
}

.toolbar input,
.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  border-color: var(--accent);
}

.toolbar input {
  width: 180px;
}

/* ---- BUTTONS ---- */
.btn {
  padding: 8px 14px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.btn:hover {
  background: #d0d7de;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn-primary:hover {
  background: #1a6dd4;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border: none;
}

.btn-warning {
  background: var(--danger);
  color: #fff;
  border: none;
}

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

/* ---- STATUS BADGE ---- */
.status-badge {
  display: none;
  background: var(--accent);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.status-badge.visible {
  display: inline-block;
}

/* ---- GRID ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

/* =============================================
   CARD STYLES - Sidebar Layout
   ============================================= */

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 90px; /* Reserve space for sidebar */
  min-height: 400px;
}

/* --- LEFT SIDEBAR (Icons) --- */
.stat-icons {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 90px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  padding: 10px 0;
  z-index: 2;
}

.stat-icons img {
  width: 65px;
  height: 65px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.1));
}

/* --- CARD IMAGE --- */
.card-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #fff;
  border-bottom: 1px solid #eee;
  display: block;
}

/* --- CARD BODY --- */
.card-body {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card-header {
  border-bottom: 2px solid #333;
  margin-bottom: 5px;
  padding-bottom: 5px;
}

.card-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  text-transform: uppercase;
  color: #000;
  letter-spacing: -0.5px;
}

.card-class {
  font-size: 10px;
  text-transform: uppercase;
  color: #666;
  background: #eee;
  padding: 2px 6px;
  border-radius: 4px;
  float: right;
  margin-top: 4px;
}

/* --- DESCRIPTION / STATS --- */
.card-description {
  font-size: 14px;
  color: #111;
  flex: 1;
}

.stat-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-line {
  font-size: 14px;
  color: #111;
  text-align: left;
  line-height: 1.3;
}

.stat-line strong {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 2px;
}

/* --- CARD CONTROLS --- */
.card-controls {
  padding: 10px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-left: -90px;
  width: calc(100% + 90px);
  background: #fff;
  z-index: 5;
}

/* --- BUSY OVERLAY --- */
.busy-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 16px;
  font-weight: 600;
  z-index: 10;
}

/* =============================================
   MODAL STYLES
   ============================================= */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.2s ease-out;
}

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

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: #111;
  padding: 20px 24px;
  margin: 0;
  border-bottom: 1px solid #ddd;
  background: #f9f9f9;
}

.modal-content {
  padding: 24px;
}

.modal-row {
  margin-bottom: 16px;
}

.modal-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-row input,
.modal-row textarea {
  width: 100%;
  background: #fff;
  border: 1px solid #ccc;
  color: #111;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.modal-row input:focus,
.modal-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-row textarea {
  min-height: 100px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  background: #f9f9f9;
  border-top: 1px solid #ddd;
}

/* ---- FOOTER ---- */
.footer {
  text-align: center;
  padding: 20px;
  color: #666;
  font-size: 13px;
  border-top: 1px solid #ddd;
  margin-top: 40px;
  background: #fff;
}

.footer code {
  background: #f0f0f0;
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--accent);
}

/* =============================================
   PRINT STYLES
   ============================================= */

@media print {
  @page {
    size: letter portrait;
    margin: 0.25in;
  }

  .header, .toolbar, .footer, .card-controls, .btn, .modal-overlay, .busy-overlay {
    display: none !important;
  }

  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .container { max-width: none; padding: 0; margin: 0; }

  .grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.2in;
  }

  .card {
    break-inside: avoid;
    height: 46vh;
    border: 2px solid #000;
    box-shadow: none;
    border-radius: 0;
    overflow: visible !important;
    position: relative !important;
    display: block !important;
    padding-left: 95px !important;
    background-color: #fff !important;
  }

  .stat-icons {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    height: 100% !important;
    width: 95px !important;
    z-index: 100 !important;
    background-color: #f0f0f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border-right: 2px solid #000;
    padding: 20px 0;
    justify-content: space-around;
  }

  .stat-icons img {
    width: 70px !important;
    height: 70px !important;
    display: block;
  }

  .card-image {
    width: 100%;
    height: 60%;
    border-bottom: 2px solid #000;
    object-fit: contain;
    object-position: center bottom;
  }

  .card-body {
    height: 40%;
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .card-header {
    border-bottom: 2px solid #000;
    margin-bottom: 8px;
    padding-bottom: 5px;
  }

  .card-title { font-size: 16pt; }

  .stat-line {
    font-size: 11pt;
    margin-bottom: 6px;
  }

  .stat-line strong {
    display: inline-block;
    width: 90px;
    font-weight: 800;
    color: #000;
  }
}
