/* EntryKit Frontend Styles */

/* === Grid Layout === */
.ek-grid--card {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

/* Column overrides from block settings */
.ek-columns-1 .ek-grid--card { grid-template-columns: 1fr; }
.ek-columns-2 .ek-grid--card { grid-template-columns: repeat(2, 1fr); }
.ek-columns-3 .ek-grid--card { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.ek-columns-4 .ek-grid--card { grid-template-columns: repeat(4, 1fr); }

/* Card styles from block settings */
.ek-style-shadow .ek-card { border: none; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.ek-style-shadow .ek-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.ek-style-bordered .ek-card { box-shadow: none; border: 1px solid #e2e8f0; }
.ek-style-bordered .ek-card:hover { box-shadow: none; border-color: #3182ce; }
.ek-style-minimal .ek-card { box-shadow: none; border: none; border-bottom: 1px solid #edf2f7; border-radius: 0; }
.ek-style-minimal .ek-card:hover { box-shadow: none; transform: none; }

/* Toggle visibility from block settings */
.ek-hide-images .ek-card__image,
.ek-hide-images .ek-list__thumb { display: none; }
.ek-hide-category .ek-badge,
.ek-hide-category .ek-card__meta-item[data-type="category"] { display: none; }

/* === Card === */
.ek-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ek-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.ek-card__link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.ek-card__image {
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #f1f5f9;
}

.ek-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ek-card__body {
    padding: 1rem 1.25rem 1.25rem;
}

.ek-card__title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
    line-height: 1.3;
    color: #1a202c;
}

.ek-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.ek-badge {
    display: inline-block;
    font-size: 0.8125rem;
    padding: 0.2rem 0.6rem;
    background: #edf2f7;
    border-radius: 4px;
    color: #4a5568;
}

.ek-badge__label {
    font-weight: 600;
}

.ek-card__meta {
    margin-bottom: 0.75rem;
}

.ek-card__meta-item {
    display: block;
    font-size: 0.875rem;
    color: #718096;
    margin-bottom: 0.25rem;
}

.ek-card__meta-label {
    font-weight: 600;
    color: #4a5568;
}

.ek-card__summary {
    font-size: 0.875rem;
    color: #718096;
    line-height: 1.5;
    margin: 0 0 0.75rem;
}

.ek-card__contact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.ek-card__contact-item a {
    font-size: 0.875rem;
    color: #3182ce;
    text-decoration: none;
}

.ek-card__contact-item a:hover {
    text-decoration: underline;
}

/* === List Layout === */
.ek-list {
    margin: 1.5rem 0;
}

.ek-list__item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid #e2e8f0;
    align-items: flex-start;
}

.ek-list__item:last-child {
    border-bottom: none;
}

.ek-list__thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: #f1f5f9;
}

.ek-list__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ek-list__content {
    flex: 1;
    min-width: 0;
}

.ek-list__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.ek-list__title a {
    color: #1a202c;
    text-decoration: none;
}

.ek-list__title a:hover {
    color: #3182ce;
}

.ek-list__meta {
    font-size: 0.8125rem;
    color: #718096;
    margin-bottom: 0.25rem;
}

.ek-list__meta-item {
    display: inline;
}

.ek-list__meta-item a {
    color: #3182ce;
    text-decoration: none;
}

.ek-list__sep {
    margin: 0 0.25rem;
    color: #cbd5e0;
}

.ek-list__summary {
    font-size: 0.8125rem;
    color: #a0aec0;
    margin: 0.25rem 0 0;
}

/* === Table Layout === */
.ek-table-wrap {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.ek-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.ek-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
    color: #4a5568;
    white-space: nowrap;
}

.ek-table__row {
    border-bottom: 1px solid #edf2f7;
}

.ek-table__row:hover {
    background: #f7fafc;
}

.ek-table__cell {
    padding: 0.75rem 1rem;
    color: #4a5568;
    vertical-align: middle;
}

.ek-table__cell--title a {
    color: #1a202c;
    font-weight: 600;
    text-decoration: none;
}

.ek-table__cell--title a:hover {
    color: #3182ce;
}

.ek-table__cell a {
    color: #3182ce;
    text-decoration: none;
}

/* === Detail Page === */
.ek-detail {
    max-width: 800px;
    margin: 1.5rem 0;
}

.ek-detail__image {
    margin-bottom: 1.5rem;
    border-radius: 8px;
    overflow: hidden;
}

.ek-detail__img {
    width: 100%;
    height: auto;
    display: block;
}

.ek-detail__title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: #1a202c;
}

.ek-detail__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.ek-detail__contact {
    background: #f7fafc;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.ek-contact-item {
    padding: 0.375rem 0;
    font-size: 0.9375rem;
}

.ek-contact-item__label {
    font-weight: 600;
    color: #4a5568;
}

.ek-contact-item a {
    color: #3182ce;
    text-decoration: none;
}

.ek-contact-item a:hover {
    text-decoration: underline;
}

.ek-detail__section {
    margin-bottom: 1.5rem;
}

.ek-detail__section-label {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 0.5rem;
}

.ek-detail__section-value {
    color: #4a5568;
    line-height: 1.7;
}

.ek-detail__fields {
    border-top: 1px solid #e2e8f0;
    padding-top: 1rem;
}

.ek-detail__field {
    padding: 0.5rem 0;
    font-size: 0.9375rem;
}

.ek-detail__field-label {
    font-weight: 600;
    color: #4a5568;
}

.ek-detail__field-value {
    color: #2d3748;
}

/* === Smart Field Styles === */
.ek-field-phone a,
.ek-field-email a,
.ek-field-url a {
    color: #3182ce;
    text-decoration: none;
}

.ek-field-phone a:hover,
.ek-field-email a:hover,
.ek-field-url a:hover {
    text-decoration: underline;
}

.ek-field-date {
    color: #4a5568;
}

.ek-toggle-yes {
    color: #38a169;
    font-weight: 600;
}

.ek-toggle-no {
    color: #a0aec0;
}

/* Star Rating Display */
.ek-field-rating {
    display: inline-flex;
    gap: 1px;
}

.ek-star {
    font-size: 1.125rem;
    line-height: 1;
}

.ek-star--filled {
    color: #f6ad55;
}

.ek-star--empty {
    color: #e2e8f0;
}

/* Star Rating Input */
.ek-rating-input {
    display: inline-flex;
    gap: 2px;
    padding: 0.25rem 0;
}

.ek-star-pick {
    font-size: 1.75rem;
    color: #e2e8f0;
    cursor: pointer;
    transition: color 0.15s, transform 0.1s;
    line-height: 1;
    user-select: none;
}

.ek-star-pick:hover {
    transform: scale(1.15);
}

.ek-star-pick.ek-star--active {
    color: #f6ad55;
}

.ek-rating-input:hover .ek-star-pick {
    color: #e2e8f0;
}

.ek-rating-input .ek-star-pick:hover,
.ek-rating-input .ek-star-pick:hover ~ .ek-star-pick {
    color: #e2e8f0;
}

.ek-rating-input:hover .ek-star-pick:hover,
.ek-rating-input:hover .ek-star-pick:hover ~ .ek-star-pick ~ .ek-star-pick {
    color: #e2e8f0;
}

/* Hover fill effect - fill stars up to hovered one */
.ek-rating-input {
    direction: rtl;
    display: inline-flex;
}

.ek-rating-input .ek-star-pick {
    direction: ltr;
}

/* Simpler hover: just scale on hover, color handled by JS */
.ek-rating-input:not(:hover) .ek-star-pick.ek-star--active {
    color: #f6ad55;
}

/* === Submission Form === */
.ek-form-wrap {
    max-width: 640px;
    margin: 1.5rem 0;
}

.ek-form {
    position: relative;
}

.ek-form-field {
    margin-bottom: 1.25rem;
}

.ek-form-field label {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 0.375rem;
}

.ek-required {
    color: #e53e3e;
}

.ek-form-field input[type="text"],
.ek-form-field input[type="email"],
.ek-form-field input[type="tel"],
.ek-form-field input[type="url"],
.ek-form-field input[type="number"],
.ek-form-field input[type="date"],
.ek-form-field select,
.ek-form-field textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.9375rem;
    color: #2d3748;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.ek-form-field input:focus,
.ek-form-field select:focus,
.ek-form-field textarea:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.ek-form-field textarea {
    resize: vertical;
    min-height: 100px;
}

.ek-field-help {
    font-size: 0.8125rem;
    color: #a0aec0;
    margin: 0.25rem 0 0;
}

.ek-radio-group,
.ek-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ek-radio-label,
.ek-checkbox-label {
    font-weight: 400 !important;
    font-size: 0.9375rem;
    color: #4a5568;
    cursor: pointer;
}

.ek-radio-label input,
.ek-checkbox-label input {
    margin-right: 0.5rem;
}

/* Toggle switch */
.ek-toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.ek-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ek-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #cbd5e0;
    border-radius: 26px;
    transition: 0.2s;
}

.ek-toggle-slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.ek-toggle-switch input:checked + .ek-toggle-slider {
    background: #3182ce;
}

.ek-toggle-switch input:checked + .ek-toggle-slider:before {
    transform: translateX(22px);
}

.ek-submit-btn {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: #3182ce;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.ek-submit-btn:hover {
    background: #2b6cb0;
}

.ek-form-messages {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9375rem;
}

.ek-form-messages.ek-success {
    background: #f0fff4;
    border: 1px solid #c6f6d5;
    color: #276749;
}

.ek-form-messages.ek-error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c53030;
}

.ek-form-notice {
    padding: 1rem;
    background: #fffff0;
    border: 1px solid #fefcbf;
    border-radius: 6px;
    color: #744210;
}

/* === Empty State === */
.ek-entries-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #a0aec0;
    font-size: 1rem;
}

/* === Pagination === */
.ek-pagination {
    margin: 2rem 0;
    text-align: center;
}

.ek-pagination .page-numbers {
    display: inline-block;
    padding: 0.5rem 0.875rem;
    margin: 0 0.125rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    color: #4a5568;
    text-decoration: none;
    font-size: 0.875rem;
}

.ek-pagination .page-numbers.current {
    background: #3182ce;
    border-color: #3182ce;
    color: #fff;
}

.ek-pagination .page-numbers:hover:not(.current) {
    background: #f7fafc;
}

/* === Tags === */
.ek-tags-suggestions {
    margin-top: 0.375rem;
}

.ek-tag-suggestion {
    color: #3182ce;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.8125rem;
}

.ek-tag-suggestion:hover {
    text-decoration: underline;
}

.ek-entry-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.ek-entry-tag {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.2rem 0.625rem;
    background: #edf2f7;
    border-radius: 99px;
    color: #4a5568;
    text-decoration: none;
    transition: background 0.15s;
}

.ek-entry-tag:hover {
    background: #e2e8f0;
    color: #2d3748;
}

/* === Author Box === */
.ek-author-box {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    margin-top: 2rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.ek-author__avatar {
    flex-shrink: 0;
}

.ek-author__avatar-img {
    border-radius: 50%;
    display: block;
}

.ek-author__info {
    flex: 1;
    min-width: 0;
}

.ek-author__name {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: #1a202c;
}

.ek-author__bio {
    font-size: 0.875rem;
    color: #718096;
    line-height: 1.5;
    margin: 0 0 0.5rem;
}

.ek-author__meta {
    margin: 0;
}

.ek-author__entries-link {
    font-size: 0.8125rem;
    color: #3182ce;
    text-decoration: none;
}

.ek-author__entries-link:hover {
    text-decoration: underline;
}

/* === Block Placeholder === */
.ek-block-placeholder {
    text-align: center;
    padding: 3rem;
    background: #f7fafc;
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    color: #718096;
}

/* === Responsive === */
@media (max-width: 768px) {
    .ek-grid--card,
    .ek-columns-2 .ek-grid--card,
    .ek-columns-3 .ek-grid--card,
    .ek-columns-4 .ek-grid--card {
        grid-template-columns: 1fr;
    }

    .ek-list__thumb {
        width: 60px;
        height: 60px;
    }

    .ek-detail__title {
        font-size: 1.375rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .ek-columns-4 .ek-grid--card {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === Form Style Variations === */
.ek-form-style-compact .ek-form-field {
    margin-bottom: 0.75rem;
}

.ek-form-style-compact .ek-form-field label {
    font-size: 0.8125rem;
    margin-bottom: 0.2rem;
}

.ek-form-style-compact .ek-form-field input,
.ek-form-style-compact .ek-form-field select,
.ek-form-style-compact .ek-form-field textarea {
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
}

.ek-form-style-outlined .ek-form-field input,
.ek-form-style-outlined .ek-form-field select,
.ek-form-style-outlined .ek-form-field textarea {
    border-width: 2px;
    border-radius: 8px;
}

.ek-form-style-outlined .ek-form-field input:focus,
.ek-form-style-outlined .ek-form-field select:focus,
.ek-form-style-outlined .ek-form-field textarea:focus {
    border-color: #3182ce;
    box-shadow: none;
}

/* === File Input === */
.ek-form-field input[type="file"] {
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

/* === Flatpickr Overrides === */
.ek-form-field .flatpickr-input {
    background: #fff;
}

.ek-form-field .flatpickr-input + input.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.9375rem;
    color: #2d3748;
    background: #fff;
    box-sizing: border-box;
}

.ek-form-field .flatpickr-input + input.form-control:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}
