/**
 * Shared Location Item Styles
 * Common styles for location item display across different contexts
 *
 * @package  WP_Company_Manager
 * @category Styles
 * @author   WebFX <support@webfx.com>
 * @license  GPL-2.0+ https://www.gnu.org/licenses/gpl-2.0.txt
 * @link     https://www.webfx.com
 */

/* Base Location Item Styles */
.wpcm-location-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
    position: relative;
}

.wpcm-location-item:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wpcm-location-item.selected {
    background: #e3f2fd;
    border-left: 4px solid #1976d2;
}

/* Header Section */
.wpcm-location-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    gap: 10px;
}

.wpcm-location-item-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
    line-height: 1.3;
}

.wpcm-location-distance {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Details Section */
.wpcm-location-item-details {
    margin-bottom: 15px;
}

.wpcm-location-item-details p {
    margin: 8px 0;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wpcm-location-address {
    font-weight: 500;
    color: #333 !important;
}

.wpcm-location-phone a,
.wpcm-location-email a {
    color: #1976d2;
    text-decoration: none;
}

.wpcm-location-phone a:hover,
.wpcm-location-email a:hover {
    text-decoration: underline;
}

/* Actions Section */
.wpcm-location-item-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.wpcm-go-to-page-btn,
.wpcm-directions-btn {
    padding: 0;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    display: inline-block;
    border: none;
    cursor: pointer;
}

.wpcm-go-to-page-btn {
    color: #bb242c;
    leading-trim: both;
    text-edge: cap;
    font-family: Montserrat;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 26px;
    text-decoration: underline;
}

.gm-style-iw-chr {
    display: none;
}

.gm-style .gm-style-iw-d {
    padding: 10px 8px 0;
}

a.wpcm-go-to-page-btn .fas.fa-chevron-right {
    font-size: 78%;
}

.wpcm-go-to-page-btn:hover {
    /* background: #a01e25; */
    color: #a01e25;
    text-decoration: none;
    opacity: 0.6;
}

.wpcm-directions-btn {
    background: #1976d2;
    color: white;
}

.wpcm-directions-btn:hover {
    background: #1565c0;
    color: white;
    text-decoration: none;
}

/* Layout Variants */

/* Card Layout (Default) */
.wpcm-location-item--card {
    /* Default styles already applied */
}

/* List Layout */
.wpcm-location-item--list {
    border-left: none;
    border-right: none;
    border-radius: 0;
    border-top: 1px solid #e0e0e0;
    margin-bottom: 0;
    padding: 15px 0;
}

.wpcm-location-item--list:first-child {
    border-top: none;
}

/* Compact Layout */
.wpcm-location-item--compact {
    padding: 15px;
    margin-bottom: 10px;
}

.wpcm-location-item--compact .wpcm-location-item-title {
    font-size: 1rem;
}

.wpcm-location-item--compact .wpcm-location-item-details p {
    font-size: 0.85rem;
    margin: 5px 0;
}

.wpcm-location-item--compact .wpcm-go-to-page-btn,
.wpcm-location-item--compact .wpcm-directions-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Context-Specific Styles */

/* Grid Layout Context */
.wpcm-location-grid .wpcm-location-item {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.wpcm-location-grid .wpcm-location-item-details {
    flex: 1;
}

.wpcm-location-grid .wpcm-location-item-actions {
    margin-top: auto;
}

/* Sidebar Context - Enhanced for better UX */
.wpcm-location-sidebar .wpcm-location-item {
    border-left: none;
    border-right: none;
    border-radius: 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 0;
    padding: 20px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
}

.wpcm-location-sidebar .wpcm-location-item:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateX(5px);
}

.wpcm-location-sidebar .wpcm-location-item.selected {
    background: #e3f2fd;
    border-left: 4px solid #1976d2;
    transform: translateX(0);
}

.wpcm-location-sidebar .wpcm-location-item:first-child {
    border-top: 1px solid #e0e0e0;
}

/* Location Accordion Styles */
.wpcm-locations-accordion {
    border: none;
}

.wpcm-location-accordion-item {
    border: none;
    border-bottom: none;
    background: #fff;
    margin-bottom: 20px;
    border-radius: 10px;
}

.wpcm-location-accordion-item:first-child {
    border-top: none;
}

.wpcm-location-header {
    padding: 11px 16px;
    background: #fff;
    border: none;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    border-radius: 10px;
}

.wpcm-location-header:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wpcm-location-header[aria-expanded="true"] {
    background: #bb242c;
    color: #fff;
    font-weight: bold;
}

.wpcm-location-header[aria-expanded="true"] .wpcm-location-title {
    color: #fff;
    font-weight: bold;
}

.wpcm-location-header[aria-expanded="true"] .wpcm-accordion-toggle-icon {
    color: #fff;
}

.wpcm-location-header-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    pointer-events: none; /* Prevent child elements from interfering with header clicks */
}

.wpcm-location-header-content * {
    pointer-events: none; /* Ensure all child elements don't block header clicks */
}

.wpcm-location-title-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.wpcm-location-title {
    margin: 0;
    font-family: Montserrat;
    font-size: 16px;
    font-style: normal;
    font-weight: 400;
    line-height: 26px;
    color: #2c3e50;
    flex: 1;
}

.wpcm-distance-badge {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.wpcm-location-address-preview {
    margin: 0;
    font-size: 0.9rem;
    color: #404040;
    display: flex;
    align-items: center;
    font-size: 16px;
    gap: 8px;
    margin-bottom: 0 !important;
}

.wpcm-location-address-preview .fas {
    color: #1976d2;
    width: 16px;
    text-align: center;
}

.wpcm-accordion-toggle-icon {
    position: absolute;
    right: 0;
    top: 44%;
    transform: translateY(-50%);
    color: #666;
    transition: transform 0.3s ease;
    font-size: 125%;
}

.wpcm-location-header[aria-expanded="true"] .wpcm-accordion-toggle-icon {
    transform: translateY(-50%) rotate(180deg);
}

.wpcm-location-collapse {
    border-top: none;
    overflow: hidden;
}

.wpcm-location-content {
    padding: 10px 15px;
    background: #fafafa;
}

.wpcm-location-detail {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 16px;
}

.wpcm-location-detail .fas {
    color: #1976d2;
    width: 20px;
    text-align: center;
}

.wpcm-detail-label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 60px;
}

.wpcm-detail-value {
    color: #404040;
    text-decoration: none;
}

.wpcm-detail-value:hover {
    text-decoration: underline;
}

.wpcm-location-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.wpcm-action-btn {
    padding: 2px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    font-family: Montserrat;
    font-size: 14px;
    font-style: normal;
    font-weight: 600;
    line-height: 30px; /* 185.714% */
    text-transform: uppercase;
}

.wpcm-details-btn {
    background: #22366f;
    color: white;
}

.wpcm-details-btn:hover {
    background: #a01e25;
    color: white;
    text-decoration: none;
}

.wpcm-directions-btn {
    background: #1976d2;
    color: white;
}

.wpcm-directions-btn:hover {
    background: #1565c0;
    color: white;
    text-decoration: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wpcm-location-sidebar .wpcm-location-item {
        padding: 15px 10px;
    }

    .wpcm-location-sidebar .wpcm-location-item:hover {
        transform: none;
    }

    .wpcm-location-item-actions {
        flex-direction: column;
        gap: 8px;
    }

    .wpcm-go-to-page-btn,
    .wpcm-directions-btn {
        text-align: center;
        justify-content: center;
    }
}

/* Icon Styles */
.wpcm-location-item-details .fas {
    color: #666;
    width: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Animation for Interaction */
.wpcm-location-item[data-location-id]:hover {
    transform: translateY(-1px);
}

.wpcm-location-item.loading {
    opacity: 0.7;
    pointer-events: none;
}

.wpcm-location-item.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ccc;
    border-top: 2px solid #1976d2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
