/* ================================================================
   ICCAD PUBLIC STYLES
   ================================================================ */

/* === Main Search Bar Styling (Applies to both pages) === */
#ic-company-search {
  max-width: 1100px;
  margin: 42px auto;
  padding: 0 15px; /* Add padding for mobile */
  font-family: Arial, sans-serif;
}

.ic-input-group {
  display: flex;
  align-items: center;
  background: #fff;
  height: 60px;
  position: relative;
  z-index: 2;
}

/* HOMEPAGE Search Bar (fully rounded) */
#ic-company-search[data-mode="redirect"] .ic-input-group {
  border-radius: 30px;
  border: 1px solid #adb5bd;
  box-shadow: 0 4px 15px rgba(0,0,0,0.06);
}
#ic-company-search[data-mode="redirect"] .ic-input-group:focus-within {
  border-color: #D84039;
  box-shadow: 0 0 0 3px rgba(216, 64, 57, 0.2), 0 4px 15px rgba(0,0,0,0.06);
}

/* --- Shared input, button, and select styles --- */
.ic-input-group input#ic-company-name { flex: 1 1 auto; min-width: 0; border: 0; outline: none; background: transparent; padding: 0 20px; height: 100%; font-size: 16px; }

/* MODIFICATION START: Text is now visible by default */
.ic-input-group .ic-search-btn {
  flex-shrink: 0;
  height: 48px;
  width: 120px; /* MODIFIED: Set expanded width by default */
  margin: 0 6px;
  border: 0;
  border-radius: 24px; /* MODIFIED: Set pill shape by default */
  background: #D84039;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease; /* MODIFIED: Simplified transition */
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}

.ic-input-group .ic-search-btn:hover {
  background: #b53029; /* Only background color changes on hover */
}

.ic-input-group .ic-search-btn:active { transform: scale(0.95); }

.ic-search-icon-wrapper {
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.ic-input-group .ic-search-btn:hover .ic-search-icon-wrapper {
  transform: rotate(360deg); /* Icon still spins on hover */
}

.ic-search-icon {
  font-size: 18px;
}

.ic-search-text {
  font-size: 16px;
  font-weight: 600;
  margin-left: 8px;
  opacity: 1; /* MODIFIED: Text is always visible */
  transform: translateX(0); /* MODIFIED: Text is in its final position */
  /* Transitions removed as they are no longer needed */
}

/* REMOVED: The :hover rule for the text is no longer needed */
/* MODIFICATION END */

.ic-input-group .select2-container { flex: 0 0 220px; height: 100%; }
.ic-input-group .select2-container--default .select2-selection--single { height: 100%; width: 100%; display: flex; align-items: center; border: none; border-left: 1px solid #dee2e6; border-radius: 0; background-color: transparent; outline: none; }
.ic-input-group .select2-container--default .select2-selection--single .select2-selection__rendered { color: #495057; padding-left: 20px; padding-right: 30px; }
.ic-input-group .select2-container--default .select2-selection--single .select2-selection__arrow { height: 100%; right: 10px; }


/* ==========================================================
   RESULTS PAGE CARD LAYOUT
   ========================================================== */

#ic-company-search[data-mode="results"] {
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
  overflow: hidden;
}

#ic-company-search[data-mode="results"] .ic-input-group {
  border: none;
  border-bottom: 1px solid #e2e8f0;
}

#ic-company-search[data-mode="results"] .ic-results-wrap {
  margin-top: 0;
  border: none;
  background: #fff;
}

.ic-loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 350px;
}
.ic-loading-container p {
  margin-top: -30px;
  font-size: 16px;
  color: #555;
  font-weight: 500;
}

/* --- Results Table --- */
.ic-results-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.ic-results-table thead th { background: #233167; color: #fff; text-align: left; padding: 14px 18px; font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; border: none; }
.ic-results-table tbody td { padding: 14px 18px; border: none; vertical-align: middle; font-size: 15px; }
.ic-results-table tbody tr { border-top: 1px solid #eef2f7; }
.ic-results-table tbody tr:first-child { border-top: none; }
.ic-results-table tbody tr:hover { background-color: #f7f8fc; }
.ic-results-table tbody td:last-child { text-align: right; width: 100%; }

.ic-action-group {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.ic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.ic-btn:hover { transform: translateY(-1px); }
.ic-btn i { font-size: 16px; }

.ic-btn--details { color: #233167; background: #fff; border-color: #233167; }
.ic-btn--details:hover { background: #233167; color: #fff; box-shadow: 0 4px 12px rgba(35,49,103,.15); }

.ic-btn--buy { color: #fff; background: #D84039; border-color: #D84039; }
.ic-btn--buy:hover { background: #b53029; border-color: #b53029; box-shadow: 0 4px 12px rgba(216,64,57,.2); }


/* ==========================================================
   EXPANDABLE DETAILS ROW STYLES
   ========================================================== */
.ic-details-row td { padding: 0 !important; background-color: #f8f9fd; }
.icd-wrap { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; padding: 24px; text-align: left; background: #fff; }
.icd-left { min-width: 0; }
.icd-map { border-radius: 8px; overflow: hidden; }
.icd-map iframe { width: 100%; height: 100%; border: 0; }
.icd-hdr { font-weight: 800; color: #233167; margin-bottom: 16px; font-size: 18px; }
.icd-headbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; margin: 10px 0 20px; }
.icd-data-grid { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: baseline; }
.icd-data-grid strong { font-weight: 600; color: #333; }
.icd-secondary-info { display: none; grid-column: 1 / -1; }
.icd-secondary-info.is-open { display: contents; }
.icd-loader-wrap { display: flex; justify-content: center; align-items: center; padding: 40px; min-height: 200px; }
.ic-inline-spinner { width: 32px; height: 32px; border: 4px solid rgba(216, 64, 57, 0.2); border-top-color: #D84039; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================
   SELECT2 DROPDOWN THEME
   ========================================================== */
.select2-dropdown.ic-province-dropdown { border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); overflow: hidden; animation: fadeInDown 0.2s cubic-bezier(0.215, 0.610, 0.355, 1) forwards; }
@keyframes fadeInDown { from { opacity: 0; transform: translate3d(0, -10px, 0); } to { opacity: 1; transform: translate3d(0, 0, 0); } }
.select2-dropdown.ic-province-dropdown .select2-search--dropdown { padding: 8px; background-color: #f8f9fa; border-bottom: 1px solid #e2e8f0; }
.select2-dropdown.ic-province-dropdown .select2-search__field { border: 1px solid #ced4da; border-radius: 8px; outline: none; font-size: 14px; padding: 8px 12px; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.select2-dropdown.ic-province-dropdown .select2-search__field:focus { border-color: #D84039; box-shadow: 0 0 0 3px rgba(216, 64, 57, 0.2); }
.select2-dropdown.ic-province-dropdown .select2-results__options { padding: 6px; }
.select2-dropdown.ic-province-dropdown .select2-results__option { padding: 10px 14px; border-radius: 8px; margin: 2px 0; transition: background-color 0.15s ease, color 0.15s ease; }
.select2-dropdown.ic-province-dropdown .select2-results__option--highlighted[aria-selected] { background-color: #fff1f0; color: #c53030; }
.select2-dropdown.ic-province-dropdown .select2-results__option[aria-selected=true] { background-color: #D84039; color: #fff; font-weight: 600; }


/* ================================================================
   MOBILE RESPONSIVE STYLES
   ================================================================ */

   @media screen and (max-width: 768px) {

    #ic-company-search[data-mode="redirect"] .ic-input-group {
      border-radius: unset !important;
      border: unset !important;
      box-shadow: unset !important;;
    }

    /* --- Search Bar Adjustments --- */
    #ic-company-search {
        margin: 24px auto; /* Reduced margin on mobile */
    }

    /* MODIFICATION START: Stack form elements on mobile */
    .ic-input-group {
      flex-direction: column;
      height: auto;
      gap: 10px; /* Add space between stacked items */
      background: none;
      box-shadow: none;
      border: none;
    }

    .ic-input-group input#ic-company-name,
    .ic-input-group .select2-container {
      width: 100% !important;
      flex-basis: auto; /* Reset flex basis */
    }

    .ic-input-group input#ic-company-name {
        height: 54px;
        background: #fff;
        border: 1px solid #adb5bd;
        border-radius: 30px;
        padding: 0 25px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.06);
        font-size: 16px;
    }
    
    .ic-input-group .select2-container {
        height: 54px;
    }

    .ic-input-group .select2-container--default .select2-selection--single {
        background: #fff;
        border: 1px solid #adb5bd;
        border-radius: 30px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    }

    .ic-input-group .ic-search-btn {
      width: 100%;
      height: 54px;
      border-radius: 30px;
    }

    .ic-input-group .ic-search-btn:hover {
        width: 100%; 
        border-radius: 30px;
        background: #b53029;
    }

    .ic-input-group .ic-search-btn .ic-search-text {
        opacity: 1;
        transform: translateX(0);
    }
    
    .ic-input-group .ic-search-btn:hover .ic-search-icon-wrapper {
        transform: none; /* Disable spin on mobile for consistency */
    }

    .ic-input-group .ic-search-btn .ic-search-icon-wrapper {
        margin-right: 8px; /* Keep icon spaced from text */
    }
    /* MODIFICATION END */
  
    /* --- Results Table Adjustments (REWRITTEN) --- */
    .ic-results-table thead {
        display: none;
    }

    .ic-results-table, .ic-results-table tbody, .ic-results-table tr, .ic-results-table td {
        display: block;
        width: 100%;
    }

    #ic-company-search[data-mode="results"] {
      border: none;
      box-shadow: none;
      border-radius: 0;
      background: transparent;
    }

    .ic-results-table tr {
        margin-bottom: 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        overflow: hidden;
        border-top: none;
    }

    .ic-results-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        padding: 12px 15px;
        border-top: 1px solid #eef2f7;
        font-size: 14px;
    }

    .ic-results-table tr td:first-child {
        border-top: none;
    }

    /* The label (pseudo-element) */
    .ic-results-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #333;
        text-align: left;
        margin-right: 15px; /* Creates space between label and value */
        flex-shrink: 0; /* Prevents the label from shrinking if the value is long */
    }

    /* The value (span inside the td) */
    .ic-results-table td .ic-cell-value {
        text-align: right;
        word-break: break-word; /* Ensures long words do not overflow */
    }

    /* --- ACTION BUTTONS FIX --- */
    /* This cell doesn't need a label */
    .ic-results-table td.ic-cell-azione::before {
      display: none;
    }

    /* Make the action buttons take up the full width */
    .ic-results-table td.ic-cell-azione {
      padding: 12px 15px;
      justify-content: flex-start;
    }
    
    .ic-action-group {
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-items: center;
      justify-content: flex-start;
      gap: 8px;
    }
    .ic-action-group .ic-btn {
      padding: 8px 10px;
      font-size: 12px;
    }
    .ic-action-group .ic-btn i {
      font-size: 14px;
    }
  
    /* --- Expandable Details Adjustments --- */
    .icd-wrap {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }
    .icd-hdr {
        font-size: 16px;
    }
    .icd-data-grid {
        grid-template-columns: 1fr;
        gap: 4px 0;
    }
    .icd-data-grid strong, .icd-data-grid span {
        display: block;
        width: 100%;
        text-align: left;
        font-size: 14px;
    }
    .icd-data-grid strong {
        margin-top: 8px;
        color: #555;
    }
    .icd-data-grid strong:first-of-type {
        margin-top: 0;
    }
    .icd-map {
        min-height: 250px;
    }
  }