/**
 * Site Advertising Manager - Frontend Styles
 *
 * @package SiteAdvertisingManager
 */

/* ==========================================================================
   Shortcode Display - Grid Layout
   ========================================================================== */

.sam-advertisements {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.sam-advertisements.sam-columns-1 {
    grid-template-columns: 1fr;
}

.sam-advertisements.sam-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.sam-advertisements.sam-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.sam-advertisements.sam-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

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

@media (max-width: 480px) {
    .sam-advertisements.sam-columns-2,
    .sam-advertisements.sam-columns-3,
    .sam-advertisements.sam-columns-4 {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Advertisement Card
   ========================================================================== */

.sam-advertisement {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.sam-advertisement:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.sam-ad-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.sam-ad-content {
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Type-specific Display
   ========================================================================== */

/* Banner type only - hide square */
.sam-type-banner .sam-ad-square {
    display: none !important;
}

/* Square type only - hide banner */
.sam-type-square .sam-ad-banner {
    display: none !important;
}

/* Responsive type - show banner on desktop, square on mobile */
/* Default: hide square, show banner */
.sam-type-responsive .sam-advertisement .sam-ad-square,
.sam-type-responsive .sam-ad-square {
    display: none !important;
}

.sam-type-responsive .sam-advertisement .sam-ad-banner,
.sam-type-responsive .sam-ad-banner {
    display: block !important;
}

/* Mobile: hide banner, show square (only if ad has both images) */
@media (max-width: 768px) {
    .sam-type-responsive .sam-has-both .sam-ad-banner {
        display: none !important;
    }

    .sam-type-responsive .sam-has-both .sam-ad-square {
        display: flex !important;
    }
}

/* ==========================================================================
   Advertisement Images
   ========================================================================== */

.sam-ad-banner {
    width: 100%;
    overflow: hidden;
}

.sam-banner-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.sam-ad-square {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}

.sam-square-image {
    max-width: 100%;
    max-height: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Legacy support for .sam-ad-logo class */
.sam-ad-logo {
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sam-logo-image {
    max-width: 150px;
    max-height: 80px;
    height: auto;
}

.sam-ad-title {
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}

/* ==========================================================================
   BuddyPress Profile - View Tab
   ========================================================================== */

.sam-profile-advertisement {
    max-width: 100%;
}

.sam-status-box {
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    background: #f9f9f9;
    border-left: 4px solid #ccc;
}

.sam-status-box h3 {
    margin: 0 0 15px;
    font-size: 18px;
}

.sam-status-box p {
    margin: 8px 0;
}

/* Status colors */
.sam-status-pending,
.sam-status-box.sam-status-pending {
    border-left-color: #f0ad4e;
    background: #fcf8e3;
}

.sam-status-publish,
.sam-status-box.sam-status-publish {
    border-left-color: #5cb85c;
    background: #dff0d8;
}

.sam-status-expired,
.sam-status-box.sam-status-expired {
    border-left-color: #d9534f;
    background: #f2dede;
}

.sam-status-label span {
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
}

.sam-status-label .sam-status-pending {
    background: #f0ad4e;
    color: #fff;
}

.sam-status-label .sam-status-publish {
    background: #5cb85c;
    color: #fff;
}

.sam-status-label .sam-status-expired {
    background: #d9534f;
    color: #fff;
}

.sam-status-note {
    font-style: italic;
    color: #666;
    border-top: 1px dashed #ddd;
    padding-top: 10px;
    margin-top: 10px;
}

/* ==========================================================================
   BuddyPress Profile - Stats Box
   ========================================================================== */

.sam-stats-box {
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.sam-stats-box h3 {
    margin: 0 0 20px;
    font-size: 18px;
    color: #fff;
}

.sam-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 480px) {
    .sam-stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

.sam-stat-item {
    text-align: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

.sam-stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 5px;
}

.sam-stat-label {
    display: block;
    font-size: 13px;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sam-stats-note {
    margin-top: 15px;
    text-align: center;
    opacity: 0.8;
}

.sam-stats-note small {
    font-size: 12px;
}

/* ==========================================================================
   BuddyPress Profile - Ad Preview
   ========================================================================== */

.sam-ad-preview {
    margin-bottom: 30px;
}

.sam-ad-preview h3 {
    margin: 0 0 20px;
    font-size: 18px;
}

.sam-preview-details {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.sam-preview-details p {
    margin: 8px 0;
}

.sam-preview-banner,
.sam-preview-logo {
    margin-bottom: 20px;
}

.sam-preview-banner h4,
.sam-preview-logo h4 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #666;
}

.sam-banner-preview {
    max-width: 100%;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.sam-logo-preview {
    max-width: 200px;
    height: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.sam-no-content {
    color: #888;
    font-style: italic;
}

.sam-no-content a {
    display: block;
    margin-top: 10px;
}

/* ==========================================================================
   BuddyPress Profile - Actions
   ========================================================================== */

.sam-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.sam-expired-notice {
    padding: 20px;
    background: #f2dede;
    border-radius: 8px;
    text-align: center;
}

.sam-expired-notice p {
    margin: 0 0 15px;
    color: #a94442;
}

/* ==========================================================================
   BuddyPress Profile - Edit Form
   ========================================================================== */

.sam-edit-form-container {
    max-width: 100%;
}

.sam-edit-form-container h3 {
    margin: 0 0 25px;
    font-size: 20px;
}

.sam-edit-form {
    background: #fff;
    padding: 25px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.sam-form-field {
    margin-bottom: 25px;
}

.sam-form-field > label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.sam-form-field input[type="text"],
.sam-form-field input[type="url"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.sam-form-field input[type="text"]:focus,
.sam-form-field input[type="url"]:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

/* Image upload fields */
.sam-image-fields-container {
    display: flex;
    gap: 20px; /* space between the two fields */
    flex-wrap: wrap; /* allows stacking on smaller screens */
}

.sam-image-fields-container .sam-form-field {
    flex: 1; /* each field takes equal space */
    min-width: 300px; /* optional: prevents fields from getting too small */
}

.sam-image-field {
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.sam-image-preview {
    min-height: 60px;
    margin-bottom: 15px;
    padding: 10px;
    background: #fff;
    border: 2px dashed #ddd;
    border-radius: 4px;
    text-align: center;
}

.sam-image-preview img {
    max-width: 100%;
    max-height: 150px;
    height: auto;
}

.sam-image-inputs {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sam-upload-option,
.sam-url-option {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sam-upload-option label,
.sam-url-option label {
    font-size: 13px;
    color: #666;
}

.sam-or-divider {
    text-align: center;
    color: #999;
    font-size: 12px;
    font-style: italic;
}

.sam-remove-image {
    margin-top: 10px;
    padding: 6px 12px;
    background: #d9534f;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.sam-remove-image:hover {
    background: #c9302c;
}

/* Form actions */
.sam-form-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.sam-submit-btn {
    padding: 12px 24px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.sam-submit-btn:hover {
    background: #005a87;
}

.sam-submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.sam-form-status {
    font-size: 14px;
}

.sam-form-status.success {
    color: #5cb85c;
}

.sam-form-status.error {
    color: #d9534f;
}

.sam-edit-notice {
    margin-top: 20px;
    padding: 15px;
    background: #d9edf7;
    border-radius: 8px;
    font-size: 13px;
    color: #31708f;
}

.sam-edit-disabled {
    padding: 30px;
    text-align: center;
    background: #f5f5f5;
    border-radius: 8px;
    color: #666;
}

/* ==========================================================================
   No Advertisement State
   ========================================================================== */

.sam-no-advertisement {
    padding: 40px 20px;
}

.sam-no-ad-own {
    text-align: center;
    border-radius: 12px;
    padding: 40px;
}

.sam-no-ad-own i {
    font-size: 64px;
    color: #ff8126;
    margin-bottom: 16px;
    display: block;
}

.sam-no-ad-own h3 {
    margin: 0 0 12px;
    color: var(--n1-color, #ffffff);
    font-size: 20px;
}

.sam-no-ad-own p {
    color: var(--n2-color, #000000);
    margin: 0 0 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.sam-btn-create {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: rgba(var(--p6), 1);
    border: none;
    border-radius: 8px;
    color: var(--n1-color, #ffffff) !important;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.2s ease;
}

.sam-btn-create:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.sam-btn-create i {
    font-size: 18px;
    margin-bottom: 0 !important;
    line-height: 1;
}

/* Legacy button support */
.sam-no-advertisement .button {
    display: inline-block;
    padding: 12px 24px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
}

.sam-no-advertisement .button:hover {
    background: #005a87;
}

/* Responsive */
@media (max-width: 576px) {
    .sam-no-ad-own {
        padding: 30px 20px;
    }
}

/* ==========================================================================
   WooCommerce Order Integration
   ========================================================================== */

.sam-order-ad-status {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
}

.sam-order-ad-status .sam-status-pending {
    color: #8a6d3b;
}

.sam-order-ad-status .sam-status-publish {
    color: #3c763d;
}

.sam-order-ad-status .sam-status-expired {
    color: #a94442;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.sam-loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.sam-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: sam-spin 0.8s linear infinite;
}

@keyframes sam-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Hide Subnav Bar for My Advertisement
   ========================================================================== */

/* Hide the entire subnav when on my-ad component */
body.my-ad #subnav {
    display: none !important;
}

/* ==========================================================================
   Live Preview Section
   ========================================================================== */

.sam-live-preview-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #eee;
}

.sam-live-preview-section > label {
    font-size: 18px !important;
    margin-bottom: 5px !important;
}

.sam-field-description {
    margin: 0 0 15px;
    font-size: 13px;
    color: #666;
}

.sam-preview-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f5f5f5;
    border-radius: 6px;
}

.sam-preview-size-label {
    font-size: 13px;
    color: #666;
}

#sam-preview-dimensions {
    font-weight: 600;
    color: #333;
}

.sam-preview-buttons {
    display: flex;
    gap: 8px;
}

.sam-preview-preset {
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sam-preview-preset:hover {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.sam-preview-preset.active {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.sam-live-preview-container {
    background: #e0e0e0;
    padding: 20px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.sam-live-preview-wrapper {
    position: relative;
    width: 100%;
    max-width: 800px;
    min-width: 280px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    resize: horizontal;
    overflow: hidden;
}

.sam-live-preview {
    margin: 0 !important;
    gap: 0 !important;
}

.sam-live-preview .sam-advertisement {
    border-radius: 0;
    border: none;
}

.sam-live-preview .sam-ad-content {
    min-height: 100px;
}

/* Resize handle */
.sam-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, #0073aa 50%);
    border-radius: 0 0 8px 0;
}

.sam-resize-handle::before {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
}

/* Preview link - clickable, opens in new tab */
.sam-preview-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.sam-preview-note {
    margin-top: 10px;
    font-size: 12px;
    color: #888;
    font-style: italic;
}

/* Preview empty state */
.sam-live-preview .sam-no-images {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Responsive preview behavior */
.sam-live-preview-wrapper[data-width="mobile"] .sam-ad-banner {
    display: none !important;
}

.sam-live-preview-wrapper[data-width="mobile"] .sam-ad-square {
    display: flex !important;
}

.sam-live-preview-wrapper[data-width="desktop"] .sam-ad-banner {
    display: block !important;
}

.sam-live-preview-wrapper[data-width="desktop"] .sam-ad-square {
    display: none !important;
}

/* View page preview styling */
.sam-view-preview {
    margin-top: 30px;
    padding: 25px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.sam-view-preview h3 {
    margin: 0 0 10px;
    font-size: 18px;
    color: #333;
}

.sam-view-preview + .sam-preview-details {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}
