/**
 * QuickPostBuilder Admin Styles
 */

.quickpostbuilder-admin {
    max-width: 1200px;
}

/* Form Styles */
.quickpostbuilder-form {
    background: #fff;
    padding: 20px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    margin-bottom: 20px;
}

.quickpostbuilder-form .form-table th {
    width: 200px;
    vertical-align: top;
    padding-top: 15px;
}

.quickpostbuilder-form .required {
    color: #d63638;
    font-weight: bold;
}

/* Image Upload Area */
#qpb-image-upload-area {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    background: #f9f9f9;
}

#qpb-drop-zone {
    border: 2px dashed #aaa;
    border-radius: 4px;
    padding: 40px;
    text-align: center;
    background: #fff;
    transition: all 0.3s ease;
    cursor: pointer;
}

#qpb-drop-zone:hover {
    border-color: #0073aa;
    background: #f0f8ff;
}

#qpb-drop-zone.drag-over {
    border-color: #0073aa;
    background: #e6f3ff;
}

#qpb-drop-zone p {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #666;
}

/* Image Preview */
#qpb-image-preview {
    margin-top: 20px;
}

.qpb-image-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
}

.qpb-image-item {
    position: relative;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    width: 150px;
    cursor: move;
}

.qpb-image-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 2px;
}

.qpb-image-item .qpb-image-actions {
    position: absolute;
    top: 5px;
    right: 5px;
}

.qpb-remove-image {
    background: #d63638;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    line-height: 1;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
}

.qpb-remove-image:hover {
    background: #a02f32;
}

.qpb-image-title {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sortable placeholder */
.qpb-image-item.ui-sortable-placeholder {
    background: #f0f8ff;
    border: 2px dashed #0073aa;
    visibility: visible !important;
}

.qpb-image-item.ui-sortable-placeholder img {
    display: none;
}

/* Messages */
.qpb-message {
    padding: 12px;
    margin: 15px 0;
    border-radius: 4px;
}

.qpb-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.qpb-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.qpb-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.qpb-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Loading states */
.qpb-loading {
    opacity: 0.6;
    pointer-events: none;
}

#qpb-loading {
    margin-left: 10px;
    visibility: visible;
    float: none;
}

/* Responsive */
@media (max-width: 768px) {
    .qpb-image-list {
        gap: 10px;
    }

    .qpb-image-item {
        width: 120px;
    }

    .quickpostbuilder-form .form-table th {
        width: 150px;
    }
}

/* Categories and Tags */
select[multiple] {
    height: 120px;
}

/* Tag Suggestions */
.qpb-tag-suggestions {
    margin-top: 15px;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.qpb-tag-suggestions h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #333;
}

.qpb-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.qpb-tag-button {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 15px;
    padding: 6px 12px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.qpb-tag-button:hover {
    background: #f0f0f1;
    border-color: #0073aa;
    color: #0073aa;
}

.qpb-tag-button:active {
    background: #0073aa;
    color: #fff;
    transform: scale(0.98);
}

.qpb-tag-button.qpb-tag-selected {
    background: #00a32a;
    color: #fff;
    border-color: #00a32a;
}

.qpb-tag-count {
    opacity: 0.6;
    font-size: 11px;
    margin-left: 4px;
}

/* Post Action Select */
#qpb-post-action {
    width: 300px;
}

/* Preview Area */
#qpb-preview-area {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

#qpb-preview-content {
    border: 1px solid #ddd;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
}

#qpb-preview-content h1 {
    margin-top: 0;
    color: #333;
}

#qpb-preview-content .qpb-post-image {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    border-radius: 4px;
}

#qpb-preview-content .qpb-image-wrapper {
    margin: 15px 0;
}

/* Accessibility */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* Focus styles */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Error states */
.form-field-error {
    border-color: #d63638 !important;
    box-shadow: 0 0 0 1px #d63638 !important;
}

.form-field-error:focus {
    box-shadow: 0 0 0 2px #d63638 !important;
    outline: none;
}

/* Image Pattern Selection */
#qpb-pattern-selection {
    margin: 15px 0;
}

.qpb-pattern-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.qpb-pattern-options label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
}

.qpb-pattern-options label:hover {
    border-color: #0073aa;
    background: #f8f9fa;
}

.qpb-pattern-options input[type="radio"] {
    margin: 0 0 10px 0;
}

.qpb-pattern-options input[type="radio"]:checked+.qpb-pattern-preview {
    background: #e6f3ff;
    border-color: #0073aa;
}

.qpb-pattern-options label:has(input[type="radio"]:checked) {
    border-color: #0073aa;
    background: #f0f8ff;
}

.qpb-pattern-preview {
    width: 120px;
    height: 80px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
}

.pattern-demo {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.demo-row {
    display: flex;
    gap: 3px;
    flex: 1;
}

.demo-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.demo-col-vertical {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 30%;
}

.demo-image {
    background: #0073aa;
    border-radius: 2px;
    opacity: 0.7;
}

.demo-image.single {
    width: 100%;
    height: 18px;
    margin-bottom: 3px;
}

.demo-image.half {
    flex: 1;
    height: 100%;
}

.demo-image.third {
    flex: 1;
    height: 100%;
}

.demo-image.third-small {
    width: 25%;
    height: 100%;
}

.demo-image.large {
    flex: 2;
    height: 100%;
}

.demo-image.medium {
    flex: 1;
    height: 100%;
}

.demo-image.small {
    flex: 1;
    height: 48%;
}

.demo-image.small-vert {
    width: 100%;
    height: 48%;
}

.demo-image.small-three {
    flex: 1;
    height: 100%;
}

.pattern-label {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    color: #333;
}

/* Mixed Pattern Controls */
#qpb-mixed-pattern-controls {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-top: 15px;
}

#qpb-mixed-pattern-controls h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
}

.qpb-pattern-section {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.qpb-pattern-section select {
    min-width: 150px;
}

.qpb-pattern-section .qpb-image-range {
    display: flex;
    align-items: center;
    gap: 5px;
}

.qpb-pattern-section input[type="number"] {
    width: 60px;
}

.qpb-remove-section {
    background: #d63638;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 12px;
}

.qpb-remove-section:hover {
    background: #a02f32;
}

/* Pattern Preview Area */
#qpb-pattern-preview-area {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
}

#qpb-pattern-preview-area h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #333;
}

#qpb-pattern-preview-content {
    min-height: 100px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 10px;
}

/* Image Layout Patterns for Preview */
.qpb-preview-pattern-a .qpb-preview-image {
    width: 100%;
    margin-bottom: 15px;
    display: block;
}

.qpb-preview-pattern-b {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.qpb-preview-pattern-c {
    display: grid;
    grid-template-columns: 1fr 1fr 0.8fr;
    gap: 15px;
}


.qpb-preview-image {
    background: #ddd;
    min-height: 60px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #666;
    position: relative;
    overflow: hidden;
}

/* For demo images without actual image content */
.qpb-preview-image:not(:has(img)) {
    aspect-ratio: 1 / 1;
}

/* When using background images, maintain aspect ratio */
.qpb-preview-image[style*="background-image"] {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* For actual images */
.qpb-preview-image img {
    width: 100%;
    height: auto;
    max-height: 120px;
    object-fit: contain;
    border-radius: 4px;
}

.qpb-preview-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    font-size: 11px;
    text-align: center;
    border-radius: 0 0 4px 4px;
}

.qpb-preview-image[style*="background-image"] {
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    background-color: #333;
}

.qpb-preview-image[style*="background-image"]:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.qpb-preview-image[style*="background-image"] {
    z-index: 2;
    position: relative;
}

.qpb-preview-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.qpb-preview-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Post Content Pattern Styles */
.qpb-post-pattern {
    margin: 20px 0;
}

.qpb-post-image-wrapper {
    margin: 10px 0;
}

.qpb-post-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Pattern A: Single Column */
.qpb-post-pattern-a .qpb-post-image-wrapper {
    width: 100%;
    margin-bottom: 15px;
}

/* Pattern B: Two Columns (2x2 Grid) */
.qpb-post-pattern-b {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Pattern C: Three Columns */
.qpb-post-pattern-c {
    display: grid;
    grid-template-columns: 1fr 1fr 0.8fr;
    gap: 15px;
}


/* Responsive patterns for mobile */
@media (max-width: 768px) {

    .qpb-post-pattern-b,
    .qpb-post-pattern-c {
        grid-template-columns: 1fr;
    }

}

/* Mixed Pattern Sections */
.qpb-mixed-section {
    margin-bottom: 20px;
}

.qpb-mixed-section:last-child {
    margin-bottom: 0;
}

.qpb-mixed-section .qpb-post-pattern {
    margin: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .qpb-pattern-options {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .qpb-pattern-section {
        flex-direction: column;
        align-items: stretch;
    }

    .qpb-pattern-section .qpb-image-range {
        justify-content: space-between;
    }
}

/* Media Library Multiple Selection Enhancement */
.media-modal.qpb-media-modal .attachments-browser .attachments>li {
    position: relative;
    cursor: pointer;
}

.media-modal.qpb-media-modal .attachments-browser .attachments>li:hover {
    transform: scale(1.02);
    transition: all 0.2s ease;
    z-index: 1;
}

.media-modal.qpb-media-modal .attachments-browser .attachments>li.selected {
    box-shadow: 0 0 0 4px #0073aa !important;
    background-color: #e7f3ff !important;
}

.media-modal.qpb-media-modal .attachments-browser .attachments>li.selected .thumbnail {
    border: 3px solid #0073aa !important;
}

/* Add visual checkmark for selected items */
.media-modal.qpb-media-modal .attachments-browser .attachments>li.selected:after {
    content: "✓";
    position: absolute;
    top: 5px;
    right: 5px;
    background: #0073aa;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Style the instruction text */
.qpb-selection-instruction {
    font-size: 14px;
    color: #0073aa;
    font-weight: normal;
    margin-left: 10px;
    background: #e7f3ff;
    padding: 2px 8px;
    border-radius: 3px;
}

/* Add hover effect to make selection obvious */
.media-modal.qpb-media-modal .attachments-browser .attachments>li:hover:before {
    content: "クリックして選択";
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 115, 170, 0.9);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 100;
}
