/* ===== FitVibes · Foods - DARK THEME ===== */

/* Dark theme variables */
:root{
    --fv-primary: #69B254;
    --fv-ink: #ffffff;
    --fv-card: rgba(255,255,255,.05);
    --fv-card-strong: rgba(255,255,255,.08);
    --fv-border: rgba(255,255,255,.1);
    --fv-border-strong: rgba(255,255,255,.15);
    --fv-shadow: 0 6px 20px rgba(0,0,0,.4);
  }
  
  .foods-page .foods-card{
    background: var(--fv-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--fv-border);
    border-radius: 18px;
    padding: clamp(16px, 3vw, 28px);
    max-width: 1200px;
    margin: 0 auto;
  }
  
  /* naslov i podnaslov */
  .foods-head{
    text-align:center;
    margin-bottom: clamp(8px, 1.2vw, 14px);
  }
  .foods-title{
    font-weight: 800;
    line-height: 1.1;
    font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.3rem);
    margin: 0 0 .25rem 0;
  }
  .foods-subtitle{
    margin: 0;
    opacity: .85;
    font-size: clamp(.95rem, .8rem + .5vw, 1.05rem);
  }
  
  /* blok sa kontrolama */
  .foods-controls{ margin-top: .4rem; margin-bottom: .6rem; }
  
  /* SEARCH – centriran, sa ikonicom */
  #fv-food-search{
    display:block;
    width: min(580px, 100%);
    margin: 0 auto clamp(12px, 2vw, 18px);
    height: 52px;
    border-radius: 14px;
    background: var(--fv-card-strong);
    border: 1px solid var(--fv-border);
    padding: 12px 16px 12px 42px;
    font-size: 1rem;
    outline: none;
    color: var(--fv-ink);
    background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='7' stroke='%23ffffff' stroke-opacity='.7' stroke-width='2'/%3E%3Cpath d='M20 20L17 17' stroke='%23ffffff' stroke-opacity='.7' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px 50%;
  }
  #fv-food-search::placeholder{ opacity:.7; }
  #fv-food-search:focus{
    border-color: var(--fv-primary);
    box-shadow: 0 0 0 3px rgba(105, 178, 84, 0.3);
  }
  
  /* Inputi i select – ujednačeni */
  .foods-controls .form-label{
    font-weight: 600;
    opacity: .9;
    margin-bottom: .35rem;
  }
  .foods-controls .form-control,
  .foods-controls .form-select{
    height: 48px;
    border-radius: 14px;
    background: var(--fv-card-strong);
    border: 1px solid var(--fv-border);
    padding: 10px 14px;
    font-size: 1rem;
    color: var(--fv-ink);
  }
  .foods-controls .form-control:focus,
  .foods-controls .form-select:focus{
    border-color: var(--fv-primary) !important;
    box-shadow: 0 0 0 3px rgba(105, 178, 84, 0.3) !important;
    outline: none;
  }

  .foods-controls .form-select option {
    background: #1f1f1f;
    color: #ffffff;
  }
  
  /* SORT & CLEAR CONTAINER - Force left/right alignment on desktop */
  @media (min-width: 768px) {
    .foods-controls .d-flex {
      justify-content: space-between !important;
      width: 100% !important;
    }
    .foods-controls .d-flex > div {
      width: auto !important;
    }
  }

  /* CLEAR – ghost dugme */
  #fv-clear.btn{
    border: none;
    background: transparent;
    color: var(--fv-primary);
    font-weight: 800;
    padding: 10px 12px;
    border-radius: 12px;
    letter-spacing: .01em;
  }
  #fv-clear.btn:hover{ background: rgba(105, 178, 84, 0.15); }
  
  /* Meta i paginacija */
  .foods-meta{
    display:flex; align-items:center; justify-content:space-between;
    gap: 14px; margin: 8px 0 16px;
    flex-wrap: wrap;
  }
  #fv-results{ font-weight: 600; opacity:.9; }
  .foods-meta .pagination{
    display:flex; gap:10px; align-items:center;
  }
  .foods-meta .pagination button{
    border: 1px solid var(--fv-border-strong);
    background: var(--fv-card-strong);
    border-radius: 12px; width: 42px; height: 40px;
    font-weight: 700;
  }
  .foods-meta .pagination button:disabled{
    opacity:.5; pointer-events:none;
  }
  #fv-page{ min-width: 66px; text-align:center; font-weight:700; }
  
  /* GRID */
  .foods-grid{
    display:grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
  }
  /* kolone po širini – bez da diramo HTML */
  @media (min-width: 1201px){
    .foods-grid > *{ grid-column: span 3; }   /* 4 u redu */
  }
  @media (min-width: 992px) and (max-width: 1200px){
    .foods-grid > *{ grid-column: span 4; }   /* 3 u redu */
  }
  @media (min-width: 640px) and (max-width: 991px){
    .foods-grid > *{ grid-column: span 6; }   /* 2 u redu */
  }
  @media (max-width: 639px){
    .foods-grid > *{ grid-column: 1 / -1; }   /* 1 u redu */
  }
  
  /* KARTICE */
  .food-card{
    background: var(--fv-card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--fv-border);
    border-radius: 16px;
    padding: 14px 14px 12px;
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
    outline: none;
  }
  @media (hover:hover){
    .food-card:hover{
      transform: translateY(-2px);
      box-shadow: 0 8px 24px rgba(105, 178, 84, 0.3);
      border-color: rgba(105, 178, 84, 0.3);
      background: rgba(255, 255, 255, 0.08);
    }
  }
  .food-card:focus-visible{
    border-color: var(--fv-primary);
    box-shadow: 0 0 0 4px rgba(105, 178, 84, 0.3);
  }
  
  /* zaglavlje kartice */
  .food-top{
    display:flex; align-items:baseline; justify-content:space-between; gap: 10px; margin-bottom: 10px;
  }
  .food-name{
    margin:0; font-weight:800; font-size: clamp(1rem, .9rem + .4vw, 1.12rem); line-height:1.2; color: var(--fv-ink);
  }
  .food-kcal{
    font-size:.95rem; padding: 6px 10px; border-radius: 999px;
    border: 1px dashed rgba(105, 178, 84, 0.4);
    background: rgba(105, 178, 84, 0.12);
    color: #7bc463;
    font-weight: 600;
  }
  
  /* makroi – 4→2 kolone */
  .food-macros{
    display:grid; gap: 6px;
    grid-template-columns: repeat(4, minmax(0,1fr));
  }
  @media (max-width: 1200px){
    .food-macros{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  }
  @media (max-width: 639px){
    .food-macros{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  }
  .stat{
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--fv-border);
    border-radius: 12px;
    padding: 6px 8px;
    display:grid; gap:1px;
    min-width: 0;
  }
  .stat-label{ font-size:.78rem; letter-spacing:.02em; color: rgba(255, 255, 255, 0.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stat-value{ font-weight:700; font-size:.9rem; color: var(--fv-ink); white-space: nowrap; }
  
  /* error */
  .foods-error{ margin-top: 12px; color:#ff6b6b; font-weight:700; }
  
  /* ===== RESPONSIVE FINE-TUNING ===== */
  
  /* ≤ 992px (tablet) */
  @media (max-width: 992px){
    .foods-page .foods-card{ border-radius: 16px; }
    .foods-controls .row{ row-gap: .75rem; }
    #fv-clear.btn{ padding: 8px 10px; }
  }
  
  /* ≤ 768px (mali tablet / veliki telefoni) */
  @media (max-width: 768px){
    .foods-page .foods-card{ padding: 14px; }
    #fv-food-search{ height: 50px; }
    .foods-meta{ gap: 10px; }
    .foods-meta #fv-results{ order: 2; width: 100%; }
    .foods-meta .pagination{ order: 1; margin-left: auto; }
  }
  
  /* ≤ 576px (telefoni) */
  @media (max-width: 576px){
    /* search full width */
    #fv-food-search{ width: 100%; margin-bottom: 14px; }
  
    /* sort i clear jedan ispod drugog, ali lepo poređani */
    .foods-controls .d-flex{ flex-wrap: wrap; }
    .foods-controls .d-flex > div{ width: 100%; }
    #fv-clear.btn{ margin-left: auto; }
  
    /* meta ispod – centrirano */
    .foods-meta{ justify-content: center; }
    .foods-meta .pagination{ width: 100%; justify-content: center; }
    #fv-results{ text-align:center; }
  }
  
  /* ≤ 380px – kompaktan mod */
  @media (max-width: 380px){
    .food-card{ padding: 12px; }
    .food-kcal{ font-size:.9rem; padding: 5px 8px; }
    .stat{ padding:7px 8px; }
  }
  
  /* accessibility i glatke animacije */
  @media (prefers-reduced-motion: reduce){
    .food-card{ transition: none; }
  }

  /* ===== LANDSCAPE ORIENTATION OPTIMIZATIONS ===== */

  /* Mobile Landscape - Compact Food Grid */
  @media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
    .foods-page .foods-card {
      padding: clamp(12px, 2.5vw, 20px);
    }

    .foods-head {
      margin-bottom: clamp(6px, 1vw, 10px);
    }

    .foods-title {
      font-size: clamp(1.4rem, 1rem + 1.5vw, 2rem);
      margin: 0 0 .2rem 0;
    }

    .foods-subtitle {
      font-size: clamp(.88rem, .75rem + .4vw, 1rem);
    }

    #fv-food-search {
      height: 44px;
      margin: 0 auto clamp(10px, 1.5vw, 14px);
      padding: 10px 14px 10px 38px;
    }

    .foods-controls .row {
      row-gap: .5rem;
    }

    .foods-controls .form-control,
    .foods-controls .form-select {
      height: 42px;
      padding: 8px 12px;
      font-size: 0.95rem;
    }

    #fv-clear.btn {
      padding: 7px 10px;
      font-size: 0.95rem;
    }

    .foods-meta {
      gap: 10px;
      margin: 6px 0 12px;
    }

    .foods-grid {
      gap: 12px;
      grid-template-columns: repeat(6, 1fr) !important;
    }

    .foods-grid > * {
      grid-column: span 2 !important;
    }

    .food-card {
      padding: 12px 12px 10px;
    }

    .food-name {
      font-size: clamp(.95rem, .85rem + .3vw, 1.05rem);
    }

    .food-kcal {
      font-size: .9rem;
      padding: 5px 9px;
    }

    .food-macros {
      gap: 6px;
    }

    .stat {
      padding: 7px 9px;
    }

    .stat-label {
      font-size: .72rem;
    }

    .stat-value {
      font-size: .9rem;
    }
  }

  /* Tablet Landscape - 4 Column Grid */
  @media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .foods-grid {
      grid-template-columns: repeat(4, 1fr) !important;
    }

    .foods-grid > * {
      grid-column: span 1 !important;
    }
  }

  /* Very Small Phone Landscape - 2 Column Grid */
  @media (max-width: 740px) and (max-height: 420px) and (orientation: landscape) {
    .foods-page .foods-card {
      padding: 10px;
    }

    .foods-title {
      font-size: 1.3rem;
    }

    .foods-subtitle {
      font-size: .85rem;
    }

    #fv-food-search {
      height: 40px;
      margin-bottom: 10px;
      padding: 8px 12px 8px 36px;
      font-size: 0.95rem;
    }

    .foods-controls .form-control,
    .foods-controls .form-select {
      height: 38px;
      padding: 7px 10px;
      font-size: 0.9rem;
    }

    .foods-grid {
      gap: 10px;
      grid-template-columns: repeat(2, 1fr) !important;
    }

    .foods-grid > * {
      grid-column: span 1 !important;
    }

    .food-card {
      padding: 10px;
    }

    .food-top {
      gap: 8px;
      margin-bottom: 8px;
    }

    .food-name {
      font-size: .9rem;
    }

    .food-kcal {
      font-size: .85rem;
      padding: 4px 8px;
    }

    .food-macros {
      gap: 5px;
      grid-template-columns: repeat(2, minmax(0,1fr));
    }

    .stat {
      padding: 6px 8px;
    }

    .stat-label {
      font-size: .7rem;
    }

    .stat-value {
      font-size: .85rem;
    }
  }
  