/**
 * Customer Trade-In Management Plugin
 * Frontend Styles
 */

/* ===============================
   1. CONTAINER STYLES
   =============================== */

.ctim-form-container,
.ctim-history-container,
.ctim-dashboard-container {
    max-width: 100%;
    margin: 0 0 2em;
    padding: 1.5em;
    background-color: #f8f9fa;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ctim-processing-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.ctim-processing-search,
.ctim-processing-details,
.ctim-processing-form,
.ctim-processing-recent,
.ctim-password-form {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

.ctim-search-input {
    display: flex;
    gap: 10px;
}

.ctim-instructions {
    margin-bottom: 2em;
    padding: 1em;
    background-color: #f9f9f9;
    border-left: 5px solid #F38221;
}

/* ===============================
   2. TYPOGRAPHY & TITLES
   =============================== */

.ctim-form-title,
.ctim-history-title {
    color: #333;
    margin-bottom: 1.5em;
    font-size: 1.5em;
    border-bottom: 2px solid #F38221;
    padding-bottom: 0.5em;
}

/* ===============================
   3. FORM STYLES
   =============================== */

.ctim-form {
    margin-bottom: 1em;
}

.ctim-form-row {
    margin-bottom: 1.5em;
}

.ctim-form-label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: #333;
}

/* Base form field styles */
.ctim-form-input,
.ctim-form-textarea,
.ctim-form-select,
.ctim-form-file-input {
    padding: 0.75em;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 16px;
    background-color: #ffffff !important; /* Force white background for all fields */
}

/* Text inputs */
input[type="text"], 
input[type="number"], 
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="password"],
textarea,
select {
    background-color: #ffffff !important; /* Force white background */
}

/* Text area styles */
.ctim-form-textarea {
    width: 100%;
    min-height: 100px;
    resize: vertical;
}

/* Input sizing */
.ctim-form-input[type="number"],
.ctim-form-select,
.ctim-form-file-input {
    width: 350px; /* Consistent width for inputs */
    max-width: 100%;
}

/* Select dropdown styling */
select,
.ctim-form-select {
    height: auto !important;
    min-height: 42px;
    white-space: normal !important;
    text-overflow: clip !important;
    padding-right: 30px !important;
}

select option,
.ctim-form-select option {
    padding: 8px;
    background-color: #ffffff;
    white-space: normal;
}

/* File input styling */
input[type="file"] {
    background-color: #ffffff !important;
}

.ctim-form-hint {
    margin-top: 0.3em;
    font-size: 0.85em;
    color: #666;
    max-width: 350px;
}

/* Radio groups */
.ctim-radio-group {
    margin: 10px 0;
}

.ctim-radio-group label {
    display: block;
    margin-bottom: 8px;
}

/* ===============================
   4. PHOTO & PREVIEW STYLES
   =============================== */

.ctim-photo-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1em;
}

.ctim-photo-preview .photo-container {
    position: relative;
    width: 100px;
    height: 100px;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.ctim-photo-preview .photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ctim-delete-photo {
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
}

.ctim-delete-photo:hover {
    background-color: #d32f2f;
}

.ctim-photos-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1em;
}

.ctim-photo-link {
    display: block;
    width: 100px;
    height: 100px;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.ctim-photo-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.ctim-photo-link:hover .ctim-photo-thumb {
    transform: scale(1.1);
}

/* ===============================
   5. BUTTON STYLES
   =============================== */

.ctim-form-button {
    display: inline-block;
    padding: 0.75em 1.5em;
    background-color: #F38221;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.3s;
}

.ctim-form-button:hover {
    background-color: #E67100;
    color: white;
    text-decoration: none;
}

.ctim-form-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.ctim-button-secondary {
    background-color: #f44336;
}

.ctim-button-secondary:hover {
    background-color: #d32f2f;
}

.ctim-form-button.normal-width {
    display: inline-block;
    width: auto;
    min-width: 180px;
}

.print-button {
    background-color: #F38221;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 25px;
    margin-top: 15px;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    transition: background-color 0.3s;
}

.print-button:hover {
    background-color: #e67200;
}

.ctim-completion-container .close-button {
    background-color: #F38221;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 20px;
}

/* ===============================
   6. MESSAGE STYLES
   =============================== */

.ctim-message {
    padding: 1em;
    margin-bottom: 1.5em;
    border-radius: 4px;
    font-weight: 500;
}

.ctim-message-success {
    background-color: #dff0d8;
    border: 1px solid #d6e9c6;
    color: #3c763d;
}

.ctim-message-error {
    background-color: #f2dede;
    border: 1px solid #ebccd1;
    color: #a94442;
}

.ctim-message-info {
    background-color: #d9edf7;
    border: 1px solid #bce8f1;
    color: #31708f;
}

.ctim-certificate-redeemed-message {
    background-color: #f5f5f5;
    padding: 10px 15px;
    border-radius: 4px;
    border-left: 3px solid #f44336;
    margin-bottom: 15px;
}

.ctim-store-credit-notice {
    background-color: #dff0d8 !important;
    border-color: #d6e9c6 !important;
    color: #3c763d !important;
}

/* ===============================
   7. LOADING INDICATOR
   =============================== */

.ctim-loading {
    display: none;
    text-align: center;
    padding: 1em;
}

.ctim-loading:after {
    content: "";
    display: inline-block;
    width: 2em;
    height: 2em;
    border: 0.25em solid #F38221;
    border-radius: 50%;
    border-top-color: transparent;
    animation: ctim-spin 1s linear infinite;
}

@keyframes ctim-spin {
    to {
        transform: rotate(360deg);
    }
}

/* QR Code loading indicator */
.ctim-certificate-qr::before,
.certificate-qr::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 50%;
    border-top-color: #F38221;
    animation: ctim-spin 1s linear infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -10px;
    margin-left: -10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ctim-certificate-qr:not(:has(img)),
.certificate-qr:not(:has(img)) {
    position: relative;
}

.ctim-certificate-qr:not(:has(img))::before,
.certificate-qr:not(:has(img))::before {
    opacity: 1;
}

/* ===============================
   8. FILTER & OPTIONS
   =============================== */

.ctim-filter-options {
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.ctim-filter-options label {
    margin-right: 5px;
}

.ctim-filter-options select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-right: 15px;
}

.ctim-filter-options input[type="checkbox"] {
    margin-right: 15px;
}
.ctim-certificate-section {
    text-align: center;
}

.ctim-certificate-section .ctim-view-certificate {
    display: inline-block;
    width: auto;
    min-width: 180px;
    margin: 10px auto;
    text-align: center;
}
/* ===============================
   9. TABLE STYLES
   =============================== */

.ctim-history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1em;
}

.ctim-history-table th,
.ctim-history-table td {
    padding: 0.75em;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.ctim-history-table th {
    background-color: #f5f5f5;
    font-weight: 600;
}

.ctim-history-table tr:hover {
    background-color: #f9f9f9;
}

.ctim-details-row {
    background-color: #f9f9f9;
}

.ctim-details-cell {
    padding: 1.5em !important;
}

.ctim-processing-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.ctim-processing-table th,
.ctim-processing-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.ctim-processing-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

/* ===============================
   10. STATUS STYLES
   =============================== */

.ctim-status {
    display: inline-block;
    padding: 0.3em 0.6em;
    border-radius: 3px;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: capitalize;
}

.ctim-status-pending {
    background-color: #FFC107;
    color: #333;
}

.ctim-status-approved {
    background-color: #4CAF50;
    color: white;
}

.ctim-status-rejected {
    background-color: #f44336;
    color: white;
}

.ctim-status-countered {
    background-color: #2196F3;
    color: white;
}

.ctim-status-processed {
    background-color: #F38221;
    color: white;
}

/* ===============================
   11. DETAIL BOXES
   =============================== */

/* Bonus details styling */
.ctim-bonus-details {
    margin-top: 10px;
    padding: 10px;
    background-color: #f0f8ff;
    border-left: 3px solid #2196F3;
    border-radius: 3px;
}

.ctim-bonus-details p {
    margin: 5px 0;
    color: #333;
}

.ctim-counter-details,
.ctim-approved-details,
.ctim-rejected-details,
.ctim-pending-details {
    margin-top: 1em;
    padding: 1em;
    border-radius: 4px;
    background-color: #f5f5f5;
}

.ctim-counter-details h4,
.ctim-approved-details h4,
.ctim-rejected-details h4,
.ctim-pending-details h4 {
    margin-top: 0;
    margin-bottom: 0.5em;
    color: #333;
}

.ctim-counter-actions {
    margin-top: 1em;
    display: flex;
    gap: 10px;
}

/* ===============================
   12. TAB STYLES
   =============================== */

.ctim-tabs {
    display: flex;
    margin-bottom: 1.5em;
    border-bottom: 1px solid #ddd;
}

.ctim-tab {
    padding: 0.75em 1.5em;
    margin-right: 0.5em;
    text-decoration: none;
    color: #333;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s;
}

.ctim-tab:hover {
    background-color: #f5f5f5;
    text-decoration: none;
}

.ctim-tab.active {
    background-color: #fff;
    border-color: #ddd;
    border-bottom-color: #fff;
    margin-bottom: -1px;
    font-weight: 600;
    color: #F38221;
    text-decoration: none;
}

.ctim-tab-content {
    background-color: #fff;
    padding: 1.5em;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

/* ===============================
   13. CERTIFICATE STYLES
   =============================== */

/* Main certificate container */
.certificate {
    border: 2px solid #333;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 25px;
    max-width: 600px;
    margin: 20px auto;
    background: #fff url('/wp-content/plugins/f2f-core/modules/trade-in/media/marble.png') repeat;
    font-family: 'Arial', sans-serif;
    display: none; /* Hide by default, show only when needed */
}

.certificate-header {
    text-align: center;
    border-bottom: 2px solid #0e5d33;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

.certificate-header h2 {
    font-size: 28px;
    color: #0e5d33;
    margin: 0 0 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.certificate-id {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.certificate-body {
    margin-bottom: 25px;
}

.certificate-body p {
    margin: 12px 0;
    font-size: 16px;
    line-height: 1.5;
}

.certificate-body p strong {
    font-weight: bold;
    color: #0e5d33;
    min-width: 120px;
    display: inline-block;
}

.certificate-footer {
    border-top: 2px solid #0e5d33;
    padding-top: 20px;
    text-align: center;
}

.certificate-qr {
    display: block;
    margin: 0 auto;
    text-align: center;
}

.certificate-qr img {
    max-width: 180px;
    border: 1px solid #ddd;
    padding: 5px;
    background: white;
}

/* Certificate section styles */
.ctim-certificates-section,
.ctim-redeemed-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.ctim-certificates-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px;
}

.ctim-certificate {
    border: 2px solid #333;
    border-radius: 8px;
    padding: 15px;
    width: calc(50% - 10px);
    min-width: 300px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    background-color: #fff;
}

.ctim-certificate-header {
    text-align: center;
    border-bottom: 1px solid #0e5d33;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.ctim-certificate-header h2 {
    font-size: 20px;
    color: #0e5d33;
    margin: 0 0 5px;
}

.ctim-certificate-id {
    font-size: 16px;
    font-weight: bold;
}

.ctim-certificate-body {
    margin-bottom: 15px;
}

.ctim-certificate-body p {
    margin: 5px 0;
    font-size: 14px;
}

/* Certificate section and buttons */
.ctim-certificate-section {
    text-align: center;
}

.ctim-certificate-section .ctim-view-certificate {
    display: inline-block;
    width: auto;
    min-width: 180px;
    margin: 10px auto;
    text-align: center;
}

.ctim-certificate-footer {
    display: inline-block;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #ddd;
    padding-top: 10px;
    text-align: center;
}

.ctim-certificate-footer .ctim-view-certificate {
    display: inline-block;
    width: auto;
    min-width: 150px;
    text-align: center;
}

/* QR code styling */
.ctim-certificate-qr,
.certificate-qr {
    display: block;
    text-align: center;
    margin: 15px auto;
    width: auto;
    height: auto;
    min-height: 150px;
}

.ctim-certificate-qr img,
.certificate-qr img {
    width: 150px;
    height: 150px;
    max-width: 100%;
    border: 1px solid #ddd;
    padding: 5px;
    background-color: #fff;
    display: inline-block;
}

/* Redeemed certificate styles */
.ctim-certificate.ctim-certificate-redeemed {
    opacity: 0.7;
    background-color: #f8f8f8;
}

.ctim-certificate-processed {
    font-style: italic;
    color: #777;
}

/* Certificate buttons */
.ctim-view-certificate,
.ctim-certificate-redeemed {
    display: inline-block;
    padding: 8px 15px;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
    box-sizing: border-box;
}

.ctim-view-certificate:not(.ctim-certificate-redeemed) {
    background-color: #F38221; 
    color: white;
    border: none;
    text-decoration: none;
    transition: background-color 0.3s;
}

.ctim-view-certificate:not(.ctim-certificate-redeemed):hover {
    background-color: #e67200;
    text-decoration: none;
    color: white;
}

.ctim-certificate-redeemed {
    background-color: #888888;
    color: white;
    cursor: default;
    border: none;
}

/* ===============================
   14. COMPLETION STYLES
   =============================== */

.ctim-completion-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 30px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.ctim-completion-container .success-icon {
    color: #4CAF50;
    margin-bottom: 20px;
    font-size: 60px;
    line-height: 1;
}

.ctim-completion-container h1 {
    color: #333;
    margin-bottom: 20px;
}

.ctim-completion-container .details {
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.6;
}

/* ===============================
   15. MEDIA QUERIES
   =============================== */

/* Print styles */
@media print {
    .print-button,
    .ctim-tabs,
    .ctim-form-button {
        display: none;
    }
    
    .certificate {
        box-shadow: none;
        border: 1px solid #333;
        display: block !important;
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    .ctim-certificate-qr img,
    .certificate-qr img {
        display: block !important;
        width: 150px !important;
        height: 150px !important;
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
}

/* Small screens */
@media screen and (max-width: 600px) {
    .certificate {
        padding: 15px;
        margin: 10px auto;
    }
    
    .certificate-header h2 {
        font-size: 22px;
    }
    
    .certificate-id {
        font-size: 14px;
    }
    
    .certificate-body p {
        font-size: 14px;
        margin: 8px 0;
    }
    
    .certificate-qr img {
        max-width: 200px;
        max-height: 200px;
    }
    
    .ctim-certificate {
        width: 100%;
        min-width: auto;
    }
    
    .ctim-certificates-container {
        flex-direction: column;
    }
}

/* Medium screens */
@media screen and (max-width: 767px) {
    .ctim-certificates-container {
        display: block;
    }
    
    .ctim-certificate {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .ctim-certificate-footer {
        flex-direction: column;
    }
    
    .ctim-certificate-qr {
        margin-bottom: 15px;
    }
    
    .ctim-filter-options {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ctim-filter-options label, 
    .ctim-filter-options select,
    .ctim-filter-options input[type="checkbox"] {
        margin-bottom: 10px;
    }
}

/* Larger screens and tablets */
@media screen and (max-width: 768px) {
    .ctim-form-input[type="number"],
    .ctim-form-select,
    .ctim-form-file-input {
        width: 100%;
    }
    
    .ctim-history-table thead {
        display: none;
    }
    
    .ctim-history-table tr {
        display: block;
        margin-bottom: 1em;
        border: 1px solid #ddd;
    }
    
    .ctim-history-table td {
        display: block;
        text-align: right;
        border-bottom: 1px dotted #ddd;
        position: relative;
        padding-left: 50%;
    }
    
    .ctim-history-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0.75em;
        width: 45%;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
    }
    
    .ctim-history-table td:last-child {
        border-bottom: none;
    }
    
    .ctim-counter-actions {
        flex-direction: column;
    }
    
    .ctim-tabs {
        flex-direction: column;
        border-bottom: none;
    }
    
    .ctim-tab {
        border: 1px solid #ddd;
        border-radius: 4px;
        margin-bottom: 0.5em;
    }
    
    .ctim-tab.active {
        margin-bottom: 0.5em;
        border-bottom-color: #ddd;
    }
    
    .ctim-tab-content {
        border: 1px solid #ddd;
        border-radius: 4px;
    }
    
    .ctim-search-input {
        flex-direction: column;
    }
}