@tailwind base;
@tailwind components;
@tailwind utilities;

/* Block Editor Preview Styles */
.wpuf-user-directory-block-preview {
    .wpuf-block-preview {
        border-radius: 8px;
        overflow: hidden;

        &:not([style*="cursor: default"]):hover {
            border-color: #007cba !important;
            box-shadow: 0 0 0 1px rgba(0, 124, 186, 0.2);
        }

        .wpuf-preview-label {
            background: #f0f0f0;
            padding: 8px 16px;
            margin: -20px -20px 20px -20px;
            font-weight: 500;
            border-bottom: 1px solid #ddd;
        }

        .wpuf-ud-table {
            font-size: 14px;

            th, td {
                border: 1px solid #e5e7eb;
            }

            th {
                background-color: #f9fafb !important;
                font-weight: 600;
            }

            td {
                background-color: white;
            }
        }

        .wpuf-search-field input {
            border: 1px solid #d1d5db;
            border-radius: 6px;
            font-size: 14px;
        }

        .wpuf-btn-primary {
            font-size: 12px;
            font-weight: 500;
            text-decoration: none;

            &:hover {
                background-color: #2563eb !important;
            }
        }

        .wpuf-ud-pagination {
            button, span {
                font-size: 14px;
                border-radius: 6px;
                font-weight: 500;
            }

            button:hover:not(:disabled) {
                background-color: #f3f4f6;
            }
        }
    }
}

.wpuf-profile-button a {
    text-decoration: none;
}

/* Base styles that complement Tailwind classes */
.wpuf-user-directory-item-content {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

/* No Users Found Message Styles */
.wpuf-user-directory-no-users {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 8px;
    margin: 1rem 0;
}

.wpuf-user-directory-no-users .wpuf-text-gray-500 {
    color: #6b7280;
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.wpuf-user-directory-no-users .wpuf-text-gray-400 {
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Table-specific no users message */
.wpuf-user-directory-no-users td {
    text-align: center;
    padding: 2rem 1rem;
}

/* Grid-specific no users message */
.wpuf-user-directory-no-users.wpuf-col-span-full {
    grid-column: 1 / -1;
    margin: 1rem 0;
}

/* Pattern Selection Styles - Only for editor */
.wpuf-directory-pattern-selection {
    padding: 2rem;
    background: #f9fafb;
    border-radius: 12px;
    border: 2px dashed #d1d5db;
}

.wpuf-pattern-selection-header {
    text-align: center;
    margin-bottom: 2rem;
}

.wpuf-pattern-selection-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.wpuf-pattern-selection-header p {
    color: #6b7280;
    font-size: 1rem;
}

.wpuf-pattern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.wpuf-pattern-item {
    background: white;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.wpuf-pattern-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.wpuf-pattern-item:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-color: #3b82f6;
}

.wpuf-pattern-preview {
    margin-bottom: 1rem;
}

.wpuf-pattern-thumbnail {
    height: 120px;
    background: #f3f4f6;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.wpuf-pattern-visual {
    width: 80%;
    height: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pattern Visual Previews */
.wpuf-grid-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 100%;
    height: 100%;
}

.wpuf-grid-item {
    background: #3b82f6;
    border-radius: 2px;
}

.wpuf-list-preview {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    height: 100%;
}

.wpuf-list-item {
    background: #10b981;
    border-radius: 2px;
    height: 20px;
}

.wpuf-masonry-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    width: 100%;
    height: 100%;
}

.wpuf-masonry-item:first-child {
    background: #8b5cf6;
    border-radius: 2px;
    grid-row: span 2;
}

.wpuf-masonry-item:last-child {
    background: #8b5cf6;
    border-radius: 2px;
}

.wpuf-blank-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 2rem;
    color: #9ca3af;
    border: 2px dashed #d1d5db;
    border-radius: 6px;
}

.wpuf-pattern-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    text-align: left;
    padding-top: 0.5rem;
}

.wpuf-pattern-info h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.5rem 0;
    text-align: center;
}

.wpuf-pattern-info p {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.4;
    text-align: center;
}

/* Blank Directory Styles - Only for editor */
.wpuf-blank-directory-container {
    min-height: 300px;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.wpuf-blank-directory-notice {
    text-align: center;
    margin-bottom: 1.5rem;
}

.wpuf-blank-directory-notice p {
    color: #6b7280;
    font-size: 1rem;
    margin: 0;
}

.wpuf-directory-inner-blocks {
    width: 100%;
    min-height: 200px;
}

/* Responsive Design - Only for editor patterns */
@media (max-width: 768px) {
    .wpuf-pattern-grid {
        grid-template-columns: 1fr;
    }
}

/* Query Loop-style grid for user directory */
.is-layout-grid.columns-1 {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
}

.is-layout-grid.columns-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.is-layout-grid.columns-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.is-layout-grid.columns-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}

.is-layout-grid > li {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* User directory specific grid styles */
.wpuf-ud-list.is-layout-grid.columns-1 {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.wpuf-ud-list.is-layout-grid.columns-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.wpuf-ud-list.is-layout-grid.columns-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.wpuf-ud-list.is-layout-grid.columns-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}

.wpuf-ud-list.is-layout-grid > li {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Handle the nested structure in user directory */
.wpuf-ud-list.is-layout-grid > li > .wpuf-user-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.wpuf-ud-list.is-layout-grid > li > .wpuf-user-card > .wpuf-flex {
  height: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 32px 24px;
  box-sizing: border-box;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.wpuf-ud-list.is-layout-grid > li > .wpuf-user-card > .wpuf-flex:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

@media (max-width: 1024px) {
  .is-layout-grid.columns-3,
  .wpuf-ud-list.is-layout-grid.columns-3,
  .is-layout-grid.columns-4,
  .wpuf-ud-list.is-layout-grid.columns-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .is-layout-grid.columns-1,
  .wpuf-ud-list.is-layout-grid.columns-1,
  .is-layout-grid.columns-2,
  .wpuf-ud-list.is-layout-grid.columns-2,
  .is-layout-grid.columns-3,
  .wpuf-ud-list.is-layout-grid.columns-3,
  .is-layout-grid.columns-4,
  .wpuf-ud-list.is-layout-grid.columns-4 {
    grid-template-columns: 1fr;
  }
}

/* Dropdown Text Truncation - Prevent caret overlap */
.wpuf-ud-search-in,
.wpuf-ud-sort-by,
.wpuf-ud-sort-order {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    /* Ensure sufficient space for caret icon */
    padding-right: 3rem !important;
    /* Ensure consistent appearance across all dropdowns */
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure dropdown options are also properly truncated */
.wpuf-ud-search-in option,
.wpuf-ud-sort-by option,
.wpuf-ud-sort-order option {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%;
}

/* Ensure WordPress layout classes work properly in user directory */
.wp-block-group.is-layout-flex {
  display: flex;
}

.wp-block-group.is-vertical {
  flex-direction: column;
}

.wp-block-group.is-content-justification-center {
  justify-content: center;
}

.wp-block-group.is-content-justification-space-between {
  justify-content: space-between;
}

.wp-block-group.is-content-justification-left {
  justify-content: flex-start;
  align-items: flex-start;
}

.wp-block-group.is-content-justification-right {
  justify-content: flex-end;
}

/* Additional flexbox layout classes for complete coverage */
.wp-block-group.is-nowrap {
  flex-wrap: nowrap;
}

.wp-block-group.wp-block-group-is-layout-flex {
  display: flex;
}

/* Container classes for WordPress generated layouts */
.wp-container-core-group-is-layout-flex {
  display: flex;
}

/* Align items support */
.wp-block-group[style*="align-items: flex-start"] {
  align-items: flex-start;
}

.wp-block-group[style*="align-items: center"] {
  align-items: center;
}

.wp-block-group[style*="align-items: flex-end"] {
  align-items: flex-end;
}

/* Flex wrap support */
.wp-block-group[style*="flex-wrap: nowrap"] {
  flex-wrap: nowrap;
}

.wp-block-group[style*="flex-wrap: wrap"] {
  flex-wrap: wrap;
}
