/**
 * Card-Based Edit Order Screen
 * 
 * Redesigned styles for the customer order edit form using a card-based UI
 */

/* Container styling */
.customer-order-container {
    max-width: 100%;
    box-sizing: border-box;
    padding: 20px;
    background-color: #f8f9fa;
}

/* Main edit form container */
.customer-order-edit {
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Page header */
.customer-order-edit h2 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #333;
    font-weight: bold;
    text-align: center;
}

/* Status text in page header */
.status-text {
    display: inline-block;
    font-weight: normal;
    font-size: 18px;
    padding: 3px 12px;
    border-radius: 20px;
    color: #333;
    margin-left: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Combined order meta info container */
.order-meta-info {
    text-align: center;
    margin: -15px auto 15px auto;
    padding: 5px 10px;
    font-style: italic;
    display: block;
    width: 100%;
    max-width: 500px;
}

/* Status change history info */
.status-change-info, .printed-info {
    text-align: center;
    font-size: 11px;
    color: #666;
    margin: 0;
    padding: 1px 0;
    line-height: 0;
    display: block;
}

.status-change-info strong, .printed-info strong {
    color: #007cba;
    font-weight: 600;
}

/* Print info matches status change info */
.printed-info {
    color: #666;
}

.status-text.status-publish {
    background-color: #bbdefb; /* Pastel blue for received */
    border: 1px solid #90caf9;
}

.status-text.status-pending {
    background-color: #ffe0b2; /* Pastel orange for in the oven */
    border: 1px solid #ffcc80;
}

.status-text.status-completed {
    background-color: #c8e6c9; /* Pastel green for ready */
    border: 1px solid #a5d6a7;
}

.status-text.status-draft {
    background-color: #ffcdd2; /* Pastel red for canceled */
    border: 1px solid #ef9a9a;
}

/* Card styling for form sections */
.form-section {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.form-section:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

/* Section headers */
.form-section h3 {
    background-color: #f8f9fa;
    color: #333;
    padding: 15px 20px;
    margin: 0;
    border-bottom: 1px solid #eee;
    font-size: 18px;
    font-weight: 600;
}

/* Form groups within cards */
.form-group {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.form-group:last-child {
    border-bottom: none;
}

.form-group:hover {
    background-color: #f9f9f9;
}

/* Personal details section specifically */
.form-section:first-of-type .form-group {
    width: 100%;
}

/* Label styling */
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

/* Input field styling */
#customer-edit-form input[type="text"],
#customer-edit-form input[type="tel"],
#customer-edit-form input[type="email"],
#customer-edit-form select,
#customer-edit-form textarea {
    width: 100%;
    padding: 12px 25px !important;/* by nikos */
	border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
    height: auto; /* Ensure proper height */
    text-overflow: ellipsis; /* Add ellipsis for overflow */
    max-width: 100%; /* Ensure fields don't exceed container width */
}

/* Fix for the dynamic field section visibility issues */
#dynamic-fields-container select,
#dynamic-fields-container input {
    height: auto !important; /* Override any height restrictions */
    min-height: 46px; /* Ensure consistent height */
    white-space: normal; /* Allow text to wrap */
    word-break: break-word; /* Break long words if needed */
    text-align: left; /* Ensure left alignment */
    overflow: visible; /* Show any overflow */
    padding-right: 30px; /* Extra space for dropdown arrow */
}

/* Specific fixes for select elements */
#dynamic-fields-container select {
    appearance: menulist; /* Force native select appearance */
    -webkit-appearance: menulist; /* For Safari */
    -moz-appearance: menulist; /* For Firefox */
    background-color: white; /* Ensure white background */
    background-image: none; /* Remove any custom arrows */
    max-width: 100%; /* Ensure it doesn't overflow */
    overflow: hidden; /* Hide any overflow */
    text-overflow: ellipsis; /* Add ellipsis for overflow */
    padding-right: 25px; /* Space for dropdown arrow */
}

/* Make option text fully visible when dropdown is open */
#dynamic-fields-container select option {
    padding: 10px;
    white-space: normal;
    min-height: 30px;
    overflow: visible;
}

#customer-edit-form input:focus,
#customer-edit-form select:focus,
#customer-edit-form textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(111, 24, 52, 0.1);
}

/* Cake type toggle styling */
.cake-type-toggle {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.cake-type-toggle label {
    display: flex;
    align-items: center;
    background-color: #f0f0f0;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 180px;
    color: #333;
    border: 1px solid #ddd;
}

.cake-type-toggle label:hover {
    background-color: #e8e8e8;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.cake-type-toggle input[type="radio"] {
    margin-right: 10px;
}

/* Style for the selected toggle */
.cake-type-toggle label:has(input[type="radio"]:checked) {
    background-color: #007cba;
    color: #ffffff;
    border-color: #007cba;
    box-shadow: 0 2px 6px rgba(111,24,52,0.4);
}

/* Make the text clearly visible on the selected button */
.cake-type-toggle label span {
    font-size: 16px;
    font-weight: normal;
}

.cake-type-toggle label:has(input[type="radio"]:checked) span {
    color: #ffffff;
    font-weight: bold;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

/* Sugar paste message styling */
#sugar-paste-message {
    padding: 15px 20px;
    margin: 15px 20px;
    background-color: #fffaf0;
    border-left: 4px solid #ff9800;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Dynamic fields container styling */
#dynamic-fields-container {
    padding: 5px 0;
    margin: 15px 0;
}

/* Ensure each dynamic field has proper spacing */
#dynamic-fields-container .form-group {
    margin-bottom: 15px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #eee;
}

/* Image handling */
.current-image {
    padding: 15px 20px;
    text-align: center;
}

.current-image img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 15px auto;
    max-height: 300px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.file-info {
    display: block;
    margin-top: 8px;
    font-size: 12px;
    color: #777;
}

/* Admin actions styling */
.admin-order-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    background-color: #f0f0f0;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    margin-bottom: 25px;
    position: sticky;
    top: 20px;
    z-index: 999;
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
}

.admin-button {
    background-color: #007cba;
    color: white;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    padding: 0;
}

.admin-button:hover {
    background-color: #495057;
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.admin-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.button-icon {
    margin: 0;
    font-size: 18px;
}

/* Desktop/Mobile button switching */
.mobile-buttons {
    display: none;
}

.mobile-admin-button,
.mobile-button {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    background-color: #007cba;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-button {
    width: 48px;
    height: 48px;
}

.mobile-admin-button:active,
.mobile-button:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 2px rgba(111,24,52,0.5) inset !important;
}

.mobile-button.button-secondary {
    background-color: #e0e0e0;
    color: #333;
}

.mobile-admin-button .button-icon,
.mobile-button .button-icon {
    margin: 0 !important;
    font-size: 18px;
}

/* Add tooltips for all buttons */
.admin-button,
.mobile-admin-button,
.mobile-button {
    position: relative;
}

.admin-button:after,
.mobile-admin-button:after,
.mobile-button:after {
    content: attr(title);
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.admin-button:hover:after,
.mobile-admin-button:hover:after,
.mobile-button:hover:after {
    opacity: 1;
}

/* Desktop button styles */
.desktop-buttons {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    overflow-x: auto;
}

/* Status buttons with different colors */
.status-button {
    position: relative;
}

.status-buttons-separator {
    width: 2px;
    height: 24px;
    background-color: #ddd;
    margin: 0 5px;
}

.status-received {
    background-color: #bbdefb !important; /* Pastel blue for "received" */
    border: 1px solid #90caf9 !important;
    color: #1565c0 !important; /* Darker blue text for contrast */
}

.status-received:hover {
    background-color: #90caf9 !important;
}

.status-baking {
    background-color: #ffe0b2 !important; /* Pastel orange for "in the oven" */
    border: 1px solid #ffcc80 !important;
    color: #e65100 !important; /* Darker orange text for contrast */
}

.status-baking:hover {
    background-color: #ffcc80 !important;
}

.status-ready {
    background-color: #c8e6c9 !important; /* Pastel green for "ready" */
    border: 1px solid #a5d6a7 !important;
    color: #2e7d32 !important; /* Darker green text for contrast */
}

.status-ready:hover {
    background-color: #a5d6a7 !important;
}

.status-cancel {
    background-color: #ffcdd2 !important; /* Pastel red for "cancel" */
    border: 1px solid #ef9a9a !important;
    color: #b71c1c !important; /* Darker red text for contrast */
}

.status-cancel:hover {
    background-color: #ef9a9a !important;
}

/* Mobile adjustments */
@media (max-width: 767px) {
    /* No longer hide desktop buttons */
    .desktop-buttons {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
    }
    
    /* Hide mobile buttons since we're using desktop ones */
    .mobile-buttons {
        display: none !important;
    }
    
    /* Admin actions container spacing */
    .admin-order-actions {
        padding: 10px;
    }
    
    /* Form submit container spacing */
    .form-submit {
        padding: 10px;
    }
    
    /* Expand form group width in personal details section */
    .form-section .form-group {
        width: 100%;
        padding-left: 10px;
        padding-right: 10px;
    }
    
    /* Ensure input fields take full width */
    #customer-edit-form input[type="text"],
    #customer-edit-form input[type="tel"],
    #customer-edit-form input[type="email"] {
        width: 100%;
        min-width: 100%;
    }
}

/* Form action buttons */
.form-action-button {
    /* Distinct styling for form buttons */
    background-color: #007cba !important;
}

.form-action-button.save-button {
    background-color: #495057 !important; /* Different color for save */
    border: 1px solid #7d664b !important;
}

.form-action-button.save-button:hover {
    background-color: #7d664b !important;
}

.form-action-button.cancel-button {
    background-color: #777777 !important; /* Gray for cancel */
    border: 1px solid #666666 !important;
}

.form-action-button.cancel-button:hover {
    background-color: #666666 !important;
}

.button {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.button-primary {
    background-color: #007cba;
    color: white;
    margin-right: 10px;
}

.button-primary:hover {
    background-color: #495057;
}

.button-secondary {
    background-color: #e0e0e0;
    color: #333;
}

.button-secondary:hover {
    background-color: #d0d0d0;
}

/* Ajax response styling */
.ajax-response {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    text-align: center;
}

.ajax-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ajax-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Grid layout for all devices */
#customer-edit-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    max-width: 700px;
    margin: 0 auto;
}

.form-section {
    width: 100%;
    max-width: 100%;
}

.admin-order-actions,
.customer-order-edit h2,
.ajax-response,
.form-submit {
    width: 100%;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Tablet view */
@media (min-width: 768px) and (max-width: 991px) {
    #customer-edit-form {
        display: grid;
        grid-template-columns: 1fr;
    }
    
    .form-submit .button {
        flex: 1;
        min-width: 150px;
    }
    
    /* Improve form layout on tablets */
    .form-section {
        padding: 0;
        margin-bottom: 20px;
    }
    
    .form-section h3 {
        padding: 15px;
        margin-bottom: 10px;
    }
    
    /* Make personal details fields take full width */
    .form-section:first-of-type .form-group {
        padding: 10px 15px;
    }
    
    /* Expand input fields to full width */
    #customer-edit-form input[type="text"],
    #customer-edit-form input[type="tel"],
    #customer-edit-form input[type="email"] {
        width: 100%;
        min-width: 100%;
        max-width: none;
    }
}

/* Mobile view */
@media (max-width: 767px) {
    .customer-order-container,
    .customer-order-edit {
        padding: 8px;
    }
    
    /* Page title */
    .customer-order-edit h2 {
        font-size: 20px;
        margin: 10px 0;
    }
    
    .form-section {
        margin-bottom: 12px;
    }
    
    .form-section h3 {
        padding: 10px 15px;
        font-size: 16px;
    }
    
    /* Compress form fields on mobile */
    .form-group {
        padding: 10px 15px;
        margin-bottom: 5px;
    }
    
    /* Optimize input fields for mobile */
    #customer-edit-form input[type="text"],
    #customer-edit-form input[type="tel"],
    #customer-edit-form input[type="email"],
    #customer-edit-form select,
    #customer-edit-form textarea {
        padding: 10px;
        font-size: 16px;
        min-height: 40px;
    }
    
    /* Compact cake type toggle for mobile */
    .cake-type-toggle {
        flex-direction: row; /* Side by side on mobile */
        margin-bottom: 10px;
        gap: 8px;
    }
    
    .cake-type-toggle label {
        margin-bottom: 0;
        padding: 8px 10px;
        font-size: 14px;
        min-width: unset;
    }
    
    .cake-type-toggle .toggle-text {
        font-size: 14px;
    }
    
    /* More compact admin actions toolbar */
    .admin-order-actions {
        padding: 10px;
        gap: 5px;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: flex-start;
        width: 100%;
        background-color: #e7e7e7;
    }
    
    /* Submit buttons now integrated in top toolbar */
    
    /* Reduce empty space */
    #sugar-paste-message {
        padding: 10px;
        margin: 10px;
    }
    
    /* Make image container more compact */
    .current-image {
        padding: 10px;
    }
    
    .current-image img {
        max-height: 200px;
    }
}