/* Layouts page specific styles */
.layouts-page {
    padding: 12px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin: 12px auto;
    max-width: 1240px; /* a bit narrower for balance with 3-up grid */
    width: 100%;
    box-sizing: border-box;
}

/* Mobile responsive fixes for search form AND grid layout */
@media screen and (max-width: 768px) {
  /* Force 2-column grid on mobile */
  .layouts-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  
  .search-filter-form {
    flex-direction: row !important;
    gap: 8px !important;
    align-items: flex-end !important;
  }
  
  .search-filter-form .filter-group {
    flex: 0 0 auto !important;
    width: auto !important;
  }
  
  .search-filter-form .search-group {
    flex: 1 1 0 !important;
    min-width: 0 !important;
  }
  
  .search-filter-form .input-with-button {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
  }
  
  .search-filter-form .form-control {
    flex: 1 !important;
    box-sizing: border-box !important;
    padding: 8px 12px !important;
    font-size: 16px !important;
    min-width: 0 !important;
  }
  
  /* Hide the Apply and Search buttons on mobile */
  .search-filter-form .btn {
    display: none !important;
  }
  
  /* Make form submit on change */
  .search-filter-form select,
  .search-filter-form input[type="text"] {
    background: white !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
  }
}

/* Very small screens: fix search form buttons AND ensure 2-column grid */
@media screen and (max-width: 420px) {
  /* Double-ensure 2-column grid on small mobile */
  .layouts-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  
  .search-filter-form .input-with-button { 
    flex-direction: column !important; 
    align-items: stretch !important; 
    gap: 8px !important;
  }
  
  .search-filter-form .input-with-button .form-control { 
    border-radius: 3px !important; 
    margin-bottom: 0 !important;
  }
  
  .search-filter-form .input-with-button .btn { 
    width: 100% !important; 
    margin: 0 !important; 
    border-radius: 3px !important; 
  }
}

/* Ensure the layouts page content uses the full white area */
.simple-container {
    width: 100% !important;
    max-width: 1240px !important;
    margin: 0 auto !important;
    padding: 0 8px !important;
    box-sizing: border-box;
}

/* Header row with title and My Layouts button */
.layouts-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.layouts-page-header h1 { margin: 8px 0; }

/* Refined My Layouts button style */
.my-layouts-btn {
    background: #3B77F6;
    color: #fff;
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid #2f5fc2;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    line-height: 1;
}
.my-layouts-btn:hover { background: #2f69db; }

/* Compact Vista/Aero promo panel */
.vista-aero-section.compact {
    padding: 12px;
    margin-bottom: 12px;
}
.vista-aero-section.compact h2 { font-size: 18px; margin-bottom: 6px; }
.vista-aero-section.compact p { font-size: 13px; margin-bottom: 10px; }
.vista-aero-button.small { padding: 8px 14px; font-size: 14px; }

/* Hide form labels and buttons in the layouts search form (desktop + mobile) */
.search-filter-form .form-label { display: none !important; }
.search-filter-form .btn { display: none !important; }

/* Layout Preview Page Styles */
.layout-preview-container {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.layout-preview-container h1 {
    color: #333;
    margin-bottom: 20px;
    text-align: center;
    font-size: 24px;
}

.layout-image-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    background-color: #f8f8f8;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.layout-preview-image {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border: 1px solid #ddd;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.layout-preview-placeholder {
    width: 100%;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f1f1;
    color: #777;
    font-style: italic;
    border: 1px dashed #ccc;
}

/* ===== Layout Preview Page (layouts/preview.php) ===== */
.back-button-container {
    margin: 8px 0 16px 0;
}

.layout-details-wrapper {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
    align-items: start;
}

.layout-preview-image-container {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.layout-preview-main-img {
    width: 100%;
    height: auto;
    max-height: 78vh;
    object-fit: contain;
    display: block;
    border-radius: 6px;
}

.layout-info-panel {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.layout-title {
    margin: 0 0 8px 0;
    font-size: 20px;
    color: #3B5998;
}

.layout-meta-details p { margin: 4px 0; color: #555; font-size: 14px; }
.layout-description-text { margin-top: 10px; color: #333; line-height: 1.5; }
.layout-actions-preview { margin-top: 12px; display: flex; gap: 8px; }

/* Preview page responsive tweaks */
@media (max-width: 1100px) {
  .layout-details-wrapper {
      grid-template-columns: 1fr;
  }
  .layout-preview-main-img { max-height: 65vh; }
}

@media (max-width: 768px) {
  .layout-preview-image-container { padding: 8px; }
  .layout-info-panel { padding: 12px; }
  .layout-title { font-size: 18px; }
}

.layout-details {
    margin-top: 20px;
}

.layout-description {
    line-height: 1.6;
    color: #555;
    margin-bottom: 20px;
    font-size: 16px;
}

.layout-info {
    background-color: #f8f8f8;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #eee;
    margin-bottom: 20px;
}

.layout-info p {
    margin: 5px 0;
    color: #333;
}

.layout-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

/* Button styles */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 4px;
    font-weight: bold;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    white-space: nowrap;
}

.btn-primary {
    background-color: #3B5998;
    color: white;
    border: 1px solid #29447E;
}

.btn-primary:hover {
    background-color: #29447E;
}

.btn-secondary {
    background-color: #f1f1f1;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #e1e1e1;
}

/* CSS Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    /* GPU acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: opacity;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 80%;
    max-width: 800px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close-modal:hover {
    color: #333;
}

.modal-code {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    padding: 15px;
    height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
    white-space: pre-wrap;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
}

.copy-btn {
    background-color: #3B5998;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
}

.copy-btn:hover {
    background-color: #29447E;
}

/* Responsive for medium screens */
@media (max-width: 1100px) {
    .layouts-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* Responsive styles */
@media (max-width: 768px) {
    .layout-preview-container {
        padding: 15px;
    }
    
    .layout-actions {
        flex-direction: column;
        gap: 5px;
    }
    
    /* Scope button full-width to layout cards only to avoid breaking header */
    .layout-actions .btn {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

.layouts-page h1 {
    color: #333;
    margin-bottom: 20px;
}

.layouts-filters {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.layouts-page .search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.layouts-page .search-form input,
.layouts-page .search-form select {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

.layouts-page .search-form button {
    padding: 6px 8px;
    background: linear-gradient(to bottom, #6D84B4 0%, #3B5998 100%);
    color: white;
    border: 1px solid #29447E;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
}

.layouts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Start with 2 columns for mobile-first */
    gap: 16px;
    margin-bottom: 24px;
    padding: 0;
}

/* Desktop: 3 columns */
@media (min-width: 1101px) {
    .layouts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Ensure each grid child fills its cell */
.layouts-grid > a,
.layouts-grid > .layout-card-link {
    display: block;
    width: 100%;
}

.layout-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    background-color: white;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    /* GPU acceleration for smooth hover */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform, box-shadow;
    height: 100%;
}

.layout-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.layout-card.featured {
    border: 2px solid #F6E36D;
    box-shadow: 0 0 5px rgba(246,227,109,0.5);
}

.layout-preview {
    height: 180px; /* uniform preview height for consistent card sizes */
    position: relative;
    background-color: #f0f0f0;
    display: block;
    overflow: hidden;
}

.layout-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Fill thumbnail */
    object-position: center;
    display: block;
}

/* Filter/search bar — single row, full width */
.search-filter-section {
    margin: 0 0 12px 0;
}

.search-filter-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: nowrap; /* keep on one line at typical widths */
}

.search-filter-form .filter-group,
.search-filter-form .search-group {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    min-width: 0;  /* allow children to shrink */
}
/* Keep Category area compact, let Search consume remaining space */
.search-filter-form .filter-group { flex: 0 0 auto; }
.search-filter-form .search-group { flex: 1 1 0; min-width: 0; }

.layouts-page .search-filter-form .form-label { margin: 0 6px 0 0; font-size: 12px; color: #444; display: inline-block; white-space: nowrap; }
.layouts-page .search-filter-form .select-field { min-width: 0; height: 34px; width: auto; max-width: 110px; }
.layouts-page .search-filter-form .text-input { min-width: 120px; height: 34px; width: 100%; flex: 1; }
.layouts-page .search-filter-form .btn { height: 34px; padding: 0 12px; line-height: 34px; }

/* Keep input + button on the same line inside grouped controls */
.layouts-page .search-filter-form .input-with-button {
    display: inline-flex;
    align-items: center;
    width: 100%;
    white-space: nowrap; /* keep input + button on one line */
}
/* Category (filter-group) should only be as wide as needed */
.layouts-page .search-filter-form .filter-group .input-with-button { width: auto; }
.layouts-page .search-filter-form .search-group .input-with-button { width: 100%; }
.layouts-page .search-filter-form .input-with-button .form-control {
    flex: 1 1 auto;
    min-width: 0;
}
.layouts-page .search-filter-form .input-with-button .btn {
    flex: 0 0 auto;
    margin-left: 6px;
}

/* Small phones: keep single row, hide labels, tighten spacing */
@media (max-width: 600px) {
  .layouts-page .search-filter-form { gap: 4px; flex-wrap: nowrap; align-items: center; }
  .layouts-page .search-filter-form label.form-label { display: none !important; }
  .layouts-page .search-filter-form .filter-group { flex: 0 0 auto; }
  .layouts-page .search-filter-form .search-group { flex: 1 1 0; min-width: 0; }
  .layouts-page .search-filter-form .select-field { max-width: 110px; height: 32px; font-size: 12px; }
  .layouts-page .search-filter-form .text-input { min-width: 80px; height: 32px; font-size: 12px; }
  .layouts-page .search-filter-form .btn { padding: 0 8px; font-size: 12px; height: 30px; line-height: 30px; }
  .layouts-page .search-filter-form .input-with-button { width: 100%; min-width: 0; }
}

/* Extreme tiny widths: stack as a last resort */
@media (max-width: 360px) {
  .layouts-page .search-filter-form { flex-direction: column; align-items: stretch; }
  .layouts-page .search-filter-form .filter-group,
  .layouts-page .search-filter-form .search-group { width: 100%; }
}

/* FriendRewind Classic Style */

/* My Layouts Button */
.my-layouts-wrapper {
    margin-bottom: 15px;
}

.my-layouts-btn {
    display: inline-block;
    background: #5B74A8;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: bold;
    font-size: 14px;
    border: 1px solid #4964A0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.my-layouts-btn:hover {
    background: #3B5998;
}

/* Search and Filter Container */
.layouts-filters {
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    overflow: visible;
    padding: 0;
}

/* Search Form */
.search-form {
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

.layouts-page .search-row {
    display: flex;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
}

.layouts-page .search-row input[type="text"] {
    flex: 1;
    border: 1px solid #BDC7D8;
    padding: 5px 8px;
    border-radius: 3px;
    font-size: 13px;
    height: 30px;
    box-sizing: border-box;
}

.layouts-page .search-btn {
    background: #5B74A8;
    color: white;
    border: none;
    padding: 0 15px;
    margin-left: 5px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    height: 30px;
}

/* Filter Row */
.layouts-page .filter-row {
    display: flex;
    margin-top: 10px;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* New Search Form Styles */
.layouts-page .search-container {
    max-width: 800px;
    margin: 0 auto 20px;
    padding: 0 15px;
    box-sizing: border-box;
}

.layouts-page .search-form {
    width: 100%;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.form-group {
    width: 100%;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
    font-size: 13px;
}

.form-row {
    display: flex;
    width: 100%;
    gap: 8px;
    align-items: center;
}

.form-select,
.form-input {
    flex: 1 1 auto;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid #BDC7D8;
    border-radius: 3px;
    font-size: 13px;
    box-sizing: border-box;
    height: 38px;
}

.form-button {
    flex: 0 0 auto;
    padding: 0 16px;
    height: 38px;
    border: none;
    border-radius: 3px;
    background: #f0f0f0;
    color: #333;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
}

.form-button.primary {
    background: #5B74A8;
    color: white;
}

/* Search */
.layouts-page .search-row { display: flex; margin: 10px 0; max-width: 400px; }
.layouts-page .search-row input[type="text"] { 
    flex: 1; 
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #BDC7D8;
    border-right: 0;
    border-radius: 3px 0 0 3px;
    font-size: 13px;
}
.layouts-page .search-row button {
    padding: 0 15px;
    background: #5B74A8;
    color: white;
    border: 0;
    border-radius: 0 3px 3px 0;
}

.form-button:hover {
    opacity: 0.9;
}

/* Mobile layout */
@media screen and (max-width: 768px) {
    .layouts-page .search-container {
        padding: 0 10px;
    }
    
    .form-section {
        gap: 15px;
    }
    
    .layouts-page .form-row {
        flex-direction: column;
        gap: 8px;
    }
    
    .layouts-page .form-select,
    .layouts-page .form-input,
    .layouts-page .form-button {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    .layouts-page .form-button {
        margin-top: 5px !important;
    }
}

/* Small screen reordering */
@media screen and (max-width: 518px) {
    .layouts-page .search-row {
        order: 2;
        margin-top: 15px;
    }
    
    .layouts-page .filter-row {
        order: 1;
    }
}

/* Already defined above */

.filter-label {
    font-size: 13px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.category-select {
    width: 100%;
    border: 1px solid #BDC7D8;
    padding: 5px 8px;
    border-radius: 3px;
    font-size: 13px;
    height: 30px;
    background-color: white;
}

.apply-filters-btn {
    background: #5B74A8;
    color: white;
    border: none;
    padding: 0 10px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    height: 30px;
    width: auto;
    min-width: 100px;
    white-space: nowrap;
    text-align: center;
}

/* Mobile Responsive Styles */
@media screen and (max-width: 768px) {
    /* Global fixes */
    body, html {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .simple-container {
        width: 100%;
        max-width: 100%;
        padding: 5px;  /* Reduced padding for more space */
        margin: 0;
        box-sizing: border-box;
        overflow-x: visible;
    }
    
    h1 {
        font-size: 20px;
        text-align: center;
        margin-bottom: 15px;
    }
    
    .my-layouts-wrapper {
        text-align: center;
        margin-bottom: 15px;
    }
    
    .my-layouts-btn {
        display: inline-block;
        width: 80%;
        text-align: center;
    }
    
    /* Search form mobile styles */
    .layouts-filters {
        padding: 0;
        overflow: visible;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }
    
    .search-row {
        flex-direction: column;
        margin-bottom: 15px;
    }
    
    /* Edit button */
    .edit-layouts-btn {
        width: 100%;
        padding: 12px 16px;
        height: auto;
        margin: 0;
        text-align: center;
        font-size: 16px;
        font-weight: bold;
        box-sizing: border-box;
    }
    .layouts-page {
        padding: 8px;
        margin: 0;
        border-radius: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .simple-container {
        padding: 0 8px;
    }
    
    .layouts-filters {
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-bottom: 15px;
        width: 100%;
    }
    
    .layouts-page .search-form {
        width: 100%;
        max-width: 100%;
        margin: 0 0 15px 0;
        background: #f7faff;
        border-radius: 8px;
        padding: 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        box-sizing: border-box;
    }
    
    .layouts-page .search-form .form-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .layouts-page .search-form input[type="text"],
    .layouts-page .search-form select {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
        height: 48px;
        box-sizing: border-box;
        border: 1px solid #bcd;
        border-radius: 6px;
        background: white;
    }

    /* Keep filter/search buttons compact to avoid edge-to-edge buttons */
    .layouts-page .search-form button,
    .layouts-page .search-filter-form .btn {
        width: auto;
        padding: 10px 14px;
        font-size: 15px;
        height: 40px;
        border-radius: 6px;
        margin-top: 0;
    }
    
    .layouts-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; /* Keep 2 columns on mobile */
        gap: 10px;
        width: 100%;
        padding: 0;
    }
    /* Make anchor wrappers fill the grid row so inner card's height:100% works */
    .layouts-grid > a,
    .layouts-grid > .layout-card-link {
        height: 100% !important;
        display: block;
    }
    
    .layout-card {
        margin: 0;
        border-radius: 8px;
        overflow: hidden;
        background: white;
        border: 1px solid #e0e0e0;
        transition: transform 0.2s, box-shadow 0.2s;
        width: 100%;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        height: 100%; /* stretch to grid row height */
    }
    
    .layout-card:active {
        transform: scale(0.98);
    }
    
    .layout-preview {
        background: #f8f8f8;
        position: relative;
        overflow: hidden;
        flex: 1 1 auto; /* grow to fill leftover height */
        min-height: 90px; /* maintain a reasonable minimum */
        height: auto; /* allow it to expand */
    }
    
    .layout-preview img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s ease;
        display: block;
    }
    
    .layout-card:hover .layout-preview img {
        transform: scale(1.03);
    }
    
    .layout-info {
        padding: 10px 8px;
        margin-top: auto; /* push info panel to the bottom of the card */
    }
    
    .layout-info h3 {
        font-size: 13px;
        margin: 0 0 4px 0;
        color: #333;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .layout-meta {
        font-size: 11px;
        color: #666;
        display: flex;
        justify-content: space-between;
    }
    
    .layout-actions {
        padding: 0 8px 8px;
        display: flex;
        flex-direction: row;
        gap: 6px;
        flex-wrap: wrap;
    }
    
    /* Scope card action buttons only */
    .layout-actions .btn {
        flex: 1 1 45%;
        min-width: 0;
        padding: 10px 6px;
        font-size: 13px;
        border-radius: 4px;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
        margin: 2px;
    }
    
    .btn-primary {
        background: #3B5998;
        color: white;
    }
    
    .btn-secondary {
        background: #f0f0f0;
        color: #333;
        border: 1px solid #ddd;
    }
    
    .pagination {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 4px;
        margin: 20px 0;
        padding: 0 8px;
    }
    
    .pagination a, 
    .pagination span {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 6px 10px;
        min-width: 36px;
        height: 36px;
        font-size: 13px;
        background: white;
        border: 1px solid #ddd;
        border-radius: 4px;
        text-decoration: none;
        color: #3B5998;
    }
    
    .pagination .current {
        background: #3B5998;
        color: white;
        border-color: #3B5998;
    }
    
    .pagination a:hover {
        background: #f5f5f5;
    }
}

.featured-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #F6E36D;
    color: #333;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.layout-info {
    padding: 10px;
}

/* Layouts index cards: remove extra bottom space coming from global .layout-info margin */
.layouts-grid .layout-info,
.layout-card .layout-info {
    margin-bottom: 0 !important;
    background: transparent;
    border: 0;
}

.layout-info h3 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #3B5998;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.layout-meta,
.layout-author {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    line-height: 1.4;
}

.layout-meta {
    display: flex;
    justify-content: space-between;
}

.layout-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    padding: 0 10px 10px;
}

.preview-btn,
.apply-btn {
    padding: 6px 10px;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    flex: 1;
    font-weight: bold;
}

.preview-btn {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.preview-btn:hover {
    background-color: #e5e5e5;
}

.apply-btn {
    background: linear-gradient(to bottom, #6D84B4 0%, #3B5998 100%);
    color: white;
    border: 1px solid #29447E;
}

.apply-btn:hover {
    background: linear-gradient(to bottom, #5D74A4 0%, #2A4888 100%);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.page-link {
    padding: 4px 8px;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #3B5998;
    border-radius: 3px;
    font-size: 13px;
}

.page-link.current {
    background-color: #3B5998;
    color: white;
    border-color: #29447E;
}

.layout-upload-section {
    margin-top: 20px;
    padding: 15px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-align: center;
}

.create-layout-btn {
    display: inline-block;
    padding: 6px 12px;
    background: linear-gradient(to bottom, #6D84B4 0%, #3B5998 100%);
    color: white;
    text-decoration: none;
    border-radius: 3px;
    border: 1px solid #29447E;
    font-weight: bold;
}

.create-layout-btn:hover {
    background: linear-gradient(to bottom, #5D74A4 0%, #2A4888 100%);
}

.no-results {
    padding: 20px;
    text-align: center;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 3px;
    color: #666;
}

/* Small screen styles - Reorder form elements */
@media screen and (max-width: 518px) {
    .layouts-page .search-row {
        order: 2;
        margin-top: 15px;
    }
    
    .layouts-page .filter-row {
        order: 1;
    }
}

/* Final tiny-device overrides for layouts page */
@media screen and (max-width: 420px) {
  .layouts-page .layouts-grid { 
    grid-template-columns: repeat(2, 1fr) !important; /* Keep 2 columns even on very small screens */
    gap: 8px;
  }
  .layouts-page .layout-preview { height: 80px; }
  .layouts-page .search-filter-form .input-with-button { flex-direction: column; align-items: stretch; }
  .layouts-page .search-filter-form .input-with-button .btn { width: 100%; margin-top: 6px; }
}
