/* MoleCatalog Styles */

/* Global box-sizing for consistent widths */
.molecatalog-catalog,
.molecatalog-controls,
.molecatalog-pagination,
.molecatalog-modal-content,
.molecatalog-catalog *,
.molecatalog-controls *,
.molecatalog-pagination *,
.molecatalog-modal-content * {
    box-sizing: border-box;
}

/* Global cursor fix - this is important */
html body.wp-admin *:not(input):not(textarea):not(select):not(button):not(a):not([contenteditable="true"]),
html body *:not(input):not(textarea):not(select):not(button):not(a):not([contenteditable="true"]) {
    cursor: default !important;
    user-select: none !important; /* Prevent text selection */
    -webkit-user-select: none !important; /* Safari */
    -moz-user-select: none !important; /* Firefox */
    -ms-user-select: none !important; /* IE/Edge */
}

/* Only allow text selection on inputs and elements that need it */
html body input[type="text"],
html body input[type="search"],
html body input[type="email"],
html body input[type="password"],
html body input[type="url"],
html body input[type="tel"],
html body input[type="number"],
html body textarea,
html body [contenteditable="true"] {
    cursor: text !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

/* Make clickable elements show the pointer cursor */
html body a,
html body button,
html body input[type="submit"],
html body input[type="button"],
html body input[type="reset"],
html body input[type="checkbox"],
html body input[type="radio"],
html body select,
html body label[for],
html body .button,
html body .wp-core-ui .button,
html body .wp-core-ui .button-primary,
html body .wp-core-ui .button-secondary,
html body .molecatalog-catalog-item,
html body .molecatalog-modal-close {
    cursor: pointer !important;
}

/* Fix cursor display issues - prevent cursor from appearing where it shouldn't */
.molecatalog-catalog,
.molecatalog-catalog *:not(input):not(textarea):not(select):not(button):not(a):not([contenteditable="true"]),
.molecatalog-modal-content *:not(input):not(textarea):not(select):not(button):not(a):not(.molecatalog-beer-details p):not([contenteditable="true"]),
body.settings_page_molecatalog-settings *:not(input):not(textarea):not(select):not(button):not(a):not(pre):not(code):not([contenteditable="true"]) {
    cursor: default;
    user-select: none; /* Prevent text selection */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
}

.molecatalog-catalog a,
.molecatalog-catalog button,
.molecatalog-search-button,
.molecatalog-clear-search,
.molecatalog-filter-submit,
.molecatalog-filter-clear,
.molecatalog-view-details,
.molecatalog-page-link,
.molecatalog-modal-close {
    cursor: pointer;
}

.molecatalog-catalog {
    margin: 20px auto;
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
}

/* Combined Controls Container */
.molecatalog-controls {
    background: #f9f9f9;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    overflow: hidden;
    margin: 0 auto 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
}

/* Search Form */
.molecatalog-search {
    margin: 0;
    padding: 20px;
    background: #fff;
    border-bottom: 1px solid #e1e1e1;
}

.molecatalog-search:last-child {
    border-bottom: none;
}

.molecatalog-search-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.molecatalog-search input[type="search"] {
    flex: 1;
    min-width: 250px;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.molecatalog-search input[type="search"]:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.molecatalog-search button,
.molecatalog-search-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #0073aa, #005a87);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.molecatalog-search button:hover,
.molecatalog-search-button:hover {
    background: linear-gradient(135deg, #005a87, #004165);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 115, 170, 0.3);
}

.molecatalog-clear-search {
    color: #666;
    text-decoration: none;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.molecatalog-clear-search:hover {
    background: #f5f5f5;
    border-color: #999;
    text-decoration: none;
}

/* Filter Form Styles */
.molecatalog-filters {
    margin: 0;
    padding: 20px;
    background: #f9f9f9;
}

.molecatalog-filter-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.molecatalog-filter-row {
    display: flex;
    gap: 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.molecatalog-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
}

.molecatalog-filter-group label {
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.molecatalog-filter-group input,
.molecatalog-filter-group select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

.molecatalog-filter-group input:focus,
.molecatalog-filter-group select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 3px rgba(0, 115, 170, 0.3);
}

.molecatalog-filter-group span {
    align-self: center;
    color: #666;
    font-size: 12px;
    margin: 0 5px;
}

.molecatalog-filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid #e1e1e1;
}

.molecatalog-filter-submit {
    padding: 12px 24px;
    background: linear-gradient(135deg, #28a745, #1e7e34);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.molecatalog-filter-submit:hover {
    background: linear-gradient(135deg, #1e7e34, #155724);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.molecatalog-filter-clear {
    color: #666;
    text-decoration: none;
    padding: 10px 20px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.molecatalog-filter-clear:hover {
    background: #f5f5f5;
    border-color: #999;
    text-decoration: none;
}

/* Loading States */
.molecatalog-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
    background: #f9f9f9;
    border-radius: 6px;
    margin: 20px 0;
    position: relative;
}

.molecatalog-loading::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e3e3e3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.molecatalog-grid {
    transition: opacity 0.3s ease;
}

/* Responsive filter layout */
@media (max-width: 768px) {
    .molecatalog-filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .molecatalog-filter-group {
        min-width: auto;
    }
    
    .molecatalog-filter-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .molecatalog-filter-submit,
    .molecatalog-filter-clear {
        text-align: center;
    }
}

/* Debug Mode Styles */
.molecatalog-debug-banner {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    padding: 12px 20px;
    margin-bottom: 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    border-left: 4px solid #e65100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.molecatalog-debug-banner::before {
    content: "🚧";
    font-size: 16px;
}

.molecatalog-debug {
    border: 2px dashed #ff9800;
    border-radius: 8px;
    padding: 20px;
    position: relative;
}

.molecatalog-debug::before {
    content: "DEBUG MODE";
    position: absolute;
    top: -10px;
    right: 20px;
    background: #ff9800;
    color: white;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 4px;
    letter-spacing: 1px;
}

/* Debug mode catalog items have special styling */
.molecatalog-debug .molecatalog-catalog-item {
    border: 1px solid #ff9800;
    border-radius: 4px;
}

.molecatalog-debug .molecatalog-catalog-item:hover {
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.2);
}

.molecatalog-clear-search:hover {
    color: #000;
}

/* Grid Layout */
.molecatalog-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

.molecatalog-grid-1 {
    grid-template-columns: 1fr;
}

.molecatalog-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.molecatalog-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.molecatalog-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive grid */
@media (max-width: 768px) {
    .molecatalog-grid-2,
    .molecatalog-grid-3,
    .molecatalog-grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .molecatalog-grid-3,
    .molecatalog-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Catalog Item */
.molecatalog-catalog-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
    overflow: hidden;
    cursor: pointer !important;
    position: relative;
}

.molecatalog-catalog-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-3px);
    border-color: #0073aa;
}

.molecatalog-item-image {
    margin-bottom: 15px;
    text-align: center;
}

.molecatalog-item-image img {
    max-width: 100%;
    height: 200px;
    object-fit: contain;
    border-radius: 5px;
}

/* Style for placeholder image in catalog */
.molecatalog-item-image .molecatalog-placeholder-image {
    max-height: 180px;
    width: auto;
    margin: 10px auto;
    display: block;
}

.molecatalog-item-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.molecatalog-item-title {
    font-size: 18px;
    font-weight: bold;
    margin: 0 0 8px 0;
    color: #333;
}

.molecatalog-item-brewery {
    color: #666;
    margin: 0 0 8px 0;
    font-style: italic;
}

.molecatalog-item-price {
    font-weight: bold;
    color: #0073aa;
    margin: 0 0 15px 0;
    font-size: 16px;
}

.molecatalog-view-details {
    display: inline-block;
    padding: 10px 20px;
    background: #0073aa;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.molecatalog-view-details:hover {
    background: #005a87;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Single Beer Display */
.molecatalog-single {
    max-width: 800px;
    margin: 20px auto;
    padding: 30px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.molecatalog-beer-title {
    font-size: 28px;
    margin: 0 0 20px 0;
    color: #333;
    text-align: center;
}

.molecatalog-beer-image {
    text-align: center;
    margin-bottom: 25px;
}

.molecatalog-beer-image img {
    max-width: 100px;
    height: auto;
}

.molecatalog-placeholder-image {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    padding: 5px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-style: italic;
    margin: 0 auto;
}

.molecatalog-beer-details p {
    margin: 0 0 12px 0;
    font-size: 16px;
    line-height: 1.5;
}

.molecatalog-beer-details strong {
    color: #333;
    display: inline-block;
    min-width: 100px;
}

/* Pagination */
.molecatalog-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px auto;
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    background: #f9f9f9;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
}

/* Prevent nested pagination containers */
.molecatalog-pagination .molecatalog-pagination {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
    width: 100%;
}

/* Page info styling */
.molecatalog-page-info {
    font-size: 16px;
    color: #555;
    font-weight: 500;
    text-align: center;
    margin: 0 30px;
    min-width: 200px;
}

.molecatalog-items-info {
    font-size: 14px;
    color: #777;
    display: block;
    margin-top: 5px;
}

/* Number pagination styling */
.molecatalog-page-link,
.molecatalog-page-current {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 2px;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
    color: #0073aa;
    min-width: 40px;
    text-align: center;
}

.molecatalog-page-current {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
    font-weight: 600;
}

.molecatalog-page-link:hover {
    background: #f0f0f0;
    color: #005a87;
    text-decoration: none;
}

/* Previous/Next button styling */
.molecatalog-page-nav {
    display: inline-block;
    padding: 10px 20px;
    text-decoration: none;
    font-weight: 600;
    border: 1px solid #0073aa;
    border-radius: 5px;
    background: #0073aa;
    color: white;
    transition: all 0.3s ease;
    min-width: 120px;
    text-align: center;
    flex: 0 0 auto;
    margin: 0 15px;
}

.molecatalog-page-nav:hover {
    background: #005a87;
    border-color: #005a87;
    color: white;
    text-decoration: none;
}

.molecatalog-page-nav.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
    background: #f0f0f0;
    border-color: #ddd;
    color: #999;
}

/* Removed duplicate molecatalog-page-info styling */

/* Error and No Results */
.molecatalog-error,
.molecatalog-no-results {
    text-align: center;
    padding: 40px 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    color: #666;
    font-style: italic;
}

.molecatalog-error {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

/* Loading state styling moved to combine with existing definition */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Styles */
.molecatalog-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.molecatalog-modal-content {
    position: relative;
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.molecatalog-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #999;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer !important;
    line-height: 1;
    transition: color 0.2s ease;
}

.molecatalog-modal-close:hover,
.molecatalog-modal-close:focus {
    color: #333;
    text-decoration: none;
}

.molecatalog-beer-details {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
}

.molecatalog-beer-details .molecatalog-beer-title {
    width: 100%;
    margin: 0 0 20px 0;
    color: #333;
    font-size: 28px;
    line-height: 1.3;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 15px;
}

.molecatalog-beer-details .molecatalog-beer-image {
    flex: 0 0 250px;
    margin-bottom: 20px;
}

.molecatalog-beer-details .molecatalog-beer-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.molecatalog-beer-details .molecatalog-beer-info {
    flex: 1;
    min-width: 250px;
}

.molecatalog-beer-details .molecatalog-beer-info p {
    margin: 0 0 12px;
    line-height: 1.6;
}

.molecatalog-beer-details .molecatalog-beer-info .molecatalog-beer-brewery {
    font-size: 18px;
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
}

.molecatalog-beer-details .molecatalog-beer-info .molecatalog-beer-type {
    font-size: 16px;
    background: #f0f0f0;
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.molecatalog-beer-details .molecatalog-beer-info .molecatalog-beer-price {
    font-size: 20px;
    color: #0073aa;
    font-weight: bold;
    margin-top: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Placeholder image in beer details modal */
.molecatalog-beer-details .molecatalog-placeholder-image {
    max-height: 300px;
    max-width: 150px;
    margin: 0 auto;
    display: block;
    padding: 10px;
}

.molecatalog-beer-modal-content .molecatalog-beer-details {
    overflow: hidden;
}

.molecatalog-beer-modal-content .molecatalog-beer-details p {
    margin: 0 0 12px 0;
    font-size: 16px;
    line-height: 1.5;
}

.molecatalog-beer-modal-content .molecatalog-beer-details strong {
    color: #2c3e50;
    font-weight: 600;
    display: inline-block;
    min-width: 80px;
}

/* Responsive modal */
@media (max-width: 768px) {
    .molecatalog-modal-content {
        margin: 10px;
        width: calc(100% - 20px);
        padding: 20px;
    }
    
    .molecatalog-beer-modal-content .molecatalog-beer-image {
        float: none;
        margin: 0 auto 20px auto;
        display: block;
        text-align: center;
    }
    
    .molecatalog-beer-modal-content .molecatalog-beer-title {
        margin-right: 0;
        font-size: 24px;
        text-align: center;
    }
}
