/**
 * Sapje Subscription Editor - Frontend Styles
 *
 * @package    Sapje_Subscription_Editor
 * @subpackage Sapje_Subscription_Editor/assets/css
 */

/* ===========================
   Edit Button Styles
   =========================== */

.sapje-subscription-actions {
    margin: 20px 0;
}

.sapje-edit-subscription-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sapje-edit-subscription-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.sapje-btn-icon {
    font-size: 18px;
}

/* ===========================
   Modal Overlay
   =========================== */

.sapje-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    animation: sapje-fade-in 0.3s ease;
}

.sapje-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
}

/* ===========================
   Modal Container
   =========================== */

.sapje-modal-container {
    position: relative;
    max-width: 900px;
    max-height: 90vh;
    margin: 5vh auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: sapje-slide-up 0.3s ease;
}

/* ===========================
   Modal Header
   =========================== */

.sapje-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 30px;
    border-bottom: 1px solid #e0e0e0;
    background: #D7DE51;
    color: #fff;
    border-radius: 12px 12px 0 0;
}

#sapje-modal-title {
    color: #fff;
}

.sapje-modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.sapje-modal-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.sapje-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===========================
   Modal Body
   =========================== */

.sapje-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.sapje-modal-body::-webkit-scrollbar {
    width: 8px;
}

.sapje-modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sapje-modal-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.sapje-modal-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===========================
   Loading State
   =========================== */

.sapje-loading {
    text-align: center;
    padding: 60px 20px;
}

.sapje-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: sapje-spin 1s linear infinite;
}

/* ===========================
   Current Items Section
   =========================== */

.sapje-current-items {
    margin-bottom: 30px;
}

.sapje-current-items h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: #333;
}

.sapje-items-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sapje-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.sapje-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sapje-item-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.sapje-item-details {
    flex: 1;
}

.sapje-item-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    margin: 0 0 5px 0;
}

.sapje-item-price {
    color: #666;
    font-size: 14px;
}

.sapje-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sapje-qty-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px;
}

.sapje-qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #689053;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.sapje-qty-btn:hover:not(:disabled) {
    background: #5568d3;
}

.sapje-qty-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.sapje-qty-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    font-size: 16px;
}

.sapje-remove-item {
    width: 36px;
    height: 36px;
    border: none;
    background: #dc3545;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.sapje-remove-item:hover {
    background: #c82333;
}

/* ===========================
   Add Products Section
   =========================== */

.sapje-add-products {
    margin-bottom: 30px;
}

.sapje-add-products h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: #333;
}

.sapje-product-search {
    position: relative;
    margin-bottom: 20px;
}

.sapje-product-search input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease;
}

.sapje-product-search input:focus {
    outline: none;
    border-color: #667eea;
}

.sapje-search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    pointer-events: none;
}

.sapje-product-results {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.sapje-product-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.2s ease;
}

.sapje-product-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sapje-product-card.out-of-stock {
    opacity: 0.5;
    cursor: not-allowed;
}

.sapje-product-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.sapje-product-details {
    flex: 1;
}

.sapje-product-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
    margin: 0 0 5px 0;
}

.sapje-product-price {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.sapje-add-product-btn {
    padding: 10px 20px;
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.sapje-add-product-btn:hover:not(:disabled) {
    background: #218838;
}

.sapje-product-card.out-of-stock .sapje-add-product-btn {
    background: #ccc;
    cursor: not-allowed;
}

/* ===========================
   Summary Section
   =========================== */

.sapje-summary {
    background: #15393F;
    color: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.sapje-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 16px;
}

.sapje-summary-row:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sapje-new-total-row {
    font-weight: 700;
    font-size: 18px;
}

/* ===========================
   Changes Summary
   =========================== */

.sapje-changes-summary {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.sapje-changes-summary h4 {
    margin: 0 0 10px 0;
    color: #856404;
}

.sapje-changes-list {
    margin: 0;
    padding-left: 20px;
    color: #856404;
}

.sapje-changes-list li {
    margin-bottom: 5px;
}

/* ===========================
   Messages
   =========================== */

.sapje-error-message {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.sapje-success-message {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* ===========================
   Modal Footer
   =========================== */

.sapje-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
    align-items: center;
}

.sapje-modal-footer .button {
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sapje-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sapje-btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #fff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: sapje-spin 0.8s linear infinite;
    margin-left: 8px;
}

/* ===========================
   Animations
   =========================== */

@keyframes sapje-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes sapje-slide-up {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 768px) {
    .sapje-modal-container {
        max-width: 95%;
        margin: 2.5vh auto;
        max-height: 95vh;
    }

    .sapje-modal-header {
        padding: 20px;
    }

    .sapje-modal-header h2 {
        font-size: 20px;
    }

    .sapje-modal-body {
        padding: 20px;
    }

    .sapje-item {
        flex-direction: column;
        text-align: center;
    }

    .sapje-item-controls {
        width: 100%;
        justify-content: center;
    }

    .sapje-product-results {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .sapje-modal-footer {
        flex-direction: column;
        gap: 10px;
    }

    .sapje-modal-footer .button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sapje-product-results {
        grid-template-columns: 1fr;
    }
}

/* ===========================
   Accessibility
   =========================== */

.sapje-modal:focus-within {
    outline: none;
}

.sapje-modal-close:focus,
.sapje-qty-btn:focus,
.sapje-remove-item:focus,
.sapje-add-product-btn:focus,
.button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}