/* Tabs */
.cfd-tabs { display:flex; margin-bottom:20px; border-bottom:1px solid #ccc; }
.cfd-tab { padding:10px 20px; cursor:pointer; background:#f1f1f1; margin-right:2px; border-top-left-radius:4px; border-top-right-radius:4px; }
.cfd-tab.active { background:#0073aa; color:#fff; }

/* Panels */
.cfd-tab-content { display:none; }
.cfd-tab-content.active { display:block; }

/* Item cards: updated layout */
.cfd-items { display:grid; grid-template-columns:1fr; gap:15px; }
.cfd-item-card { display:flex; flex-direction:column; border:1px solid #e0e0e0; border-radius:6px; background:#fff; padding:10px; }
.cfd-item-main {
    display: flex;
    flex-direction: row;
    align-items: center;
    cursor: pointer;
}
.cfd-item-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    margin-right: 15px;
    border-radius: 4px;
}
.cfd-item-details { flex:1; }
.cfd-item-details h4 { margin:0 0 8px; font-size:1.2em; }
.cfd-item-details p { margin:4px 0; line-height:1.4; }

/* Actions below */
.cfd-actions { margin-top:10px; display:flex; gap:8px; }
.cfd-actions button { flex:1; padding:6px; border:none; border-radius:4px; cursor:pointer; }
.cfd-edit-btn { background:#ffc107; color:#000; }
.cfd-delete-btn { background:#dc3232; color:#fff; }

/* Forms */
.cfd-add-form label, .cfd-settings-input { display:block; margin-bottom:10px; }
.cfd-add-form input, .cfd-add-form select, .cfd-add-form textarea { width:100%; padding:8px; border:1px solid #ccc; border-radius:4px; }
.cfd-add-form button { padding:10px 15px; background:#0073aa; color:#fff; border:none; border-radius:4px; cursor:pointer; }

/* Settings tags */
.cfd-settings-group { margin-bottom:20px; }
.cfd-tag { display:inline-flex; align-items:center; background:#0073aa; color:#fff; padding:4px 8px; border-radius:4px; margin:2px; }
.cfd-tag button { background:none; border:none; color:#fff; margin-left:6px; cursor:pointer; font-weight:bold; }

/* Settings input/button */
.cfd-settings-input { display:flex; gap:8px; align-items:center; }
.cfd-settings-input input { flex:3; padding:6px; border:1px solid #ccc; border-radius:4px; }
.cfd-settings-input button { flex:1; max-width:100px; padding:6px; background:#0073aa; color:#fff; border:none; border-radius:4px; cursor:pointer; }

/* Settings tab improved styling */
#cfd-tab-settings { padding: 20px; }
.cfd-settings-container { display: flex; gap: 40px; margin-bottom: 20px; }
.cfd-settings-group { flex: 1; }
.cfd-settings-group h4 { margin-bottom: 10px; font-size: 1.1em; }
.cfd-settings-input { margin-top: 10px; display: flex; gap: 8px; }
.cfd-settings-input input { flex: 1; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.cfd-settings-input button { padding: 8px 16px; background: #0073aa; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
#cfd-save-settings-btn { display: inline-block; padding: 10px 20px; background: #0073aa; color: #fff; border: none; border-radius: 4px; cursor: pointer; float: right; margin-top: 10px; }
.cfd-tag { display: inline-flex; align-items: center; background: #0073aa; color: #fff; padding: 6px 10px; border-radius: 20px; margin: 4px 4px 8px 0; font-size: 0.9em; }
.cfd-tag button { background: none; border: none; color: #fff; margin-left: 8px; cursor: pointer; font-size: 1em; }


/* Tabs styling */
.cfd-tabs {
    margin-bottom: 20px;
}
.cfd-tabs .cfd-tab {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid #ddd;
    border-bottom: none;
    background: #f7f7f7;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    margin-right: 4px;
}
.cfd-tabs .cfd-tab.active {
    background: #fff;
    border-bottom: 1px solid #fff;
}
.cfd-tab-content {
    display: none;
    padding: 20px;
    border: 1px solid #ddd;
    background: #fff;
}
.cfd-tab-content.active {
    display: block;
}

.cfd-item-info {
    display: flex;
    flex-direction: column;
}
/* Ensure 4-column grid */
.cfd-items-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 15px;
}

/* Thumbnail on left, info on right */
.cfd-item-main {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.cfd-item-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    margin-right: 15px;
    border-radius: 4px;
}
.cfd-item-info {
    display: flex;
    flex-direction: column;
}


/* Accordion: hide details and actions until expanded */
.cfd-item-details,
.cfd-actions {
    display: none;
}
.cfd-item-card.expanded .cfd-item-details,
.cfd-item-card.expanded .cfd-actions {
    display: block;
}


/* Expanded details styling: category, vendor, notes */
.cfd-item-category,
.cfd-item-vendor,
.cfd-item-notes {
    margin-top: 4px;
    font-size: 0.9em;
    color: #555;
}

/* Action buttons below details, side by side, pill-shaped */
.cfd-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.cfd-actions button {
    flex: 1;
    border-radius: 999px;
    padding: 8px 0;
    border: none;
}
.cfd-edit-btn {
    background: #ffc107;
    color: #000;
}
.cfd-delete-btn {
    background: #dc3545;
    color: #fff;
}


/* Fix: Keep Edit/Delete buttons inline when expanded */
.cfd-item-card.expanded .cfd-actions {
    display: flex !important;
    gap: 10px;
    margin-top: 10px;
}
.cfd-actions button {
    flex: 1 1 auto !important;
    max-width: none !important;
}


/* Final fix: force inline buttons when expanded */
.cfd-item-card.expanded .cfd-actions {
  display: flex !important;
  flex-direction: row !important;
  gap: 10px !important;
  margin-top: 10px !important;
}
.cfd-actions button {
  flex: 1 1 auto !important;
  margin: 0 !important;
}


/* Highlight by age */
.cfd-item-card.cfd-item-old-20 {
    background-color: #fff3cd;
}
.cfd-item-card.cfd-item-old-30 {
    background-color: #ffe5e5;
}


/* Table layout for items */
.cfd-items-table {
  width: 100%;
  border-collapse: collapse;
}
.cfd-items-table th,
.cfd-items-table td {
  padding: 10px;
  border-bottom: 1px solid #e0e0e0;
  vertical-align: middle;
}
.cfd-items-table th {
  text-align: left;
}
/* Hide details rows by default */
.cfd-item-details-row {
  display: none;
}
.cfd-item-row.expanded + .cfd-item-details-row {
  display: table-row;
}
/* Details content styling */
.cfd-item-details-content div {
  margin: 4px 0;
}
/* Thumbnail in table */
.cfd-item-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}


/* Age highlighting for table rows */
.cfd-item-row.cfd-item-old-20 {
    background-color: #fff3cd;
}
.cfd-item-row.cfd-item-old-30 {
    background-color: #ffe5e5;
}


/* ── Settings Tab: Slick Card Layout ───────────────────────────────────── */
#cfd-tab-settings {
  padding: 30px;
  background: #fafafa;
  border-radius: 8px;
}

.cfd-settings-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-bottom: 20px;
}

.cfd-settings-group {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.cfd-settings-group h4 {
  margin-bottom: 16px;
  font-size: 1.2em;
  color: #001f3f;
}

#cfd-cat-tags, #cfd-ven-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.cfd-tag {
  background: #0073aa;
  color: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.9em;
  display: inline-flex;
  align-items: center;
}

.cfd-tag button.cfd-remove-tag {
  background: none;
  border: none;
  color: #fff;
  margin-left: 8px;
  font-size: 1em;
  cursor: pointer;
}

.cfd-settings-input {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.cfd-settings-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.cfd-settings-input button {
  padding: 8px 16px;
  background: #001f3f;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

.cfd-settings-input button:hover {
  background: #00294d;
}

#cfd-save-settings-btn {
  float: right;
  padding: 12px 24px;
  background: #001f3f;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
}

#cfd-save-settings-btn:hover {
  background: #00294d;
}

/* Clear floats */
#cfd-save-settings-btn:after {
  content: "";
  display: block;
  clear: both;
}

/* Compact table rows */
.cfd-items-table th,
.cfd-items-table td {
  padding: 4px 8px !important;
  line-height: 1.2 !important;
}

.cfd-items-table {
  margin-top: 10px;
}

/* Smaller thumbnail */
.cfd-item-img {
  width: 40px;
  height: 40px;
  margin: 0;
}

/* Reduce search box height */
#cfd-search-box {
  padding: 4px 8px !important;
  height: auto;
}

/* Tight header spacing */
.cfd-items-table thead th {
  font-weight: bold;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
}

/* Tightened details content */
.cfd-item-details-content div {
  margin: 2px 0 !important;
  font-size: 0.9em !important;
}


/* Compact table rows */
.cfd-items-table th,
.cfd-items-table td {
  padding: 4px 8px !important;
  line-height: 1.2 !important;
  font-size: 0.9em !important;
}

/* Smaller thumbnail */
.cfd-item-img {
  width: 40px !important;
  height: 40px !important;
  margin: 0;
}

/* Compact search box */
#cfd-search-box {
  padding: 4px 8px !important;
  font-size: 0.9em;
  height: auto;
}

/* Slick Add/Edit form */
#cfd-tab-add {
  background: #fafafa;
  padding: 20px;
  border-radius: 6px;
}
.cfd-add-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
.cfd-add-form label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
}
.cfd-add-form input,
.cfd-add-form select,
.cfd-add-form textarea {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-top: 4px;
}
.cfd-add-form button[type="submit"] {
  grid-column: 1 / -1;
  justify-self: end;
  padding: 8px 16px;
  background: #001f3f;
  color: #fff;
  border: none;
  border-radius: 4px;
}

/* Slick two-column Add/Edit form */
#cfd-tab-add {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 20px;
  box-shadow: none;
}
.cfd-add-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}
.cfd-add-form label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
  margin-bottom: 0;
}
.cfd-add-form input,
.cfd-add-form select,
.cfd-add-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-top: 6px;
}
.cfd-add-form textarea {
  resize: vertical;
}
.cfd-add-form button[type="submit"] {
  grid-column: 1 / -1;
  justify-self: end;
  padding: 8px 16px;
  background: #001f3f;
  color: #fff;
  border: none;
  border-radius: 4px;
  margin-top: 10px;
}

/* Add Item: Excel-like inline fields */
.cfd-add-form {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: auto auto auto;
  gap: 16px;
  grid-template-areas:
    "item_name category vendor quantity last_ordered"
    "notes notes image image image"
    "submit submit submit submit submit";
}
.cfd-field-item_name { grid-area: item_name; }
.cfd-field-category { grid-area: category; }
.cfd-field-vendor { grid-area: vendor; }
.cfd-field-quantity { grid-area: quantity; }
.cfd-field-last_ordered { grid-area: last_ordered; }
.cfd-field-notes { grid-area: notes; }
.cfd-field-image { grid-area: image; }
.cfd-field-submit { grid-area: submit; justify-self: end; }

#cfd-tab-add {
  padding: 20px;
  background: #fafafa;
  border-radius: 6px;
}

/* Responsive mobile layout for Add Item form */
@media (max-width: 768px) {
  .cfd-add-form {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-areas:
      "item_name item_name"
      "category vendor"
      "quantity last_ordered"
      "notes notes"
      "image image"
      "submit submit";
    gap: 12px;
  }
}

/* Responsive Settings Tab */
@media (max-width: 768px) {
  /* Stack settings groups vertically */
  .cfd-settings-container {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  /* Full width tag containers */
  #cfd-cat-tags,
  #cfd-ven-tags {
    justify-content: flex-start !important;
  }
  /* Inputs full width */
  .cfd-settings-input {
    flex-direction: column !important;
    gap: 10px !important;
  }
  .cfd-settings-input input,
  .cfd-settings-input button {
    width: 100% !important;
    max-width: none !important;
  }
  /* Save button full width */
  #cfd-save-settings-btn {
    float: none !important;
    width: 100% !important;
    margin-top: 20px !important;
  }
}
