/**
 * Frontend Styles for Custom Mobile Auth & Courier Plugin
 */

/* Hide email-based login/register forms on My Account page when mobile auth is active */
.cmac-mobile-only-auth form.woocommerce-form-login:not(.cmac-form),
.cmac-mobile-only-auth form.woocommerce-form-register:not(.cmac-form),
.cmac-mobile-only-auth form.login:not(.cmac-form),
.cmac-mobile-only-auth form.register:not(.cmac-form),
.cmac-mobile-only-auth .woocommerce-form-login__username,
.cmac-mobile-only-auth .woocommerce-form-login__password,
.cmac-mobile-only-auth .woocommerce-form-register__email,
.cmac-mobile-only-auth .woocommerce-form-register__password,
.cmac-mobile-only-auth input[name="username"]:not([name="mobile_number"]),
.cmac-mobile-only-auth input[name="email"],
.cmac-mobile-only-auth input[name="password"]:not([name="otp_code"]),
.cmac-mobile-only-auth .woocommerce-LostPassword {
    display: none !important;
}

/* Mobile Auth Forms */
.cmac-mobile-form {
    background: #f9f9f9;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.cmac-mobile-form h3 {
    margin-top: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.cmac-form-group {
    margin-bottom: 15px;
}

.cmac-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.cmac-mobile-input {
    display: flex;
    gap: 10px;
}

.cmac-mobile-input select {
    width: 120px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

.cmac-mobile-input input[type="tel"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

.cmac-otp-section input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 18px;
    text-align: center;
    letter-spacing: 2px;
}

.cmac-form-group button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.cmac-form-group button.button-primary {
    background: #0073aa;
    color: #fff;
}

.cmac-form-group button.button-primary:hover {
    background: #005a87;
}

.cmac-form-group button.button-secondary {
    background: #f1f1f1;
    color: #333;
    border: 1px solid #ccc;
}

.cmac-form-group button.button-secondary:hover {
    background: #e1e1e1;
}

.cmac-form-group button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cmac-form-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.cmac-form-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #ddd;
}

.cmac-form-divider span {
    background: #f9f9f9;
    padding: 0 15px;
    color: #666;
    font-size: 14px;
}

/* Messages */
.cmac-messages {
    margin-top: 15px;
}

.cmac-success {
    background: #d4edda;
    color: #155724;
    padding: 10px 15px;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 10px;
}

.cmac-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 15px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-bottom: 10px;
}

/* Checkout Integration */
.cmac-checkout-auth {
    background: #fff;
    border: 2px solid #0073aa;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
}

.cmac-checkout-auth-header h3 {
    color: #0073aa;
    margin-top: 0;
    font-size: 20px;
}

.cmac-checkout-auth-header p {
    color: #666;
    margin-bottom: 20px;
}

.cmac-checkout-auth-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.cmac-checkout-auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #ddd;
}

.cmac-checkout-auth-divider span {
    background: #fff;
    padding: 0 15px;
    color: #666;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cmac-mobile-input {
        flex-direction: column;
    }
    
    .cmac-mobile-input select {
        width: 100%;
    }
    
    .cmac-form-group button {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .cmac-checkout-auth {
        padding: 20px 15px;
    }
}

/* Loading States */
.cmac-loading {
    position: relative;
    pointer-events: none;
}

.cmac-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: cmac-spin 1s linear infinite;
}

@keyframes cmac-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* OTP Input Styling */
.cmac-otp-section {
    animation: cmac-slideDown 0.3s ease-out;
}

@keyframes cmac-slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Validation */
.cmac-form-group input.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.cmac-form-group input.success {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Custom Order Status */
.order-status.status-ready-for-courier {
    background: #ff6b35;
    color: #fff;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.order-status.status-ready-for-courier:after {
    content: "\f0d1";
    font-family: dashicons;
    margin-left: 5px;
}

/* Admin Order Actions */
.widefat .column-order_actions .button.send-to-courier {
    background: #ff6b35;
    color: #fff;
    border-color: #ff6b35;
}

.widefat .column-order_actions .button.send-to-courier:hover {
    background: #e55a2b;
    border-color: #e55a2b;
}

/* Mobile Number Display */
.cmac-mobile-display {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f0f0f0;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
}

.cmac-mobile-display::before {
    content: "\f525";
    font-family: dashicons;
    color: #0073aa;
}

/* Success Animation */
.cmac-success-animation {
    animation: cmac-successPulse 0.6s ease-in-out;
}

@keyframes cmac-successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* New User Registration Form */
.cmac-new-user-form {
    margin-top: 20px;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.cmac-new-user-form h4 {
    margin-top: 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.cmac-new-user-form .cmac-form-group {
    margin-bottom: 15px;
}

.cmac-new-user-form .cmac-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.cmac-new-user-form .cmac-form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.cmac-new-user-form .cmac-form-group input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

/* Message Types */
.cmac-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 10px 15px;
    border-radius: 4px;
    margin: 10px 0;
}

/* Tab Switcher */
.cmac-tab-switcher {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.cmac-tab-btn {
    flex: 1;
    padding: 10px 20px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.cmac-tab-btn.active {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.cmac-tab-btn:hover {
    background: #e9e9e9;
}

.cmac-tab-btn.active:hover {
    background: #005a87;
}

/* Modal Styles */
.cmac-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
}

/* OTP Step Visibility - Force visible when shown */
.cmac-modal .cmac-otp-step {
    display: none;
}

.cmac-modal .cmac-otp-step.cmac-otp-step-visible {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.cmac-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.cmac-modal-content {
    position: relative;
    z-index: 2;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    margin: 5vh auto;
}

.cmac-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.cmac-modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.cmac-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.cmac-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.cmac-modal-body {
    padding: 20px;
}

.cmac-modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    background: #f9f9f9;
}

/* Minimog Modal Compatibility - scoped to our modal only */
#cmac-mobile-login-modal.minimog-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
}

#cmac-mobile-login-modal.minimog-modal.open {
    display: block;
}

#cmac-mobile-login-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

#cmac-mobile-login-modal .modal-content {
    position: relative;
    z-index: 2;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    margin: 5vh auto;
}

#cmac-mobile-login-modal .modal-content-wrap {
    padding: 0;
}

#cmac-mobile-login-modal .modal-content-inner {
    padding: 0;
}

#cmac-mobile-login-modal .modal-content-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    position: relative;
}

#cmac-mobile-login-modal .modal-content-header h3 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

#cmac-mobile-login-modal .modal-content-header p {
    margin: 10px 0 0 0;
    color: #666;
}

#cmac-mobile-login-modal .modal-content-body {
    padding: 20px;
}

#cmac-mobile-login-modal .button-close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

#cmac-mobile-login-modal .button-close-modal:hover {
    background: #f0f0f0;
    color: #333;
}

/* Tab Content */
.cmac-tab-content {
    display: none;
}

.cmac-tab-content.active {
    display: block;
}

/* Link Transition */
.link-transition-01 {
    color: #0073aa;
    text-decoration: none;
    transition: color 0.3s ease;
}

.link-transition-01:hover {
    color: #005a87;
    text-decoration: underline;
}

/* Hide password and account creation fields on checkout (OTP-based registration only) */
.woocommerce-checkout .woocommerce-account-fields,
.woocommerce-checkout .create-account,
.woocommerce-checkout input[name="createaccount"],
.woocommerce-checkout #createaccount,
.woocommerce-checkout .woocommerce-form__label-for-checkbox.create-account,
.woocommerce-checkout input[name="account_password"],
.woocommerce-checkout #account_password,
.woocommerce-checkout input[name="account_username"],
.woocommerce-checkout #account_username,
.woocommerce-checkout .woocommerce-form-row--wide.account-password,
.woocommerce-checkout .woocommerce-form-row--wide.account-username {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}